All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonas Karlman <jonas@kwiboo.se>
To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: Jonas Karlman <jonas@kwiboo.se>,
	Ezequiel Garcia <ezequiel@collabora.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Nicolas Dufresne <nicolas.dufresne@collabora.com>,
	Tomasz Figa <tfiga@chromium.org>,
	Alexandre Courbot <acourbot@chromium.org>
Subject: [PATCH v2 11/12] media: rkvdec: h264: Support High 10 and 4:2:2 profiles
Date: Mon, 06 Jul 2020 21:54:37 +0000 (UTC)	[thread overview]
Message-ID: <20200706215430.22859-12-jonas@kwiboo.se> (raw)
In-Reply-To: <20200706215430.22859-1-jonas@kwiboo.se>

Add support and enable decoding of H264 High 10 and 4:2:2 profiles.

Decoded CAPTURE buffer width is aligned to 64 pixels to accommodate HW
requirement on 10-bit format buffers.

The new valid_fmt operation is implemented and return a valid pixelformat
for the provided SPS control.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
Changes in v2:
- Only align decoded buffer instead of using frmsize step_width
---
 drivers/staging/media/rkvdec/rkvdec-h264.c | 20 ++++++++++++++++++++
 drivers/staging/media/rkvdec/rkvdec.c      | 19 +++++++++----------
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c
index 10756b9d6118..0757fc97d1ff 100644
--- a/drivers/staging/media/rkvdec/rkvdec-h264.c
+++ b/drivers/staging/media/rkvdec/rkvdec-h264.c
@@ -1018,6 +1018,25 @@ static int rkvdec_h264_adjust_fmt(struct rkvdec_ctx *ctx,
 	return 0;
 }
 
