浏览代码

video: driver: add support for query buf

Add handling for VIDIOC_QUERYBUF ioctl in driver.
This can be used to query the status of a buffer
at any time after buffers have been allocated with
the VIDIOC_REQBUFS ioctl.

Partially Fixes: v4l2-compliance:
                test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF.

Change-Id: Ifd014bd8a8b02ce9fa15c62d7583bc8bcfb6756a
Signed-off-by: Dikshita Agarwal <[email protected]>
Dikshita Agarwal 3 年之前
父节点
当前提交
bf0e8166d8

+ 1 - 0
driver/vidc/inc/msm_vidc.h

@@ -26,6 +26,7 @@ int msm_vidc_g_selection(void* instance, struct v4l2_selection* s);
 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_release_buffer(void *instance, int buffer_type,
 		unsigned int buffer_index);
 int msm_vidc_qbuf(void *instance, struct media_device *mdev,

+ 2 - 0
driver/vidc/inc/msm_vidc_v4l2.h

@@ -34,6 +34,8 @@ int msm_v4l2_g_parm(struct file *file, void *fh,
 		struct v4l2_streamparm *a);
 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_qbuf(struct file *file, void *fh,
 		struct v4l2_buffer *b);
 int msm_v4l2_dqbuf(struct file *file, void *fh,

+ 29 - 0
driver/vidc/src/msm_vidc.c

@@ -412,6 +412,35 @@ exit:
 }
 EXPORT_SYMBOL(msm_vidc_reqbufs);
 
+int msm_vidc_querybuf(void *instance, struct v4l2_buffer *b)
+{
+	int rc = 0;
+	struct msm_vidc_inst *inst = instance;
+	int port;
+
+	if (!inst || !b) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	port = v4l2_type_to_driver_port(inst, b->type, __func__);
+	if (port < 0) {
+		rc = -EINVAL;
+		goto exit;
+	}
+
+	rc = vb2_querybuf(inst->bufq[port].vb2q, b);
+	if (rc) {
+		i_vpr_e(inst, "%s: vb2_querybuf(%d) failed, %d\n",
+			__func__, b->type, rc);
+		goto exit;
+	}
+
+exit:
+	return rc;
+}
+EXPORT_SYMBOL(msm_vidc_querybuf);
+
 int msm_vidc_qbuf(void *instance, struct media_device *mdev,
 		struct v4l2_buffer *b)
 {

+ 2 - 0
driver/vidc/src/msm_vidc_platform.c

@@ -60,6 +60,7 @@ static struct v4l2_ioctl_ops msm_v4l2_ioctl_ops_enc = {
 	.vidioc_s_parm                  = msm_v4l2_s_parm,
 	.vidioc_g_parm                  = msm_v4l2_g_parm,
 	.vidioc_reqbufs                 = msm_v4l2_reqbufs,
+	.vidioc_querybuf                = msm_v4l2_querybuf,
 	.vidioc_qbuf                    = msm_v4l2_qbuf,
 	.vidioc_dqbuf                   = msm_v4l2_dqbuf,
 	.vidioc_streamon                = msm_v4l2_streamon,
@@ -97,6 +98,7 @@ static struct v4l2_ioctl_ops msm_v4l2_ioctl_ops_dec = {
 	.vidioc_s_parm                  = msm_v4l2_s_parm,
 	.vidioc_g_parm                  = msm_v4l2_g_parm,
 	.vidioc_reqbufs                 = msm_v4l2_reqbufs,
+	.vidioc_querybuf                = msm_v4l2_querybuf,
 	.vidioc_qbuf                    = msm_v4l2_qbuf,
 	.vidioc_dqbuf                   = msm_v4l2_dqbuf,
 	.vidioc_streamon                = msm_v4l2_streamon,

+ 24 - 0
driver/vidc/src/msm_vidc_v4l2.c

@@ -323,6 +323,30 @@ unlock:
 	return rc;
 }
 
+int msm_v4l2_querybuf(struct file *filp, void *fh,
+				struct v4l2_buffer *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_querybuf((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)
 {