summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel@collabora.com>2020-07-09 18:36:34 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-07-19 13:26:25 +0200
commit9363aa33f6a9acfd16f98c749f17f6c65d184670 (patch)
tree7b507ba0a6822001aab837777e491eebdb525f66 /drivers
parent46d7aaebbe441d5381e35d8e16df784690e65ef3 (diff)
downloadlinux-9363aa33f6a9acfd16f98c749f17f6c65d184670.tar.bz2
rkvdec: h264: Refuse to decode unsupported bitstream
The hardware only supports 4:2:2, 4:2:0 or 4:0:0 (monochrome), 8-bit or 10-bit depth content. Verify that the SPS refers to a supported bitstream, and refuse unsupported bitstreams by failing at TRY_EXT_CTRLS time. The driver is currently broken on 10-bit and 4:2:2 so disallow those as well. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Reviewed-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/media/rkvdec/rkvdec.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
index fd68671f0286..c8151328fb70 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -27,6 +27,32 @@
#include "rkvdec.h"
#include "rkvdec-regs.h"
+static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
+{
+ if (ctrl->id == V4L2_CID_MPEG_VIDEO_H264_SPS) {
+ const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
+ /*
+ * TODO: The hardware supports 10-bit and 4:2:2 profiles,
+ * but it's currently broken in the driver.
+ * Reject them for now, until it's fixed.
+ */
+ if (sps->chroma_format_idc > 1)
+ /* Only 4:0:0 and 4:2:0 are supported */
+ return -EINVAL;
+ if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
+ /* Luma and chroma bit depth mismatch */
+ return -EINVAL;
+ if (sps->bit_depth_luma_minus8 != 0)
+ /* Only 8-bit is supported */
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
+ .try_ctrl = rkvdec_try_ctrl,
+};
+
static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
{
.per_request = true,
@@ -42,6 +68,7 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
.per_request = true,
.mandatory = true,
.cfg.id = V4L2_CID_MPEG_VIDEO_H264_SPS,
+ .cfg.ops = &rkvdec_ctrl_ops,
},
{
.per_request = true,