+static u32 rkvdec_h264_valid_fmt(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl)
+{
+	const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p;
+
+	if (sps->bit_depth_luma_minus8 == 0) {
+		if (sps->chroma_format_idc == 2)
+			return V4L2_PIX_FMT_NV16;
+		else
+			return V4L2_PIX_FMT_NV12;
+	} else if (sps->bit_depth_luma_minus8 == 2) {
+		if (sps->chroma_format_idc == 2)
+			return V4L2_PIX_FMT_NV20;
+		else
+			return V4L2_PIX_FMT_NV15;
+	}
+
+	return 0;
+}
+
 static int rkvdec_h264_start(struct rkvdec_ctx *ctx)
 {
 	struct rkvdec_dev *rkvdec = ctx->dev;
@@ -1125,6 +1144,7 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx)
 
 const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = {
 	.adjust_fmt = rkvdec_h264_adjust_fmt,
+	.valid_fmt = rkvdec_h264_valid_fmt,
 	.start = rkvdec_h264_start,
 	.stop = rkvdec_h264_stop,
 	.run = rkvdec_h264_run,
diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
index 11a88cb6407d..4faee9262392 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -31,7 +31,7 @@ static void rkvdec_fill_decoded_pixfmt(struct rkvdec_ctx *ctx,
 				       struct v4l2_pix_format_mplane *pix_mp)
 {
 	v4l2_fill_pixfmt_mp(pix_mp, pix_mp->pixelformat,
-			    pix_mp->width, pix_mp->height);
+			    ALIGN(pix_mp->width, 64), pix_mp->height);
 	pix_mp->plane_fmt[0].sizeimage += 128 *
 		DIV_ROUND_UP(pix_mp->width, 16) *
 		DIV_ROUND_UP(pix_mp->height, 16);
@@ -55,19 +55,15 @@ 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;
 		unsigned int width, height;
-		/*
-		 * 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 */
+
+		if (sps->chroma_format_idc > 2)
+			/* Only 4:0:0, 4:2:0 and 4:2:2 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 */
+		if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
+			/* Only 8-bit and 10-bit is supported */
 			return -EINVAL;
 
 		if (ctx->valid_fmt && ctx->valid_fmt != rkvdec_valid_fmt(ctx, ctrl))
@@ -157,6 +153,9 @@ static const struct rkvdec_ctrls rkvdec_h264_ctrls = {
 
 static const u32 rkvdec_h264_decoded_fmts[] = {
 	V4L2_PIX_FMT_NV12,
+	V4L2_PIX_FMT_NV15,
+	V4L2_PIX_FMT_NV16,
+	V4L2_PIX_FMT_NV20,
 };
 
 static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
-- 
2.17.1


  parent reply	other threads:[~2020-07-06 21:54 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01 21:56 [PATCH 0/9] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Jonas Karlman
2020-07-01 21:56 ` [PATCH 1/9] media: rkvdec: h264: Support profile and level controls Jonas Karlman
2020-07-03  2:54   ` Ezequiel Garcia
2020-07-03  5:30     ` Jonas Karlman
2020-07-01 21:56 ` [PATCH 3/9] media: rkvdec: h264: Fix pic width and height in mbs Jonas Karlman
2020-07-03  2:48   ` Ezequiel Garcia
2020-07-03 11:28     ` Jonas Karlman
2020-07-01 21:56 ` [PATCH 2/9] media: rkvdec: h264: Fix reference frame_num wrap for second field Jonas Karlman
2020-07-03  2:55   ` Ezequiel Garcia
2020-07-03  3:01   ` Ezequiel Garcia
2020-07-01 21:56 ` [PATCH 5/9] media: v4l2-common: Add helpers to calculate bytesperline and sizeimage Jonas Karlman
2020-07-01 21:56 ` [PATCH 4/9] media: rkvdec: h264: Fix bit depth wrap in pps packet Jonas Karlman
2020-07-03  2:58   ` Ezequiel Garcia
2020-07-01 21:56 ` [PATCH 6/9] media: v4l2: Add NV15 and NV20 pixel formats Jonas Karlman
2020-07-01 21:56 ` [PATCH 7/9] media: rkvdec: h264: Use bytesperline and buffer height to calculate stride Jonas Karlman
2020-07-03  3:21   ` Ezequiel Garcia
2020-07-03 11:40     ` Jonas Karlman
2020-07-01 21:56 ` [PATCH 8/9] media: rkvdec: Add validate_fmt ops for pixelformat validation Jonas Karlman
2020-07-03  3:14   ` Ezequiel Garcia
2020-07-03  6:55     ` Jonas Karlman
2020-07-03 14:58       ` Ezequiel Garcia
2020-07-03 19:17         ` Jonas Karlman
2020-07-03 19:33           ` Ezequiel Garcia
2020-07-03 19:34           ` Tomasz Figa
2020-07-01 21:56 ` [PATCH 9/9] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Jonas Karlman
2020-07-06 21:54 ` [PATCH v2 00/12] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 01/12] media: rkvdec: h264: Fix reference frame_num wrap for second field Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 03/12] media: rkvdec: h264: Validate and use pic width and height in mbs Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 02/12] media: rkvdec: Ensure decoded resolution fit coded resolution Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 06/12] media: v4l2-common: Add helpers to calculate bytesperline and sizeimage Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 05/12] media: rkvdec: h264: Do not override output buffer sizeimage Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 04/12] media: rkvdec: h264: Fix bit depth wrap in pps packet Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 08/12] media: rkvdec: h264: Use bytesperline and buffer height to calculate stride Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 07/12] media: v4l2: Add NV15 and NV20 pixel formats Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 10/12] media: rkvdec: Lock capture pixel format in s_ctrl and s_fmt Jonas Karlman
2020-07-08  3:16     ` Ezequiel Garcia
2020-07-08 12:42       ` Jonas Karlman
2020-07-06 21:54   ` Jonas Karlman [this message]
2020-07-06 21:54   ` [PATCH v2 09/12] media: rkvdec: Extract rkvdec_fill_decoded_pixfmt helper method Jonas Karlman
2020-07-06 21:54   ` [PATCH v2 12/12] media: rkvdec: h264: Support profile and level controls Jonas Karlman
2020-07-08  3:19     ` Ezequiel Garcia
2020-07-08  9:34       ` Jonas Karlman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200706215430.22859-12-jonas@kwiboo.se \
    --to=jonas@kwiboo.se \
    --cc=acourbot@chromium.org \
    --cc=ezequiel@collabora.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.