video: driver: add support for create buf
Add handling for VIDIOC_CREATE_BUFS ioctl in driver. This ioctl is used to create buffers for memory mapped or DMA buffer I/O. It can be used as an alternative or in addition to the ioctl VIDIOC_REQBUFS ioctl, when a tighter control over buffers is required. This ioctl can be called multiple times to create buffers of different sizes. Partially Fixes: v4l2-compliance: test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF. Change-Id: I9dd6c3f48e48e297b3e56fd4c8062869c8b55bee Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
This commit is contained in:
@@ -27,6 +27,7 @@ int msm_vidc_s_param(void *instance, struct v4l2_streamparm *sp);
|
||||
int msm_vidc_g_param(void *instance, struct v4l2_streamparm *sp);
|
||||
int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
|
||||
int msm_vidc_querybuf(void *instance, struct v4l2_buffer *b);
|
||||
int msm_vidc_create_bufs(void *instance, struct v4l2_create_buffers *b);
|
||||
int msm_vidc_release_buffer(void *instance, int buffer_type,
|
||||
unsigned int buffer_index);
|
||||
int msm_vidc_qbuf(void *instance, struct media_device *mdev,
|
||||
|
@@ -36,6 +36,8 @@ int msm_v4l2_reqbufs(struct file *file, void *fh,
|
||||
struct v4l2_requestbuffers *b);
|
||||
int msm_v4l2_querybuf(struct file *file, void *fh,
|
||||
struct v4l2_buffer *b);
|
||||
int msm_v4l2_create_bufs(struct file *filp, void *fh,
|
||||
struct v4l2_create_buffers *b);
|
||||
int msm_v4l2_qbuf(struct file *file, void *fh,
|
||||
struct v4l2_buffer *b);
|
||||
int msm_v4l2_dqbuf(struct file *file, void *fh,
|
||||
|
@@ -441,6 +441,37 @@ exit:
|
||||
}
|
||||
EXPORT_SYMBOL(msm_vidc_querybuf);
|
||||
|
||||
int msm_vidc_create_bufs(void *instance, struct v4l2_create_buffers *b)
|
||||
{
|
||||
int rc = 0;
|
||||
struct msm_vidc_inst *inst = instance;
|
||||
int port;
|
||||
struct v4l2_format *f;
|
||||
|
||||
if (!inst || !b) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
f = &b->format;
|
||||
port = v4l2_type_to_driver_port(inst, f->type, __func__);
|
||||
if (port < 0) {
|
||||
rc = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rc = vb2_create_bufs(inst->bufq[port].vb2q, b);
|
||||
if (rc) {
|
||||
i_vpr_e(inst, "%s: vb2_create_bufs(%d) failed, %d\n",
|
||||
__func__, f->type, rc);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_vidc_create_bufs);
|
||||
|
||||
int msm_vidc_qbuf(void *instance, struct media_device *mdev,
|
||||
struct v4l2_buffer *b)
|
||||
{
|
||||
|
@@ -61,6 +61,7 @@ static struct v4l2_ioctl_ops msm_v4l2_ioctl_ops_enc = {
|
||||
.vidioc_g_parm = msm_v4l2_g_parm,
|
||||
.vidioc_reqbufs = msm_v4l2_reqbufs,
|
||||
.vidioc_querybuf = msm_v4l2_querybuf,
|
||||
.vidioc_create_bufs = msm_v4l2_create_bufs,
|
||||
.vidioc_qbuf = msm_v4l2_qbuf,
|
||||
.vidioc_dqbuf = msm_v4l2_dqbuf,
|
||||
.vidioc_streamon = msm_v4l2_streamon,
|
||||
@@ -99,6 +100,7 @@ static struct v4l2_ioctl_ops msm_v4l2_ioctl_ops_dec = {
|
||||
.vidioc_g_parm = msm_v4l2_g_parm,
|
||||
.vidioc_reqbufs = msm_v4l2_reqbufs,
|
||||
.vidioc_querybuf = msm_v4l2_querybuf,
|
||||
.vidioc_create_bufs = msm_v4l2_create_bufs,
|
||||
.vidioc_qbuf = msm_v4l2_qbuf,
|
||||
.vidioc_dqbuf = msm_v4l2_dqbuf,
|
||||
.vidioc_streamon = msm_v4l2_streamon,
|
||||
|
@@ -347,6 +347,30 @@ unlock:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_v4l2_create_bufs(struct file *filp, void *fh,
|
||||
struct v4l2_create_buffers *b)
|
||||
{
|
||||
struct msm_vidc_inst *inst = get_vidc_inst(filp, fh);
|
||||
int rc = 0;
|
||||
|
||||
inst = get_inst_ref(g_core, inst);
|
||||
if (!inst) {
|
||||
d_vpr_e("%s: invalid instance\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
inst_lock(inst, __func__);
|
||||
rc = msm_vidc_create_bufs((void *)inst, b);
|
||||
if (rc)
|
||||
goto unlock;
|
||||
|
||||
unlock:
|
||||
inst_unlock(inst, __func__);
|
||||
put_inst(inst);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_v4l2_qbuf(struct file *filp, void *fh,
|
||||
struct v4l2_buffer *b)
|
||||
{
|
||||
|
مرجع در شماره جدید
Block a user