From patchwork Sun Sep 12 08:20:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12486779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE479C433F5 for ; Sun, 12 Sep 2021 08:23:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A07B060D42 for ; Sun, 12 Sep 2021 08:23:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A07B060D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AyQvFQt6rbFIohPzmVcaLCKc0CGelVpQlMo+7lC5MsM=; b=XivBgbhkzsSBk0 JgRHeY3B/RqAlO71d0+l8TZMKGA4A+Q7sXgD3YH/oQmqRp82/54jhnJZH4pzBJTgnYr/o1od+Qw3P 4zP4QmGa4SKdaL335z0AtefaNadTzorHvxSAF/gW9OjRzMSBocQr1yuQxmvm5oCI2eBxWMCfu/PCP b5t0yF+DOqgxnjwlGEzZdOfSo3jks3odA4GWmgBzEg8y7903786Sn9aCosczD6MCHsumEOaxA3XyQ UnZLq2qWSbSG4XYTvCQZvXZgjPTYH5yL6BgCz2xtLHkFHLravQz37MejRB7nbtPS9v82plvOKhXtG S4MyDwo7Xcybz5Ekrdvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPKjm-00G5ey-RP; Sun, 12 Sep 2021 08:21:19 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPKjY-00G5b3-LX for linux-arm-kernel@lists.infradead.org; Sun, 12 Sep 2021 08:21:06 +0000 Received: by mail-wm1-x332.google.com with SMTP id v20-20020a1cf714000000b002e71f4d2026so3357249wmh.1 for ; Sun, 12 Sep 2021 01:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WPj6LXbNCWGMgslr5J8S2na/ssf54cOsK6CaQGpLv5A=; b=fsg98pch/a14OEbNJXu9VqTjbbnBK2TPC6ZWLIpx/D+a5L8V/SMariJ4nvg6bJRFmI bPZPLVn/EKRmFr/LnOdSE5m5t/Tcpz8Mqs43dfw9g5nkSlHVrjW3gAWeNIAwsMzcrKUL NbsHDjcfE+KxOFdT5pMInpF+dZkgDGfkueRfvv50JYEU3xvW+A5mUw4hVfHLj0pVywT3 mOK6w/izbeiLC+H0nRQWogvTMnYBZPd44ByPvywrVFm0sEhfEFKOorpCy6gEMC5WAkbZ 2kAVaW/NrDoXUXtw8nk6kDHzIN/9IoFiWJSCpH5745gU3ORVi2xetU4hwSkyJTNO2H/5 eq4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WPj6LXbNCWGMgslr5J8S2na/ssf54cOsK6CaQGpLv5A=; b=UIedNYp9R7KH5amNszNmm8EWKJF+yVSO0rslyngYlPd+DbHMpVuUJTfGfRRVcuKhyG lLpTdTgCWx8V6Q7dfpRJkQQCWKBuhjHpTvALrEC846hw5sBku/l5vkqTvO/eLyfD6jFy oft3BrPf68mmBJcXKydbI7CHPhuZPnAIoGoBpKDzRTqUcXZNzErBepfJU6le1MQ8AWEz 3yK+FjtBYR9qiaBr4DrbAF5UlZ/lMWPqlm/IBSmbkZpYZ4YQhwnWMew2CUlLifoPGlIK nlKnaW/difzDrJv3ywwnpXOMY3UvPGQNOWcF2/KkOJUASSqPlTXTHCToiaeZ/rczNO4F SP7Q== X-Gm-Message-State: AOAM532Xz/ZyjuE1hF5O7fR1HV3k9Gzup7+ZELuQQ3yFhUvuXrfUmQli IqKydGtIKQn2FA/DLoxaiBI= X-Google-Smtp-Source: ABdhPJzTvuyKRgnTBkT2kkQi1LutRMAbSxrCCgfp9wfzImXxciiR95cPN4bNxbk6/01FqTsUApZ3QA== X-Received: by 2002:a1c:2313:: with SMTP id j19mr5665683wmj.189.1631434863602; Sun, 12 Sep 2021 01:21:03 -0700 (PDT) Received: from kista.localdomain (cpe-86-58-29-253.static.triera.net. [86.58.29.253]) by smtp.gmail.com with ESMTPSA id z7sm4734148wre.72.2021.09.12.01.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Sep 2021 01:21:03 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: wens@csie.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, gregkh@linuxfoundation.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 1/2] media: cedrus: Add H265 10-bit capability flag Date: Sun, 12 Sep 2021 10:20:50 +0200 Message-Id: <20210912082051.404645-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210912082051.404645-1-jernej.skrabec@gmail.com> References: <20210912082051.404645-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210912_012104_743311_64FA6981 X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently only H6 variant supports decoding 10-bit H265 videos. Add a capability flag, so driver could determine if 10-bit H265 slices should be allowed or not. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 1 + drivers/staging/media/sunxi/cedrus/cedrus.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 144286920749..e7741178465b 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -556,6 +556,7 @@ static const struct cedrus_variant sun50i_h6_cedrus_variant = { CEDRUS_CAPABILITY_MPEG2_DEC | CEDRUS_CAPABILITY_H264_DEC | CEDRUS_CAPABILITY_H265_DEC | + CEDRUS_CAPABILITY_H265_10_DEC | CEDRUS_CAPABILITY_VP8_DEC, .mod_rate = 600000000, }; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 9c7bfd2b6616..c345f2984041 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -32,6 +32,7 @@ #define CEDRUS_CAPABILITY_H264_DEC BIT(2) #define CEDRUS_CAPABILITY_MPEG2_DEC BIT(3) #define CEDRUS_CAPABILITY_VP8_DEC BIT(4) +#define CEDRUS_CAPABILITY_H265_10_DEC BIT(5) enum cedrus_codec { CEDRUS_CODEC_MPEG2, From patchwork Sun Sep 12 08:20:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12486781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08EC9C433EF for ; Sun, 12 Sep 2021 08:23:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C3F1160D42 for ; Sun, 12 Sep 2021 08:23:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C3F1160D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oOTzpMTQjhUGbzhPNVlcsMa56bBYohf1dVprj/BKXbY=; b=J9sHnBMoJbbr9k nSsY07BEOX90XdLf3+6HOEms8PAVKYvj6R/pCe1eft/idsBkQNEGJ3mHUAVCCZIdSlpmvamL+va3e AYrShXpg1t2FmV01yJolrNnCZjDTYu+m6YRv7b6K+ZQlC/XpGm1V6+h+CKdv8aX43eNnxfxq2hCfX EJvXVlDF6N4HGB/wQQgTUNI2guqATKAqbalDyvJc0gTtfj2PK1gNXzgAkkTV4hW/O6T3v1m6vo3Zi uzhM+LKN4CxAanQIEtnncxpf3GisbB3tb8VR5kg6eccnfTEsREW3m6jhK3jm0w3cMJaGlSIKXRgnB mS7vhkVIUxb9JMgBO8oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPKjy-00G5fi-MB; Sun, 12 Sep 2021 08:21:30 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPKjc-00G5bi-H0 for linux-arm-kernel@lists.infradead.org; Sun, 12 Sep 2021 08:21:10 +0000 Received: by mail-wr1-x430.google.com with SMTP id q26so9511862wrc.7 for ; Sun, 12 Sep 2021 01:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=loVuR5rf8xXZUXrkvmuZ4jdfaeutXsglZCQg6SpqqWI=; b=mz9rcT5C8Hmf5wIRx6BVghFw/iPtNymfvfF8cuTcwBpj3tVtFNUDyVqKD9m/hwVuja 3oAvSb7+QD/evuBHr8Ge9l0bHp6YhNR5ijLNRdBnZH9ubgoCtegSHThuZGr3Naml2G/U W4YxkMnq5xXcIl5MkbWBAFtwdeVgbAl9fHQ49aJZpXXC9l2Ak8oXuHuFx1hnFGI06Oa3 QQFCQY32NwzQQVDyh4iAJF43lBrDw0Zhr6PysXZk2hkbX2C0/Zy7fukuJ+kVdJH9evC7 NAJy4Q8w5Jwri1ZgA23SAcCuPq+NeBWHegfSMHCTApZ/Ls1t2EoVpYrEiAKf3szTCznS F3MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=loVuR5rf8xXZUXrkvmuZ4jdfaeutXsglZCQg6SpqqWI=; b=DbnCXbclUPZpfRmzYwP13X1mFE9HqrDjp+JaUhLUH9gY7oEVgWrrg6w2MhPvJXinZH JWbgm25OjwAHvu54cj5hHaQTBiFF8erjVyW4L+o64YZdkwtBtI9iO1Kdm5Qz6U293q4/ qrw1zW8pgECUFM4LXE3/f44AQV5CmOW+snQwufnWcvmy3rsYoAskng0ou4pYwIxZCloO a4R9Iqjm5oWna1fgijMBXoclprn+A4RFT3e6ygJszYHVGFLVa94N5Sn79EzxcDvAmYhK wRXdWliYtCRlxT/Al0zzWsToowf6HYAnz/HdFEpfRolYINaFonboEkwlg4teG/vFDw4L dKYg== X-Gm-Message-State: AOAM531qGA7ocSSEzN6vb1dHLAR9j/Q5LCPlhdu/rK+CZ+8NHUjiXdjw AOwlkSXkItBfDpxKw+LKHzDxY/bXB6h3Rw== X-Google-Smtp-Source: ABdhPJymmVlbyu3mVI7xzQefhW6DAWK5wy+DMJxGBpj1f82ZRDyXtzqEeAd+gIeNepxhQTShqR7x+Q== X-Received: by 2002:a5d:63c5:: with SMTP id c5mr6563829wrw.135.1631434864600; Sun, 12 Sep 2021 01:21:04 -0700 (PDT) Received: from kista.localdomain (cpe-86-58-29-253.static.triera.net. [86.58.29.253]) by smtp.gmail.com with ESMTPSA id z7sm4734148wre.72.2021.09.12.01.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Sep 2021 01:21:04 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: wens@csie.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, gregkh@linuxfoundation.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 2/2] media: cedrus: add check for H264 and H265 limitations Date: Sun, 12 Sep 2021 10:20:51 +0200 Message-Id: <20210912082051.404645-3-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210912082051.404645-1-jernej.skrabec@gmail.com> References: <20210912082051.404645-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210912_012108_593976_2FD88882 X-CRM114-Status: GOOD ( 16.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Cedrus supports only YUV420 H264/H265 content and mostly only 8-bit colours (except on H6, where 10-bit are also supported). Add validation callback to SPS controls, which will reject unsupported combinations. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 46 +++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index e7741178465b..9dd30cb568e8 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -28,6 +28,50 @@ #include "cedrus_dec.h" #include "cedrus_hw.h" +static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl) +{ + if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) { + const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; + + if (sps->chroma_format_idc != 1) + /* Only 4:2:0 is 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; + } else if (ctrl->id == V4L2_CID_MPEG_VIDEO_HEVC_SPS) { + const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; + struct cedrus_ctx *ctx = container_of(ctrl->handler, struct cedrus_ctx, hdl); + + if (sps->chroma_format_idc != 1) + /* Only 4:2:0 is supported */ + return -EINVAL; + + if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) + /* Luma and chroma bit depth mismatch */ + return -EINVAL; + + if (ctx->dev->capabilities & CEDRUS_CAPABILITY_H265_10_DEC) { + 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 (sps->bit_depth_luma_minus8 != 0) + /* Only 8-bit is supported */ + return -EINVAL; + } + } + + return 0; +} + +static const struct v4l2_ctrl_ops cedrus_ctrl_ops = { + .try_ctrl = cedrus_try_ctrl, +}; + static const struct cedrus_control cedrus_controls[] = { { .cfg = { @@ -62,6 +106,7 @@ static const struct cedrus_control cedrus_controls[] = { { .cfg = { .id = V4L2_CID_STATELESS_H264_SPS, + .ops = &cedrus_ctrl_ops, }, .codec = CEDRUS_CODEC_H264, }, @@ -120,6 +165,7 @@ static const struct cedrus_control cedrus_controls[] = { { .cfg = { .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS, + .ops = &cedrus_ctrl_ops, }, .codec = CEDRUS_CODEC_H265, },