[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211224084248.3070568-7-wenst@chromium.org>
Date: Fri, 24 Dec 2021 16:42:47 +0800
From: Chen-Yu Tsai <wenst@...omium.org>
To: Ezequiel Garcia <ezequiel@...guardiasur.com.ar>,
Philipp Zabel <p.zabel@...gutronix.de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Tomasz Figa <tfiga@...omium.org>,
Chen-Yu Tsai <wenst@...omium.org>, linux-media@...r.kernel.org,
linux-rockchip@...ts.infradead.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH RFT 6/7] media: hantro: Implement V4L2_CID_JPEG_ACTIVE_MARKER control
The Hantro JPEG encoder driver adds various segments to the JPEG header.
While it would be quite complicated to make these segments selectable
to userspace, given that the driver has to fill in various fields in
these segments, and also take care of alignment, it would be nice if
the driver could signal to userspace what segments are included.
Implement the V4L2_CID_JPEG_ACTIVE_MARKER control, and make it always
return the set of segments that the driver adds.
Signed-off-by: Chen-Yu Tsai <wenst@...omium.org>
---
drivers/staging/media/hantro/hantro_drv.c | 31 +++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index 6a51f39dde56..33232479dcb7 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -280,6 +280,26 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl)
return 0;
}
+#define HANTRO_JPEG_ACTIVE_MARKERS (V4L2_JPEG_ACTIVE_MARKER_APP0 | \
+ V4L2_JPEG_ACTIVE_MARKER_COM | \
+ V4L2_JPEG_ACTIVE_MARKER_DQT | \
+ V4L2_JPEG_ACTIVE_MARKER_DHT)
+
+static int hantro_jpeg_try_ctrl(struct v4l2_ctrl *ctrl)
+{
+ switch (ctrl->id) {
+ case V4L2_CID_JPEG_COMPRESSION_QUALITY:
+ break;
+ case V4L2_CID_JPEG_ACTIVE_MARKER:
+ ctrl->val = HANTRO_JPEG_ACTIVE_MARKERS;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int hantro_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct hantro_ctx *ctx;
@@ -293,6 +313,8 @@ static int hantro_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_JPEG_COMPRESSION_QUALITY:
ctx->jpeg_quality = ctrl->val;
break;
+ case V4L2_CID_JPEG_ACTIVE_MARKER:
+ break;
default:
return -EINVAL;
}
@@ -325,6 +347,7 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = {
};
static const struct v4l2_ctrl_ops hantro_jpeg_ctrl_ops = {
+ .try_ctrl = hantro_jpeg_try_ctrl,
.s_ctrl = hantro_jpeg_s_ctrl,
};
@@ -343,6 +366,14 @@ static const struct hantro_ctrl controls[] = {
.def = 50,
.ops = &hantro_jpeg_ctrl_ops,
},
+ }, {
+ .codec = HANTRO_JPEG_ENCODER,
+ .cfg = {
+ .id = V4L2_CID_JPEG_ACTIVE_MARKER,
+ .max = HANTRO_JPEG_ACTIVE_MARKERS,
+ .def = HANTRO_JPEG_ACTIVE_MARKERS,
+ .ops = &hantro_jpeg_ctrl_ops,
+ },
}, {
.codec = HANTRO_MPEG2_DECODER,
.cfg = {
--
2.34.1.448.ga2b2bfdf31-goog
Powered by blists - more mailing lists