aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-10-19 10:37:04 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2015-10-19 10:37:04 +0200
commit3ba7bbb7a5985fe50fd0ffd9464e5e1f1536e2d4 (patch)
tree7cca20d34fff3664af5ff9d01790a9913bb320dc
parentc163c262a2d4dd8600cfa2b77b35bec3c3fb36c8 (diff)
fix mplane CSCcsc
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c69
1 files changed, 38 insertions, 31 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 0520407b1409..e8d4be6d74c7 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -980,52 +980,59 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
return -EINVAL;
}
+/*
+ * The v4l2_pix_format structure has been extended with fields that were
+ * not previously required to be set to zero by applications. The priv
+ * field, when set to a magic value, indicates the the extended fields
+ * are valid. Otherwise they will contain undefined values. To simplify
+ * the API towards drivers zero the extended fields and set the priv
+ * field to the magic value when the extended pixel format structure
+ * isn't used by applications.
+ *
+ * Also process the REQUEST_CSC flag: if set for a video capture type,
+ * then keep the colorspace fields, otherwise clear them. In all cases
+ * clear the flag: the driver has to set it again to signal that it
+ * supports CSC hardware.
+ */
static void v4l_sanitize_format(struct v4l2_format *fmt)
{
- unsigned int offset;
- unsigned int csc = fmt->fmt.pix.flags & V4L2_PIX_FMT_FLAG_REQUEST_CSC;
+ bool csc;
- /*
- * The v4l2_pix_format structure has been extended with fields that were
- * not previously required to be set to zero by applications. The priv
- * field, when set to a magic value, indicates the the extended fields
- * are valid. Otherwise they will contain undefined values. To simplify
- * the API towards drivers zero the extended fields and set the priv
- * field to the magic value when the extended pixel format structure
- * isn't used by applications.
- */
+ if (V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) {
+ csc = fmt->fmt.pix_mp.flags & V4L2_PIX_FMT_FLAG_REQUEST_CSC;
+ fmt->fmt.pix_mp.flags &= ~V4L2_PIX_FMT_FLAG_REQUEST_CSC;
- fmt->fmt.pix.flags &= ~V4L2_PIX_FMT_FLAG_REQUEST_CSC;
-
- if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
- if (csc)
- return;
- fmt->fmt.pix.colorspace = V4L2_COLORSPACE_DEFAULT;
- fmt->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT;
- fmt->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
- fmt->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT;
+ if (!csc && fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+ fmt->fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT;
+ fmt->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT;
+ fmt->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
+ fmt->fmt.pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT;
+ }
+ return;
}
if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
fmt->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
return;
- if (fmt->fmt.pix.priv == V4L2_PIX_FMT_PRIV_MAGIC) {
- if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || csc)
- return;
+ if (fmt->fmt.pix.priv != V4L2_PIX_FMT_PRIV_MAGIC) {
+ unsigned offset = offsetof(struct v4l2_pix_format, priv)
+ + sizeof(fmt->fmt.pix.priv);
+
+ memset(((void *)&fmt->fmt.pix) + offset, 0,
+ sizeof(fmt->fmt.pix) - offset);
+ fmt->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+ }
+
+ csc = fmt->fmt.pix.flags & V4L2_PIX_FMT_FLAG_REQUEST_CSC;
+ fmt->fmt.pix.flags &= ~V4L2_PIX_FMT_FLAG_REQUEST_CSC;
+
+ if (!csc && fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_DEFAULT;
fmt->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT;
fmt->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
fmt->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT;
- return;
}
-
- fmt->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
-
- offset = offsetof(struct v4l2_pix_format, priv)
- + sizeof(fmt->fmt.pix.priv);
- memset(((void *)&fmt->fmt.pix) + offset, 0,
- sizeof(fmt->fmt.pix) - offset);
}
static int v4l_querycap(const struct v4l2_ioctl_ops *ops,

Privacy Policy