From patchwork Wed Jul 1 21:56:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 11637379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18B8092A for ; Wed, 1 Jul 2020 21:56:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D77B32077D for ; Wed, 1 Jul 2020 21:56:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MAJaiimD"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kwiboo.se header.i=@kwiboo.se header.b="oaG7DDBW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D77B32077D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kwiboo.se Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:References:In-Reply-To:Message-Id:Date:Subject: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zEq+UIIbpx8pav0os6+vAtGumeQAvmfiomh+1k7ybyk=; b=MAJaiimDSrnPb8jZsjBJpjarsH A5nHT1tKMwhZT0U6c2W7kfer74S/w89DVa5Ytd2awboNS3SDUd8DBnO5ob6UAolSjzaoMwZgTl7Gj lLA2TkYVNT19r7TOdfd+u0X/ircTlmbjQ1upZ/tc5F2N/Ka7CBGWe7A/xjO8xQwnM26TMP+a9wxF7 DpZt0qxUne9wDWjR56jlIRpg44+bvtY3rbCUKy7RzHA43bQuVQ0PqT4tSnOWW8T9Vz1tD21l3REs4 qk08CkkfkOlVb2imRlv7mGL9GFIRjQaj6o0jozjYFTZUIQvx9lCfR++y4oTh4u2CxaRwHr4C1a2ZM WJGWdtMg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqkiZ-000874-LO; Wed, 01 Jul 2020 21:56:35 +0000 Received: from o1.b.az.sendgrid.net ([208.117.55.133]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqkiP-00081P-2c for linux-rockchip@lists.infradead.org; Wed, 01 Jul 2020 21:56:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:to:cc:content-type: content-transfer-encoding; s=001; bh=0xiHf/EPZS5KgOKxBp5LHqsgCsml5CTBxgkvCAuLp0U=; b=oaG7DDBWFUen/TUOc2nAiCwWpMf8GuDu15AOQELNHqPfGJvAQ+r8w/QA4l9jz4XImGrp YNvZYD0efFzRznaSuFihDOLKHCDOa/W4vbM8HUYL46WZpshFTwKTTdMAdNYNhEkPmrNuAP Dw5Cz3YDsJB7PFJWMJmHupna+ZdRtSTmQ= Received: by filterdrecv-p3iad2-5b55dcd864-9xqm9 with SMTP id filterdrecv-p3iad2-5b55dcd864-9xqm9-19-5EFD0688-4F 2020-07-01 21:56:24.670333231 +0000 UTC m=+449223.629418375 Received: from bionic.localdomain (unknown) by ismtpd0001p1lon1.sendgrid.net (SG) with ESMTP id aLw37pONTYiTg-ztRd6k0A Wed, 01 Jul 2020 21:56:24.414 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 9/9] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Date: Wed, 01 Jul 2020 21:56:24 +0000 (UTC) Message-Id: <20200701215616.30874-10-jonas@kwiboo.se> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701215616.30874-1-jonas@kwiboo.se> References: <20200701215616.30874-1-jonas@kwiboo.se> X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h+yXA2aL4Ygs2+xxaJfoz7k0HLEGmlntHCMwC87Wd0lzFUTskV+GHcHaO8naz4a40/WQZcqYNRGJahFMyagv4RYL9KGjqMOl2ElTew1KS4r7H5Gie7VVAEp9g9gsH0yg6r7sf/bTmGycP81UmEHKsc13Ko8IxhQvDtx2vAapvJ4TDNf2LVhyiA7HTJxAgXRf2A== To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200701_175625_189849_701C87CF X-CRM114-Status: GOOD ( 14.97 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [208.117.55.133 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [208.117.55.133 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Courbot , Jonas Karlman , Tomasz Figa , Hans Verkuil , Nicolas Dufresne , Ezequiel Garcia MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Add support and enable decoding of H264 High 10 and 4:2:2 profiles. H264 frmsize step_width/height is changed to 64 pixels in order to ensure proper align for 10-bit formats. Incompatible pixelformats gets rejected in s_fmt/try_fmt ioctl call. Signed-off-by: Jonas Karlman --- drivers/staging/media/rkvdec/rkvdec-h264.c | 31 ++++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 24 ++++++++--------- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index 1cb6af590138..73767e5c752f 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -1022,6 +1022,36 @@ static int rkvdec_h264_adjust_fmt(struct rkvdec_ctx *ctx, return 0; } +static int rkvdec_h264_validate_fmt(struct rkvdec_ctx *ctx, u32 pixelformat) +{ + struct v4l2_ctrl *ctrl; + const struct v4l2_ctrl_h264_sps *sps; + u32 valid_format = 0; + + ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, + V4L2_CID_MPEG_VIDEO_H264_SPS); + sps = ctrl ? ctrl->p_cur.p : NULL; + if (!sps) + return 0; + + if (sps->bit_depth_luma_minus8 == 0) { + if (sps->chroma_format_idc == 2) + valid_format = V4L2_PIX_FMT_NV16; + else + valid_format = V4L2_PIX_FMT_NV12; + } else if (sps->bit_depth_luma_minus8 == 2) { + if (sps->chroma_format_idc == 2) + valid_format = V4L2_PIX_FMT_NV20; + else + valid_format = V4L2_PIX_FMT_NV15; + } + + if (valid_format == pixelformat) + return 0; + + return -EINVAL; +} + static int rkvdec_h264_start(struct rkvdec_ctx *ctx) { struct rkvdec_dev *rkvdec = ctx->dev; @@ -1163,6 +1193,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, + .validate_fmt = rkvdec_h264_validate_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 465444c58f13..8d88fa8c4d4e 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -31,19 +31,14 @@ 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_cur.p; - /* - * 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; } return 0; @@ -97,7 +92,7 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { { .cfg.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE, .cfg.min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, - .cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, + .cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422, .cfg.menu_skip_mask = BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED), .cfg.def = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN, @@ -116,16 +111,19 @@ 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[] = { { .fourcc = V4L2_PIX_FMT_H264_SLICE, .frmsize = { - .min_width = 48, + .min_width = 64, .max_width = 4096, - .step_width = 16, - .min_height = 48, + .step_width = 64, + .min_height = 64, .max_height = 2304, .step_height = 16, },