[PATCH v2 2/3] media: verisilicon: reject MPEG-1 controls
From: Arun Iyengar via B4 Relay
Date: Sat Nov 21 2026 - 05:11:16 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
The driver decodes everything in MPEG-2 mode. Reject
V4L2_MPEG2_SEQ_FLAG_MPEG1, the full pel flags and D-pictures, which it
would otherwise decode as MPEG-2. Compile tested only.
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/media/platform/verisilicon/hantro_drv.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 26e5d5547466..c910a69e8e3c 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -264,6 +264,16 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl)
if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
/* Only 8-bit and 10-bit are supported */
return -EINVAL;
+ } else if (ctrl->id == V4L2_CID_STATELESS_MPEG2_SEQUENCE) {
+ if (ctrl->p_new.p_mpeg2_sequence->flags & V4L2_MPEG2_SEQ_FLAG_MPEG1)
+ return -EINVAL;
+ } else if (ctrl->id == V4L2_CID_STATELESS_MPEG2_PICTURE) {
+ const struct v4l2_ctrl_mpeg2_picture *pic = ctrl->p_new.p_mpeg2_picture;
+
+ if (pic->picture_coding_type == V4L2_MPEG2_PIC_CODING_TYPE_D ||
+ pic->flags & (V4L2_MPEG2_PIC_FLAG_FULL_PEL_FORWARD |
+ V4L2_MPEG2_PIC_FLAG_FULL_PEL_BACKWARD))
+ return -EINVAL;
} else if (ctrl->id == V4L2_CID_STATELESS_VP9_FRAME) {
const struct v4l2_ctrl_vp9_frame *dec_params = ctrl->p_new.p_vp9_frame;
@@ -435,11 +445,13 @@ static const struct hantro_ctrl controls[] = {
.codec = HANTRO_MPEG2_DECODER,
.cfg = {
.id = V4L2_CID_STATELESS_MPEG2_SEQUENCE,
+ .ops = &hantro_ctrl_ops,
},
}, {
.codec = HANTRO_MPEG2_DECODER,
.cfg = {
.id = V4L2_CID_STATELESS_MPEG2_PICTURE,
+ .ops = &hantro_ctrl_ops,
},
}, {
.codec = HANTRO_MPEG2_DECODER,
--
2.55.0