From patchwork Wed Nov 2 18:08:00 2022 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: 13028758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C39CFC4332F for ; Wed, 2 Nov 2022 18:12:20 +0000 (UTC) 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=iOZTXHiTHzvryEOBNWlqKxWMgXp4buj6k0Llalbqm0g=; b=3/hZwGWYhhekpi 5xHfANFlsETB6Jh/mkyYRE/PDhOWpoZ8/jIXe1PJyiKnm8kq8DFGNf64AM9MklGmjzhR6xJcvj3yr i0E077yl9I5dOsqBDOkT5nFVjVdrmpXMRKe+QuM+3w3RDXugAsZ75A9IUbe0j61eEwEnx0QasRd+W tQv87bf1atk0Bh04jMfqvNjdyT9rpCtZFH7iAawZLGNthpwJBuW7TEJESHH0+ugdBZ7B06WhKMg1a 0wbgqG9PqWvBJt7MjXvbok9LCNSiNHvddw3dV2aEstN5kzSFlKGN/zbRQ8xWi9H8jxp6XGysLv/A7 BP2eqxe+v0LQ+pje3SHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqICl-00CqgR-03; Wed, 02 Nov 2022 18:11:11 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA0-00Coe6-Va for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:24 +0000 Received: by mail-ej1-x635.google.com with SMTP id ud5so47512290ejc.4 for ; Wed, 02 Nov 2022 11:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3bJiWx1wliVbcBA4hLVtU2HKADrW2hjL3FgeqkhgWtw=; b=MuOr6WgUNRTbGp0fKCLMkl/k7dGETn0MCPk6OvhPg3lmMvlQgmcuBFQ+ABDIQVEfIR wFZp5SWC4EFvbN0KmunKKO77/O/BC7U/qywpY2f1LZBtchRftfHVF3XlxDQXgmGoQ3Cu HRfmoLIhb4dl4QLwwj8v/orGggqh47FggbluTDhATnJPTKIyLEFUq6U5YhVS+2MCTQVG Gk2wEwdsPhpcbyRz3cEpnHhdYsYto1gGKo/qcRpNS7dSxQpynS9SIQ1g/wDHuap9qgst EArzOONtTazMJBiM1MR40HcTRdRrPXfFh+vXs2vu6s+5u1L8ble5iN+quusR0rM+WQoX JcKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3bJiWx1wliVbcBA4hLVtU2HKADrW2hjL3FgeqkhgWtw=; b=YXLHJN4CrSmfQrBVQ3dV13NMGdLWZXSGwj+ZYeWIBNmjCljThI/Me1mzZiWg/t9NGc khKgA3nDb0f7/QkNZI0IYyuFdKwbOOJ7/RhT3tyiSzwX2Qei1o0c/9C7IkAnnCIS469f 1hxCFGK8dndUzAYochmdB8f8pOQYXaBHgR+RYqd6+rQQAkPw/V028rn74oUSUifeaupi RbsS45wtSd8TKZVJwq4VoXFgOlnFpa7Akx9pWiVrwDH+glAjUvsrIeDzyswzq+ReeTie gKWWxHEfb2QmBdydHan8088FaJ5wr7qGWvJnIf7dCU4sN2XE5xgOt/SAvgMA0cWHgN52 x4vQ== X-Gm-Message-State: ACrzQf3enRqAU/u938MVBnt9biiYmgttM1pncrH3xk8N37Uc7CB0nUjp s/VN9NlHDXMftWbCK+SHQLE= X-Google-Smtp-Source: AMsMyM4280G5nDkbI8u023cMcU5BlS9r2WOVAAA+6//bk1OD+H9jRtahZ1KPvN75QhuxsNTEmyAj5Q== X-Received: by 2002:a17:907:b15:b0:7a7:19a3:e9e7 with SMTP id h21-20020a1709070b1500b007a719a3e9e7mr24606410ejl.361.1667412498590; Wed, 02 Nov 2022 11:08:18 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:18 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 01/11] media: cedrus: remove superfluous call Date: Wed, 2 Nov 2022 19:08:00 +0100 Message-Id: <20221102180810.267252-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110821_061351_1EC494F7 X-CRM114-Status: GOOD ( 11.16 ) 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_try_fmt_vid_out() is called two times inside cedrus_s_fmt_vid_out(), but nothing changes between calls which would influence output format. Remove first call, which was added later. Acked-by: Paul Kocialkowski Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 33726175d980..1c3c1d080d31 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -309,10 +309,6 @@ static int cedrus_s_fmt_vid_out(struct file *file, void *priv, struct vb2_queue *peer_vq; int ret; - ret = cedrus_try_fmt_vid_out(file, priv, f); - if (ret) - return ret; - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); /* * In order to support dynamic resolution change, From patchwork Wed Nov 2 18:08:01 2022 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: 13028761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 67DFBC4332F for ; Wed, 2 Nov 2022 18:14:35 +0000 (UTC) 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=Aa4T5bMd8SptgeooOJXMhJazvtbzNP0mf+Vem2TQULQ=; b=VMQFS/7Ls3xYZs GREkbd/D/+J77DMbqDLtoUN24ydvlDquz6WsWSkWc6vOXdiE7EUXXRF7ZN/3zxdiS6ptwSgc86bDQ swh7/bpRn7nVU6YUH5OcsEdBz7hdNFX2r4o9AXHwp7WwsXfdhRf46jhu2ndJt3+DEdXQu6EAU7h/j Z9R50+tR5nocLQ7ReHBn0avZL7eo/2jrESUcA9LsueBLfYjF8YUP+sXHUSXQYKq63w1/tK1mYxptV ndXL7eSlCcGKctl/h7dgDeeagYZtStZX8Uko7TIFqcNWJTCRjGI8TopRjjck2Rc+ftIHly9igiABM hGm11eR4YJcqJQLEBJiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIEu-00CryT-8q; Wed, 02 Nov 2022 18:13:25 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA1-00Coen-Om for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:24 +0000 Received: by mail-ed1-x531.google.com with SMTP id a5so27693796edb.11 for ; Wed, 02 Nov 2022 11:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4uzd84Lo8isAFXRphDOp8YM5rfTGeiE2OqupA7quo4Y=; b=V2JHHP2kl5m1wWWBT62YhSuax2oWvTafyIGpWoP3EO6VF+iu7LAFuxpM9O6WMAqfS9 +L7V7E4CnsEbUwec0aUbvxG2i+vPMC2bSiKtuD29FL7bBkO3sWX3uw+9NufO+iPGyA9Q 9XYOOZrqQly9P29PviUHrQd7lPxp+riDh3E9ZrqQJEuNc4H5FyrBsrV/DlXF7qBILi/k vyYY/8ymtmDCB4N/yOSNBZIerOvgMDMdLVF1nF+J0pwYF2emdzw8pZHLahkrNC4GMU5s kwbTimZdZUahGB3wWqZfGgQawKTCUNAN+7SIs3ALYQK++O33EwUuEGSwJ+GiEdJcXaWf p5vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4uzd84Lo8isAFXRphDOp8YM5rfTGeiE2OqupA7quo4Y=; b=PQqgrq4ZtO8tOlokjMrxWsfHvphZQ7d3YhwtxWrO51AvLYsA8cmk8PIyc7T2G9QokU JaZ1kD+DnB+ZyaP1xB/w4aTx2ynFZspw6OARsLu2xNvKnLQn5W6+Al5bwQ2ry+vQRMJg hhWFXREacpIAQmuIyObfrND3lDjbEFCKLf6nW+4l+vqiTIr5q42ZV8ybp8bDw2SD1eGe QfGCqMCSM2jXqmzxjU+qPrC30zWr9YejCZqvWsqK6HRK+/HrPnD2vl3P7oXPVKxu6BdU TFLxMmDoqcLDDf+gshEmaWbpoZA0aXqteFqS6r1DYYdmrVavLflspPK94dsvFYu++Oz6 CnLg== X-Gm-Message-State: ACrzQf1sPlbrDjmuXRnRo0Q1yKdCSz+Wet/m9px1amIielcKITuwvYFH XqMgKyAXYRi3M98XfeeCz+Y= X-Google-Smtp-Source: AMsMyM4nMdw9qFudS0MppwKqqPi9ceglgVyAgRyXA2zxjW0S8nVIvq/jDJPeHBSWYaGDV6Ycc0GpIg== X-Received: by 2002:a05:6402:2550:b0:462:38d7:a6e1 with SMTP id l16-20020a056402255000b0046238d7a6e1mr26463164edb.337.1667412499831; Wed, 02 Nov 2022 11:08:19 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:19 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 02/11] media: cedrus: Add format reset helpers Date: Wed, 2 Nov 2022 19:08:01 +0100 Message-Id: <20221102180810.267252-3-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110821_857755_01195424 X-CRM114-Status: GOOD ( 16.87 ) 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 By re-arranging try format handlers and set out format handler, we can easily implement reset out/cap format helpers. There is only one subtle, but important functional change. Capture pixel format will be reset each time output format is set. This is actually expected behaviour per stateless decoder API. Signed-off-by: Jernej Skrabec --- .../staging/media/sunxi/cedrus/cedrus_video.c | 100 +++++++++++------- .../staging/media/sunxi/cedrus/cedrus_video.h | 2 + 2 files changed, 66 insertions(+), 36 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 1c3c1d080d31..27a7120fa6fb 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -241,12 +241,10 @@ static int cedrus_g_fmt_vid_out(struct file *file, void *priv, return 0; } -static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) +static int cedrus_try_fmt_vid_cap_p(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) { - struct cedrus_ctx *ctx = cedrus_file2ctx(file); struct cedrus_dev *dev = ctx->dev; - struct v4l2_pix_format *pix_fmt = &f->fmt.pix; struct cedrus_format *fmt = cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_DST, dev->capabilities); @@ -262,12 +260,16 @@ static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int cedrus_try_fmt_vid_out(struct file *file, void *priv, +static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { - struct cedrus_ctx *ctx = cedrus_file2ctx(file); + return cedrus_try_fmt_vid_cap_p(cedrus_file2ctx(file), &f->fmt.pix); +} + +static int cedrus_try_fmt_vid_out_p(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) +{ struct cedrus_dev *dev = ctx->dev; - struct v4l2_pix_format *pix_fmt = &f->fmt.pix; struct cedrus_format *fmt = cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_SRC, dev->capabilities); @@ -281,6 +283,12 @@ static int cedrus_try_fmt_vid_out(struct file *file, void *priv, return 0; } +static int cedrus_try_fmt_vid_out(struct file *file, void *priv, + struct v4l2_format *f) +{ + return cedrus_try_fmt_vid_out_p(cedrus_file2ctx(file), &f->fmt.pix); +} + static int cedrus_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { @@ -301,13 +309,60 @@ static int cedrus_s_fmt_vid_cap(struct file *file, void *priv, return 0; } +void cedrus_reset_cap_format(struct cedrus_ctx *ctx) +{ + ctx->dst_fmt.pixelformat = 0; + cedrus_try_fmt_vid_cap_p(ctx, &ctx->dst_fmt); +} + +static int cedrus_s_fmt_vid_out_p(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) +{ + struct vb2_queue *vq; + int ret; + + ret = cedrus_try_fmt_vid_out_p(ctx, pix_fmt); + if (ret) + return ret; + + ctx->src_fmt = *pix_fmt; + + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + + switch (ctx->src_fmt.pixelformat) { + case V4L2_PIX_FMT_H264_SLICE: + case V4L2_PIX_FMT_HEVC_SLICE: + vq->subsystem_flags |= + VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; + break; + default: + vq->subsystem_flags &= + ~VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; + break; + } + + /* Propagate format information to capture. */ + ctx->dst_fmt.colorspace = pix_fmt->colorspace; + ctx->dst_fmt.xfer_func = pix_fmt->xfer_func; + ctx->dst_fmt.ycbcr_enc = pix_fmt->ycbcr_enc; + ctx->dst_fmt.quantization = pix_fmt->quantization; + cedrus_reset_cap_format(ctx); + + return 0; +} + +void cedrus_reset_out_format(struct cedrus_ctx *ctx) +{ + ctx->src_fmt.pixelformat = 0; + cedrus_s_fmt_vid_out_p(ctx, &ctx->src_fmt); +} + static int cedrus_s_fmt_vid_out(struct file *file, void *priv, struct v4l2_format *f) { struct cedrus_ctx *ctx = cedrus_file2ctx(file); struct vb2_queue *vq; struct vb2_queue *peer_vq; - int ret; vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); /* @@ -328,34 +383,7 @@ static int cedrus_s_fmt_vid_out(struct file *file, void *priv, if (vb2_is_busy(peer_vq)) return -EBUSY; - ret = cedrus_try_fmt_vid_out(file, priv, f); - if (ret) - return ret; - - ctx->src_fmt = f->fmt.pix; - - switch (ctx->src_fmt.pixelformat) { - case V4L2_PIX_FMT_H264_SLICE: - case V4L2_PIX_FMT_HEVC_SLICE: - vq->subsystem_flags |= - VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; - break; - default: - vq->subsystem_flags &= - ~VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; - break; - } - - /* Propagate format information to capture. */ - ctx->dst_fmt.colorspace = f->fmt.pix.colorspace; - ctx->dst_fmt.xfer_func = f->fmt.pix.xfer_func; - ctx->dst_fmt.ycbcr_enc = f->fmt.pix.ycbcr_enc; - ctx->dst_fmt.quantization = f->fmt.pix.quantization; - ctx->dst_fmt.width = ctx->src_fmt.width; - ctx->dst_fmt.height = ctx->src_fmt.height; - cedrus_prepare_format(&ctx->dst_fmt); - - return 0; + return cedrus_s_fmt_vid_out_p(cedrus_file2ctx(file), &f->fmt.pix); } const struct v4l2_ioctl_ops cedrus_ioctl_ops = { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.h b/drivers/staging/media/sunxi/cedrus/cedrus_video.h index 05050c0a0921..8e1afc16a6a1 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.h @@ -27,5 +27,7 @@ extern const struct v4l2_ioctl_ops cedrus_ioctl_ops; int cedrus_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq); void cedrus_prepare_format(struct v4l2_pix_format *pix_fmt); +void cedrus_reset_cap_format(struct cedrus_ctx *ctx); +void cedrus_reset_out_format(struct cedrus_ctx *ctx); #endif From patchwork Wed Nov 2 18:08:02 2022 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: 13028760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3CF9DC433FE for ; Wed, 2 Nov 2022 18:13:45 +0000 (UTC) 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=S4VrykSu1I3OaNAdkkovNQYViw5Cy7tBmnzOQR7pN7g=; b=vqC+25T0fhSB/7 rrQMQROGqMH+tifcJ99z5VTzbDAXcUh/+7ba5gUqnpBRsoxY1gjfhs/wddkgSwHTviEBZwvxess9y WNN0lE8y2hwhQXZBvdeFVlRZCdtZhJLMwssJJxdKSHWw2iiOnK8DH9+ExTV9vWXDt8+HdIMISbLUV weBZiUaq6r9GyMR7XLFWIIDkrp1GtvtQW7xXP5lsaDgQ2ihzX6O+35yNAEesuwEIXicUjTzCgV/5m AYoQqh17SSAzgzFjAOE26AlAGXwTheO6njacV98XzyvpJUkGFosIpX1BDUyB+JgQsrDYQ0V+geb5m a5+x8K4iicE6qHM8U7OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIE8-00CrXL-5O; Wed, 02 Nov 2022 18:12:36 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA2-00Cofe-8N for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:24 +0000 Received: by mail-ej1-x635.google.com with SMTP id y14so47489703ejd.9 for ; Wed, 02 Nov 2022 11:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fz8kU4WpE9TC4fsj366svqLLQU9rq3YiiGANcwE6/pc=; b=Lu9iDaPkeibob9D2zukTHvmKRrirbpzfH6LT1C6M0zP/qXy54iExH7mDioyv4Ul7Sx 6QRjy8MQZ+j2abjXnhQcIEmsc23UDoysXuAY+MJJJJmoiscmNOBXQnCnCTXXSDYhJpFq KVnNSlVUijf+ZlFCsEdQM7lLeAvW65pZxBILlTiJEdAjG8mD0eRAPjZ/58nR5X4cNBdD us1xsek5nl1pl3IyD31KHZjNAnw5Wv0LMiwobX/uFy7PomCQFtN5B2oShrzht1oLfiJ+ dJ3F3lwCKO4xoYlQ+3DWdfona/UynPlWzKQ/mrii70uT9qIIvujTdVdA+xd2twOp5Duh FDcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fz8kU4WpE9TC4fsj366svqLLQU9rq3YiiGANcwE6/pc=; b=tChDjKXWTH6iWWH0HwR/Sk0VCnRRU3nut7AEnmPlzkRq591UWjqakN4ONjsA4fWUmN K7BxyMsXC5/JS6rXXCHzmAZRHMAeSRhqUCORsTYW9BV74I5uedvqYdDd8jJ46uotuT7y +EoeXsqK5cL1Ucx9qwbyJXcQx/adfk5rey0QR3Ab/vLuElcGiRQ69WV7wHpy45QuUEFE JtFWITRov0bw1RX+DTK+0nnrNL/AmkCaPUS7rZcuam8MMwgPNmby/YDXVIjo8x4/Tjhy YkTiSYEUcojonaKt2JxMSnwkcYLZ+IFjg3HU4MO+r2uKCES8I4r04DWrgvTHqUyAKtSx z30g== X-Gm-Message-State: ACrzQf2rgOUbgCU4PmXID+pny59Aiqwm7pzdBnYbiksXPtBk9/UZWkKk 39iAKMvvj5623fqwqnMPssk= X-Google-Smtp-Source: AMsMyM4iFCLAEnI0uHlhwGw0+az0UFMMmCWDTBTRtbk0uQWbXxdgPdZEkcZEWF+GLLv8aO6NBF5ChQ== X-Received: by 2002:a17:906:401:b0:73d:af73:b78 with SMTP id d1-20020a170906040100b0073daf730b78mr25917180eja.122.1667412500919; Wed, 02 Nov 2022 11:08:20 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:20 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 03/11] media: cedrus: use helper to set default formats Date: Wed, 2 Nov 2022 19:08:02 +0100 Message-Id: <20221102180810.267252-4-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110822_402962_E7183CC2 X-CRM114-Status: GOOD ( 12.40 ) 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 Now that set output format helper is available, let's use that for setting default values. Advantage of this is that values will be always valid. Current code produced invalid default values for V3s SoC, which doesn't support MPEG2 decoding. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 55c54dfdc585..2f284a58d787 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -361,16 +361,8 @@ static int cedrus_open(struct file *file) ret = PTR_ERR(ctx->fh.m2m_ctx); goto err_ctrls; } - ctx->dst_fmt.pixelformat = V4L2_PIX_FMT_NV12_32L32; - cedrus_prepare_format(&ctx->dst_fmt); - ctx->src_fmt.pixelformat = V4L2_PIX_FMT_MPEG2_SLICE; - /* - * TILED_NV12 has more strict requirements, so copy the width and - * height to src_fmt to ensure that is matches the dst_fmt resolution. - */ - ctx->src_fmt.width = ctx->dst_fmt.width; - ctx->src_fmt.height = ctx->dst_fmt.height; - cedrus_prepare_format(&ctx->src_fmt); + + cedrus_reset_out_format(ctx); v4l2_fh_add(&ctx->fh); From patchwork Wed Nov 2 18:08:03 2022 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: 13028759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C2AE3C433FE for ; Wed, 2 Nov 2022 18:13:01 +0000 (UTC) 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=iEqz91DOoOgrN/yhaatIrEt6Zh5CWcPcxXEyXglYIZQ=; b=zHiQr73LPtJw79 YjKy/wVYU0ycYi9bmRAstHc5eZlDt3iw46gKET5F1TewSnXdQXOZgsYh4sV9DApLQicbyadYTZ0oD bZ2lip0hPVg4KXNjNE3RXCZlqyplSROnf/18QnaupSXqHSHX6SYkm2LNUNOsDulq0Ff+k+3VdiQz9 p143irXWTemrii/tAgRl85IOAjnNRLcQWShDaMP2e4l0bYaVJYl8XCoOcV1GdC6zeFsQEfBi6KhQ/ H/N/bAbn6jyFmNQf40kris2xsdig0QYiuOCx0dmefuo2fwCCAht+AiQdZy1tcnaXLCpevT4H6pkHr OZNVOS+FYBuGs/XDeyrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIDO-00Cr6O-Q9; Wed, 02 Nov 2022 18:11:51 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA4-00Cogq-8W for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:26 +0000 Received: by mail-ej1-x62f.google.com with SMTP id f27so47486141eje.1 for ; Wed, 02 Nov 2022 11:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8SBm3d04GFk4/+H9PR8aMvqp5TW7eO4YQt832cb+sCg=; b=WR0l2Xt1Y0GAn95DiTLQh6MHGWr8qXgYV/chfa2ugXr4bZT9SQriyRPo6YpT2gASTF UTFPmCNDfFjbM0MfC29UFzhsYwt9b4qmh385Lm7OdlXG4DYX3jlbtCsTcKRqXpqT27j1 OxJpQ8gHoQq/KxIh/yiXTDfjiC3rbAlChB6D7Txv/j9b9ofaQ5KaFjecy7dm2QXnqn9C GCFw4IZD2AFUFXDb+9TiX/9cTvH7xmlwcZ7Emetbqi0nvrlg+S9UYLlgzFgHDmrGSQmF SFjGi+pWDE+Nw/rBjt8ZYzPo3B/h/DLiZB4PjNCVpdMwgCDA6Ud6tVxrntBBP+o9rRGv dCHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8SBm3d04GFk4/+H9PR8aMvqp5TW7eO4YQt832cb+sCg=; b=g40xjDRysmzlQ457Y9Pvrl34rYTLK+eawoDQtK5AvnYuWlts6GeMxl4bmJA8GbhuHK zTGX0/YuLNr69WbuqX6Rm+dyWjtNv23DL23nyYkUTfKAxdUyBpDf757AHBBzw3WbCZqv 4jSmW72WdcmsMZwGEIhr/kWLYNOTcI034eqF17k99aZ3KSE1TqYeGCXF4n2tW3BwaM+N lv7ShhqyXe6/ZAEjiRQCZxtlf9adqZ5vnJ4bSfrToa0G4+ZyO8DWWlXv406UHNZnVcHw ffMQbdKn96pR4pAziLChw/L5JKzSPSUKroQqO+5z/uHhG7DNdZsmWWeizdw8jrQVs47A d15w== X-Gm-Message-State: ACrzQf1WmkZ+s3JO9xtelvTFrVOLIIHYmGAM2n2brtNfR/M0Empwv8cI gKt+pID8O+bwuTdtplawv7g= X-Google-Smtp-Source: AMsMyM5gSMtm7ldxt7yqChPSJ46+ccpg2ZkAAR31xOqTldaMLBY+vUaGSN5+YW6/Te0XXBcGS4fvHA== X-Received: by 2002:a17:907:3206:b0:780:a882:a9ac with SMTP id xg6-20020a170907320600b00780a882a9acmr24800867ejb.765.1667412502028; Wed, 02 Nov 2022 11:08:22 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:21 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 04/11] media: cedrus: Add helper for checking capabilities Date: Wed, 2 Nov 2022 19:08:03 +0100 Message-Id: <20221102180810.267252-5-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110824_359130_108F53DA X-CRM114-Status: GOOD ( 18.22 ) 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 There is several different Cedrus cores with varying capabilities, so some operations like listing formats depends on checks if feature is supported or not. Currently check for capabilities is only in format handling functions, but it will be used also elsewhere later. Let's convert this check to helper and while at it, also simplify it. There is no need to check if capability mask is zero, condition will still work properly. No functional changes intended. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.h | 6 +++++ .../staging/media/sunxi/cedrus/cedrus_video.c | 24 +++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 9cffaf228422..1a98790a99af 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -268,6 +268,12 @@ vb2_to_cedrus_buffer(const struct vb2_buffer *p) return vb2_v4l2_to_cedrus_buffer(to_vb2_v4l2_buffer(p)); } +static inline bool +cedrus_is_capable(struct cedrus_ctx *ctx, unsigned int capabilities) +{ + return (ctx->dev->capabilities & capabilities) == capabilities; +} + void *cedrus_find_control_data(struct cedrus_ctx *ctx, u32 id); u32 cedrus_get_num_of_controls(struct cedrus_ctx *ctx, u32 id); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 27a7120fa6fb..192d51397fd2 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -73,8 +73,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static struct cedrus_format *cedrus_find_format(u32 pixelformat, u32 directions, - unsigned int capabilities) +static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx, + u32 pixelformat, u32 directions) { struct cedrus_format *first_valid_fmt = NULL; struct cedrus_format *fmt; @@ -83,7 +83,7 @@ static struct cedrus_format *cedrus_find_format(u32 pixelformat, u32 directions, for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) { fmt = &cedrus_formats[i]; - if ((fmt->capabilities & capabilities) != fmt->capabilities || + if (!cedrus_is_capable(ctx, fmt->capabilities) || !(fmt->directions & directions)) continue; @@ -177,19 +177,13 @@ static int cedrus_enum_fmt(struct file *file, struct v4l2_fmtdesc *f, u32 direction) { struct cedrus_ctx *ctx = cedrus_file2ctx(file); - struct cedrus_dev *dev = ctx->dev; - unsigned int capabilities = dev->capabilities; - struct cedrus_format *fmt; unsigned int i, index; /* Index among formats that match the requested direction. */ index = 0; for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) { - fmt = &cedrus_formats[i]; - - if (fmt->capabilities && (fmt->capabilities & capabilities) != - fmt->capabilities) + if (!cedrus_is_capable(ctx, cedrus_formats[i].capabilities)) continue; if (!(cedrus_formats[i].directions & direction)) @@ -244,10 +238,9 @@ static int cedrus_g_fmt_vid_out(struct file *file, void *priv, static int cedrus_try_fmt_vid_cap_p(struct cedrus_ctx *ctx, struct v4l2_pix_format *pix_fmt) { - struct cedrus_dev *dev = ctx->dev; struct cedrus_format *fmt = - cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_DST, - dev->capabilities); + cedrus_find_format(ctx, pix_fmt->pixelformat, + CEDRUS_DECODE_DST); if (!fmt) return -EINVAL; @@ -269,10 +262,9 @@ static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, static int cedrus_try_fmt_vid_out_p(struct cedrus_ctx *ctx, struct v4l2_pix_format *pix_fmt) { - struct cedrus_dev *dev = ctx->dev; struct cedrus_format *fmt = - cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_SRC, - dev->capabilities); + cedrus_find_format(ctx, pix_fmt->pixelformat, + CEDRUS_DECODE_SRC); if (!fmt) return -EINVAL; From patchwork Wed Nov 2 18:08:04 2022 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: 13028762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C631CC4332F for ; Wed, 2 Nov 2022 18:15:49 +0000 (UTC) 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=FwzL0DVAOaWL8Ur1n+Cd8WArJk6vyf2E6Kj7uCFibMk=; b=ZAFNVD0UKPC+p2 TeUGB58CrXGwIB5kK5vw5nu8Ht4jLTwB3hbJsOAeWaz9HYK2SnONaKpP/AwEue1qJbMIgh2wfh7we cFbPi+6ev1X1ZAJHMxGiLLooj4EK1BYBFLgE+DKxB+5vvgLjr2KxmPwvAhFV3eox1xzx4otMve7jo OZvfFhGxjo75DGBGUNU/AUEc31q6LqwKC+1mbXZSoY/brY7oM3GNarXxai+CZmXyeF8k3oYsU/QgD xLmW6/xOzXQPdTScekjbmhCujSeMMygHOwvXq13LsdDPOiaUWGsO4rbyP6Pm73RwWx0T+TddW8W/Q htcAsYXYwRsbnhQ8z+5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIFt-00CsdD-Uy; Wed, 02 Nov 2022 18:14:26 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA5-00CohF-Dn for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:27 +0000 Received: by mail-ed1-x52e.google.com with SMTP id l11so26531855edb.4 for ; Wed, 02 Nov 2022 11:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZVKfgkXw7e+yGEdB6RQuZns0t64mr7WUnbO0yn+HdgQ=; b=h0ZEtU6rkOV3RkAUCGI0Fk2gczGbecEoQDwS54mZnmgWbS418dzY/BBixEIAYxLXip V2i73anwzm0aP9ZIdwDRbp5Dqywu05koRpckLiGHut8CbAOUTyrVCEb87/kLn4TmykGe EiYjuHCJtZP6iE+fOUi987R2orS9BkboheUR2EkqIVgVM+VGMe3i2RVc9tn3Nf0lvwTo 7ZWlhY3JBpxQTtSBOJk9EV7oCM87mezibz6MO9KFpAm945gv1ntdzyDMuhAqxt9F2deQ sSTpS6tIrK4xK0OtP5SrSXDd8riQGZdfrG8pldzpGMuSeUhHqGpNJaSyvOSZwRXLQnms wvsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZVKfgkXw7e+yGEdB6RQuZns0t64mr7WUnbO0yn+HdgQ=; b=nKusla+DE4SPke/VmSCAnSEUpcjip91LDVWILnWQSIpI6LyVCsRfahQwB6YwixRiO7 fxVUSjDLr9Xa81ec4D/JC4GoGmdx76eH4seds3E1aY7OCEDTuKnwpR9HBP8SLa9qsmtk GfbYKrldvlwv5ncaSOfPZMNaetKIrMUDociCqgPREl0bgzUJ/ZETeGLriTwTLJtK8BJg icRmclhBwzb+hynf3Fy0K5ZFZCgaTjqAsLPRdehRDlLjp74KuvKv0tM5wg7tIw3P4UUq v1P0GPc0Jwo9Sw7KZxN5EQp6QZ1PDBru7nFZMc3NFngGmRsSYO/Gly6KYvfU3vI2GVVm dMow== X-Gm-Message-State: ACrzQf0vQ8pznDiGudAMCjoG3jEXEK8AOHKhsMflUmTuLtxGni/j9B60 rd8FOl+VWB2qN9YZc6gi3sM= X-Google-Smtp-Source: AMsMyM6yN9v4qUAXFe84vP1aXzMgt9F7FiiaE+8tvPrHZQY3FKfJU12X0d+8n8gzfKPQuxDAlfeh/Q== X-Received: by 2002:a05:6402:5107:b0:462:3014:3d73 with SMTP id m7-20020a056402510700b0046230143d73mr26136541edd.177.1667412503108; Wed, 02 Nov 2022 11:08:23 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:22 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 05/11] media: cedrus: Filter controls based on capability Date: Wed, 2 Nov 2022 19:08:04 +0100 Message-Id: <20221102180810.267252-6-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110825_499299_F7B1091F X-CRM114-Status: GOOD ( 18.23 ) 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 Because not all Cedrus variants supports all codecs, controls should be registered only if codec related to individual control is supported by Cedrus. Replace codec enum, which is not used at all, with capabilities flags and register control only if capabilities are met. We have to be careful though, controls have to be tightly packed in ctx->ctrls array. Otherwise functions cedrus_find_control_data() and cedrus_get_num_of_controls() won't work properly. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 50 +++++++++++---------- drivers/staging/media/sunxi/cedrus/cedrus.h | 2 +- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 2f284a58d787..a88ca89d966d 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -77,56 +77,56 @@ static const struct cedrus_control cedrus_controls[] = { .cfg = { .id = V4L2_CID_STATELESS_MPEG2_SEQUENCE, }, - .codec = CEDRUS_CODEC_MPEG2, + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_MPEG2_PICTURE, }, - .codec = CEDRUS_CODEC_MPEG2, + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_MPEG2_QUANTISATION, }, - .codec = CEDRUS_CODEC_MPEG2, + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_DECODE_PARAMS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_SLICE_PARAMS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_SPS, .ops = &cedrus_ctrl_ops, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_PPS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_SCALING_MATRIX, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_PRED_WEIGHTS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { @@ -134,7 +134,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, .def = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { @@ -142,7 +142,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_H264_START_CODE_NONE, .def = V4L2_STATELESS_H264_START_CODE_NONE, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, /* * We only expose supported profiles information, @@ -160,20 +160,20 @@ static const struct cedrus_control cedrus_controls[] = { .menu_skip_mask = BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED), }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_SPS, .ops = &cedrus_ctrl_ops, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_PPS, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -181,13 +181,13 @@ static const struct cedrus_control cedrus_controls[] = { /* The driver can only handle 1 entry per slice for now */ .dims = { 1 }, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_SCALING_MATRIX, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -197,7 +197,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = 0xffffffff, .step = 1, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -205,7 +205,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, .def = V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -213,19 +213,19 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_HEVC_START_CODE_NONE, .def = V4L2_STATELESS_HEVC_START_CODE_NONE, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_VP8_FRAME, }, - .codec = CEDRUS_CODEC_VP8, + .capabilities = CEDRUS_CAPABILITY_VP8_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_DECODE_PARAMS, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, }; @@ -258,7 +258,7 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx) struct v4l2_ctrl_handler *hdl = &ctx->hdl; struct v4l2_ctrl *ctrl; unsigned int ctrl_size; - unsigned int i; + unsigned int i, j; v4l2_ctrl_handler_init(hdl, CEDRUS_CONTROLS_COUNT); if (hdl->error) { @@ -274,7 +274,11 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx) if (!ctx->ctrls) return -ENOMEM; + j = 0; for (i = 0; i < CEDRUS_CONTROLS_COUNT; i++) { + if (!cedrus_is_capable(ctx, cedrus_controls[i].capabilities)) + continue; + ctrl = v4l2_ctrl_new_custom(hdl, &cedrus_controls[i].cfg, NULL); if (hdl->error) { @@ -289,7 +293,7 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx) return hdl->error; } - ctx->ctrls[i] = ctrl; + ctx->ctrls[j++] = ctrl; } ctx->fh.ctrl_handler = hdl; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 1a98790a99af..7a1619967513 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -57,7 +57,7 @@ enum cedrus_h264_pic_type { struct cedrus_control { struct v4l2_ctrl_config cfg; - enum cedrus_codec codec; + unsigned int capabilities; }; struct cedrus_h264_run { From patchwork Wed Nov 2 18:08:05 2022 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: 13028764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 37D5CC4332F for ; Wed, 2 Nov 2022 18:17:46 +0000 (UTC) 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=jvRgpTEd6GFgka/CNyJCaQ5Bf7eftkkzcaQQfEbJYEM=; b=ldW7r7P3Llji1v M0pDwI10/4uPY9hEtRE7w8j6QYVfBZyPbbN5ZFG95C218FykgUr5aTHdlX78BOcvQO7UWmtYcTzj9 +2lWHXTtO9hMoLd0Gd9BYoZDkzAWjpKf+nLjUeJllRnmKbMC7qpWoyQNYq/CRbrqQ/eUc2NNwLSnU J52CKqTNP0bQ1TF0tZUuRJgGZ5nMl2SbQh+wX+tjXbiqEeulERaOXgteMGDXTFN9m8r3wLdoi523Z IUDKnyVi49WSJaSwKXAbyRvsbZdetD02tOywFw36AQtCK9f15n2toefpDR8bdaiZXDBft2XdyTE+O 5+x9hCzItBL860cXQb2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIHx-00CtuJ-1I; Wed, 02 Nov 2022 18:16:33 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA6-00Coiy-JD for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:28 +0000 Received: by mail-ej1-x634.google.com with SMTP id bj12so47369232ejb.13 for ; Wed, 02 Nov 2022 11:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F2Hed/cwaitEX8IrPnxfw0nVvIrGKU5Ht5QuLIknVQ8=; b=b7M5xUafZOHUvxv29xa7AkbFS94acHS8dlOgQeQe+0YZAPGynF0HZthmCM4/cO79H/ mawzSDzg30s4Huq4oFbWQ9CgckbxVgGJV6JrVZV2QN/eK/AY2pq5yqvvy9PgBhRl1NZ0 tKYTnc97RIIQYChMsjuEZmP9RAriCt+fXhd3chXfzBgfvTqCnx9bZ3/div3h5YGIYG9+ UXSfDdItc/fUT4JWIJEGqyW9p7TD5RaXhV2oTBcOdbt3eiNqoF1E6Mlpi4XNUytAqteq qwTLHnyxofcuwly6HpbVu3F1hpPectLC7LD0sTIS8tx8mHHrlyRC/loAb3jdaHiUOKp6 /nTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F2Hed/cwaitEX8IrPnxfw0nVvIrGKU5Ht5QuLIknVQ8=; b=ZJ1YbiJmoccdS9RFJRAz/f6pJ6FDfwSBfBs/xcj7TAtMvZs5saj9g6CjzZCLJW5yoP yCxSANtYMG3K+K4zxrEyxLuF7Tt1CoOZhamu9z4p8C5WwljLUC9r3JsbeYBJf8UgqXDX 8Pmbv8M0Dpjzu8VZ0tDo6SuV5HKNVP0V6rfGPeaAbtfNxswf1J/DYryWjHelmTDTLe1Q q/Qrofog5DTYNAq17ni+woxEBDJK5FifWssenSyrfJo0eBOTma6kDt+huZ9dWDSQ8C5X BJCvzftJHDwC1BL1+k16AYrFYCfNPFvSLwFX4Jb6jk/1IuWuORLaqHTNjVeV9HDhTRy9 P0Lw== X-Gm-Message-State: ACrzQf2Gjh0qC0676er1QLE13XUj/nJw0NGWO4t6MqNS6Iy8w+vN1gqt +JOUk/AWwQXFlStib4dnOrUkHEBb5v0= X-Google-Smtp-Source: AMsMyM6Xb/K1ndt+NgJjR40T4NnSZFahGn53K3pedEhA3ScDvPTqcSG72la0+XCdpyKaIbKodU2FRQ== X-Received: by 2002:a17:907:75d1:b0:7a8:291:2050 with SMTP id jl17-20020a17090775d100b007a802912050mr25428508ejc.287.1667412504299; Wed, 02 Nov 2022 11:08:24 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:23 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 06/11] media: cedrus: set codec ops immediately Date: Wed, 2 Nov 2022 19:08:05 +0100 Message-Id: <20221102180810.267252-7-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110826_687667_D9E47844 X-CRM114-Status: GOOD ( 18.75 ) 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 We'll need codec ops soon after output format is set in following commits. Let's move current codec setup to set output format callback. While at it, let's remove one level of indirection by changing current_codec to point to codec ops structure directly. Acked-by: Paul Kocialkowski Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 5 --- drivers/staging/media/sunxi/cedrus/cedrus.h | 3 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 4 +- .../staging/media/sunxi/cedrus/cedrus_hw.c | 6 +-- .../staging/media/sunxi/cedrus/cedrus_video.c | 44 ++++++++----------- 5 files changed, 25 insertions(+), 37 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index a88ca89d966d..37b1df9a9d6a 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -456,11 +456,6 @@ static int cedrus_probe(struct platform_device *pdev) return ret; } - dev->dec_ops[CEDRUS_CODEC_MPEG2] = &cedrus_dec_ops_mpeg2; - dev->dec_ops[CEDRUS_CODEC_H264] = &cedrus_dec_ops_h264; - dev->dec_ops[CEDRUS_CODEC_H265] = &cedrus_dec_ops_h265; - dev->dec_ops[CEDRUS_CODEC_VP8] = &cedrus_dec_ops_vp8; - mutex_init(&dev->dev_mutex); INIT_DELAYED_WORK(&dev->watchdog_work, cedrus_watchdog); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 7a1619967513..0b082b1fae22 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -126,7 +126,7 @@ struct cedrus_ctx { struct v4l2_pix_format src_fmt; struct v4l2_pix_format dst_fmt; - enum cedrus_codec current_codec; + struct cedrus_dec_ops *current_codec; struct v4l2_ctrl_handler hdl; struct v4l2_ctrl **ctrls; @@ -185,7 +185,6 @@ struct cedrus_dev { struct platform_device *pdev; struct device *dev; struct v4l2_m2m_dev *m2m_dev; - struct cedrus_dec_ops *dec_ops[CEDRUS_CODEC_LAST]; /* Device file mutex */ struct mutex dev_mutex; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c index e7f7602a5ab4..fbbf9e6f0f50 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c @@ -94,7 +94,7 @@ void cedrus_device_run(void *priv) cedrus_dst_format_set(dev, &ctx->dst_fmt); - error = dev->dec_ops[ctx->current_codec]->setup(ctx, &run); + error = ctx->current_codec->setup(ctx, &run); if (error) v4l2_err(&ctx->dev->v4l2_dev, "Failed to setup decoding job: %d\n", error); @@ -110,7 +110,7 @@ void cedrus_device_run(void *priv) schedule_delayed_work(&dev->watchdog_work, msecs_to_jiffies(2000)); - dev->dec_ops[ctx->current_codec]->trigger(ctx); + ctx->current_codec->trigger(ctx); } else { v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c index a6470a89851e..c3387cd1e80f 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c @@ -132,12 +132,12 @@ static irqreturn_t cedrus_irq(int irq, void *data) return IRQ_NONE; } - status = dev->dec_ops[ctx->current_codec]->irq_status(ctx); + status = ctx->current_codec->irq_status(ctx); if (status == CEDRUS_IRQ_NONE) return IRQ_NONE; - dev->dec_ops[ctx->current_codec]->irq_disable(ctx); - dev->dec_ops[ctx->current_codec]->irq_clear(ctx); + ctx->current_codec->irq_disable(ctx); + ctx->current_codec->irq_clear(ctx); if (status == CEDRUS_IRQ_ERROR) state = VB2_BUF_STATE_ERROR; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 192d51397fd2..f6305ffe2c4f 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -333,6 +333,21 @@ static int cedrus_s_fmt_vid_out_p(struct cedrus_ctx *ctx, break; } + switch (ctx->src_fmt.pixelformat) { + case V4L2_PIX_FMT_MPEG2_SLICE: + ctx->current_codec = &cedrus_dec_ops_mpeg2; + break; + case V4L2_PIX_FMT_H264_SLICE: + ctx->current_codec = &cedrus_dec_ops_h264; + break; + case V4L2_PIX_FMT_HEVC_SLICE: + ctx->current_codec = &cedrus_dec_ops_h265; + break; + case V4L2_PIX_FMT_VP8_FRAME: + ctx->current_codec = &cedrus_dec_ops_vp8; + break; + } + /* Propagate format information to capture. */ ctx->dst_fmt.colorspace = pix_fmt->colorspace; ctx->dst_fmt.xfer_func = pix_fmt->xfer_func; @@ -491,34 +506,13 @@ static int cedrus_start_streaming(struct vb2_queue *vq, unsigned int count) struct cedrus_dev *dev = ctx->dev; int ret = 0; - switch (ctx->src_fmt.pixelformat) { - case V4L2_PIX_FMT_MPEG2_SLICE: - ctx->current_codec = CEDRUS_CODEC_MPEG2; - break; - - case V4L2_PIX_FMT_H264_SLICE: - ctx->current_codec = CEDRUS_CODEC_H264; - break; - - case V4L2_PIX_FMT_HEVC_SLICE: - ctx->current_codec = CEDRUS_CODEC_H265; - break; - - case V4L2_PIX_FMT_VP8_FRAME: - ctx->current_codec = CEDRUS_CODEC_VP8; - break; - - default: - return -EINVAL; - } - if (V4L2_TYPE_IS_OUTPUT(vq->type)) { ret = pm_runtime_resume_and_get(dev->dev); if (ret < 0) goto err_cleanup; - if (dev->dec_ops[ctx->current_codec]->start) { - ret = dev->dec_ops[ctx->current_codec]->start(ctx); + if (ctx->current_codec->start) { + ret = ctx->current_codec->start(ctx); if (ret) goto err_pm; } @@ -540,8 +534,8 @@ static void cedrus_stop_streaming(struct vb2_queue *vq) struct cedrus_dev *dev = ctx->dev; if (V4L2_TYPE_IS_OUTPUT(vq->type)) { - if (dev->dec_ops[ctx->current_codec]->stop) - dev->dec_ops[ctx->current_codec]->stop(ctx); + if (ctx->current_codec->stop) + ctx->current_codec->stop(ctx); pm_runtime_put(dev->dev); } From patchwork Wed Nov 2 18:08:06 2022 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: 13028763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 955E3C4332F for ; Wed, 2 Nov 2022 18:17:05 +0000 (UTC) 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=rL6ESx1bXWiGyZ3qKA3spamE0CbaJ1kAH+q64e2Bzmo=; b=cE0RgUjwz4vLZ1 TkpYPCsOuRyD2VtIlzbXsALcIrkGCV9j41NXcifOvQaD3s5Ghna0bgN/ER7kqIYAl4rrIP+7fHPfh WjxyFlG9P1HWUL+ZCFaHVBvRFK+VW+aNvwS7/sMUBrkKOgstpNxX8QprzaCYFEnx4MSoSUC5IjVug OCpB6Ho79gKBRtbtwPKLTKPd/x6peZCRKLadWJR2J/JJodYFRLuEEToBZnsRkQBEiKInzhNlqxgS3 mvEfdTwuAI7Hg1KR/ETOudjqQlRissS12UYZPAbaOOPTL93ZnKgnS3u/J81UgL2+5XC6wII6PMvrL oNBt2mVZm8+zBZ7Uhbwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIH3-00CtMH-SE; Wed, 02 Nov 2022 18:15:39 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA6-00CokH-Us for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:29 +0000 Received: by mail-ej1-x634.google.com with SMTP id k2so47528966ejr.2 for ; Wed, 02 Nov 2022 11:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LZXn/eratvKwy31qlLD6eywRNyLVLrqRQvFS+fmobPY=; b=jgFGwGoBaVDoPDl4dOt823hkJpZ+xNsjJdU8XvAt1wACNy+6p3tKUOE1KlUnR+MfZW nrjhY/6aCmhJc41DMTR0/sUHzzl38/EGZujd2tuQMS207TDxWNhQs376LGAKx1j/vazs uJHkcq5cAgdLPOqTJOsS4eBi04ORyG3iGXwb3wFiV/mmt2tvE5KmnOOu/lz+yPGcYHIg WHlMZsFMuX4AzD7Ao4W+8IA99AryXGit/o+FNeqRaf8IL2VYMqkszLup24KRJkxJTxcI swH91okm30O/ycayJm0ONBL38bBuFBfIEHoEwNzZU0obaQh/rnjOP6VLAlHl+q4w0SLp HJtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LZXn/eratvKwy31qlLD6eywRNyLVLrqRQvFS+fmobPY=; b=6xUvoGajtb+iCDfUP4bUrhGw1p1TXckmeDXFBFyp8YpvEhSFPFE2K81w5MiMqTHoYv 5Cf6SXDDKMUFQ+y8qvCIIBGgKdYkssT5dDf34Fx/D2Cl4kffU6K6fXIFJsj40hIrPkwf /o9frDl7sE3lYZB+WtiL1TynLBtd1nqGVgNMXHJIE8iqAqclRRUn+cl2MrSJh/rsuQDc Blg+COpa0JDIlHGkNj4WvPOUaqME0ZNbfAXYlkOH3rdN0IUNhzm2E6mr7bb9MTPAkgqg QkMzJnYEQa7W4OIYfrQmve+Hp+6ih+q0n0uO3P6D3nS9/F2D53A7/H801lPQJF4bBFVi xCYw== X-Gm-Message-State: ACrzQf0Mw+DOMnS6nw08AUOI6XYmWWxzrmh14dE7Iu5BCFB0H7PmxNw2 k+88N91f5r/9i3WbpjZOzVc= X-Google-Smtp-Source: AMsMyM4mp/994s29Y9cbpgyVTuqHdNKAhOfhMBHOTnNDO4ll8TKOevkgBXSAnW0Ez1XNG6S8i+3j5A== X-Received: by 2002:a17:906:195b:b0:7ae:108:9729 with SMTP id b27-20020a170906195b00b007ae01089729mr4720802eje.604.1667412505457; Wed, 02 Nov 2022 11:08:25 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:25 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 07/11] media: cedrus: Remove cedrus_codec enum Date: Wed, 2 Nov 2022 19:08:06 +0100 Message-Id: <20221102180810.267252-8-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110827_153640_60B73EA7 X-CRM114-Status: GOOD ( 15.09 ) 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 Last user of cedrus_codec enum is cedrus_engine_enable() but this argument is completely redundant. Same information can be obtained via source pixel format. Let's remove this argument and enum. No functional changes intended. Acked-by: Paul Kocialkowski Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.h | 8 -------- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_hw.c | 12 ++++++------ drivers/staging/media/sunxi/cedrus/cedrus_hw.h | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_vp8.c | 2 +- 7 files changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 0b082b1fae22..5904294f3108 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -35,14 +35,6 @@ #define CEDRUS_CAPABILITY_VP8_DEC BIT(4) #define CEDRUS_CAPABILITY_H265_10_DEC BIT(5) -enum cedrus_codec { - CEDRUS_CODEC_MPEG2, - CEDRUS_CODEC_H264, - CEDRUS_CODEC_H265, - CEDRUS_CODEC_VP8, - CEDRUS_CODEC_LAST, -}; - enum cedrus_irq_status { CEDRUS_IRQ_NONE, CEDRUS_IRQ_ERROR, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index c92dec21c1ac..dfb401df138a 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -518,7 +518,7 @@ static int cedrus_h264_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) struct cedrus_dev *dev = ctx->dev; int ret; - cedrus_engine_enable(ctx, CEDRUS_CODEC_H264); + cedrus_engine_enable(ctx); cedrus_write(dev, VE_H264_SDROT_CTRL, 0); cedrus_write(dev, VE_H264_EXTRA_BUFFER1, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index 7a438cd22c34..5d3da50ce46a 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -471,7 +471,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) } /* Activate H265 engine. */ - cedrus_engine_enable(ctx, CEDRUS_CODEC_H265); + cedrus_engine_enable(ctx); /* Source offset and length in bits. */ diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c index c3387cd1e80f..fa86a658fdc6 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c @@ -31,7 +31,7 @@ #include "cedrus_hw.h" #include "cedrus_regs.h" -int cedrus_engine_enable(struct cedrus_ctx *ctx, enum cedrus_codec codec) +int cedrus_engine_enable(struct cedrus_ctx *ctx) { u32 reg = 0; @@ -42,18 +42,18 @@ int cedrus_engine_enable(struct cedrus_ctx *ctx, enum cedrus_codec codec) reg |= VE_MODE_REC_WR_MODE_2MB; reg |= VE_MODE_DDR_MODE_BW_128; - switch (codec) { - case CEDRUS_CODEC_MPEG2: + switch (ctx->src_fmt.pixelformat) { + case V4L2_PIX_FMT_MPEG2_SLICE: reg |= VE_MODE_DEC_MPEG; break; /* H.264 and VP8 both use the same decoding mode bit. */ - case CEDRUS_CODEC_H264: - case CEDRUS_CODEC_VP8: + case V4L2_PIX_FMT_H264_SLICE: + case V4L2_PIX_FMT_VP8_FRAME: reg |= VE_MODE_DEC_H264; break; - case CEDRUS_CODEC_H265: + case V4L2_PIX_FMT_HEVC_SLICE: reg |= VE_MODE_DEC_H265; break; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.h b/drivers/staging/media/sunxi/cedrus/cedrus_hw.h index 7c92f00e36da..6f1e701b1ea8 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.h @@ -16,7 +16,7 @@ #ifndef _CEDRUS_HW_H_ #define _CEDRUS_HW_H_ -int cedrus_engine_enable(struct cedrus_ctx *ctx, enum cedrus_codec codec); +int cedrus_engine_enable(struct cedrus_ctx *ctx); void cedrus_engine_disable(struct cedrus_dev *dev); void cedrus_dst_format_set(struct cedrus_dev *dev, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c index c1128d2cd555..10e98f08aafc 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c @@ -66,7 +66,7 @@ static int cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) quantisation = run->mpeg2.quantisation; /* Activate MPEG engine. */ - cedrus_engine_enable(ctx, CEDRUS_CODEC_MPEG2); + cedrus_engine_enable(ctx); /* Set intra quantisation matrix. */ matrix = quantisation->intra_quantiser_matrix; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c index f7714baae37d..969677a3bbf9 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c @@ -662,7 +662,7 @@ static int cedrus_vp8_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) int header_size; u32 reg; - cedrus_engine_enable(ctx, CEDRUS_CODEC_VP8); + cedrus_engine_enable(ctx); cedrus_write(dev, VE_H264_CTRL, VE_H264_CTRL_VP8); From patchwork Wed Nov 2 18:08:07 2022 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: 13028765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DD496C433FE for ; Wed, 2 Nov 2022 18:19:22 +0000 (UTC) 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=t86HudBBxJWyZ8Mmd7SvAAWQgS15/Q/HRse6wq4K4IE=; b=jJ0znZib99kMZN pc/jtirCoDR4qs7zLvbBe8SQ0KERH0CdedFYGbP9m/zmUZkwhoZmZkcbrFqsZLLCHy9MF6rXOWbT8 0gN89QV8OmW1exyLcHhIUEr4fRUAt+MquP9a6Aw5cmFhrTA5tfG2WCwLYSvwlXJ+sPKIMQPHz8dAQ BLBbGE/oi9jxBVPce8w2QEePUIy5xj6C/dwncBAbZ988zcoF0sRidHC3Vozf/XTJ0SzGcfev0quX+ N2i9SNLDz8xPjOoYLQDx4qXzTIoLPj3AsVC4sIR7v+s1BW9g3jy0vqkeFCXvx3hg2oJVo1CJCUJwp DSyQQ/0jO0OWF9b97F/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIJK-00Cunb-Ty; Wed, 02 Nov 2022 18:18:00 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA8-00ColR-P9 for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:30 +0000 Received: by mail-ej1-x62a.google.com with SMTP id q9so47563662ejd.0 for ; Wed, 02 Nov 2022 11:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VdOwqqxxYEZRd9acvNPnTYoR6lmdOOAyvQmf0ex2vO8=; b=HCjeFIP8UyzZhiT1DfZSmx9y0DaO9+xtJgKkH2ojsI4ewcVjk9DRYxTLcrOZeDekjq A43BnfqCo1CclbOe4QwMVAKshpXEaatIwlFqjhgabD4haNE/C0CBWd8g0A7DpXG6P/cF UZT1mEUmWiz6OmECxCcTOXMCEkjUENtYt5l4bEUMDjwImhhUDz98GLoTmJfDw68/v1Qb vqSXiP8YzopVl/1a21kUMvX19dpsoexISLnBjyvAVAmxn7KAARKrsbDHP77G+ax14U4W 3qbeIvDWgaa7o2UWu6OIMk4H4i2iG1bdZw0m2Vmc7HK0RPrVYDktYw9UTo72OGVM17Zn tIpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VdOwqqxxYEZRd9acvNPnTYoR6lmdOOAyvQmf0ex2vO8=; b=1431LG8sQ4Bo/N+aZ8BojuQdDYnhkltJKt8eDhOi7PeKhtrb+Mxa9io+04geWcsF23 pPmME+l02IecfrGRv7rYu3Ab8mcrZ9HWT4oyzGrEsbFtcX04RQFjlK4LZxgmgKZsGtDq FKvHE+Pebcdk3LaKxUtPoNPIuwFJJ9sGc2aONzPQPu5AnnGouZd6qZHarONmEwZw5MBB Dcn5po3AkWz3/seK0rFiNz8ef/pXrfIiqjfADwkc9hp+aMLidYPs3fCna1K4NcaRRQxF Abd3twBXt2JXrlG1bcmme0e0b3eQYC9EqSlFYalVrYi+LhWcucplsyEJeJnDPz3RbpD9 5amQ== X-Gm-Message-State: ACrzQf36exsY6XdCLFpWfwidPmsHc/sLSQsRL6Cgnyi2d7I/j1iCCocA /7IpTV136Lnw7Hl4Kws6w1w= X-Google-Smtp-Source: AMsMyM5ESq06l/CLF/S76CA9K2WIH6qaugl08P/TEhcqmBK3ysB98KByBVKRNooXPHlpgNsVAjagNw== X-Received: by 2002:a17:906:5dae:b0:78e:302f:4218 with SMTP id n14-20020a1709065dae00b0078e302f4218mr26430520ejv.22.1667412506572; Wed, 02 Nov 2022 11:08:26 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:26 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 08/11] media: cedrus: prefer untiled capture format Date: Wed, 2 Nov 2022 19:08:07 +0100 Message-Id: <20221102180810.267252-9-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110828_855924_A85C12F8 X-CRM114-Status: GOOD ( 13.00 ) 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 While all generations of display engine on Allwinner SoCs support untiled format, only first generation supports tiled format. Let's move untiled format up, so it can be picked before tiled one. If Cedrus variant doesn't support untiled format, tiled will still be picked as default format. Acked-by: Paul Kocialkowski Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index f6305ffe2c4f..dec5d3ae4871 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -55,15 +55,15 @@ static struct cedrus_format cedrus_formats[] = { .directions = CEDRUS_DECODE_SRC, .capabilities = CEDRUS_CAPABILITY_VP8_DEC, }, - { - .pixelformat = V4L2_PIX_FMT_NV12_32L32, - .directions = CEDRUS_DECODE_DST, - }, { .pixelformat = V4L2_PIX_FMT_NV12, .directions = CEDRUS_DECODE_DST, .capabilities = CEDRUS_CAPABILITY_UNTILED, }, + { + .pixelformat = V4L2_PIX_FMT_NV12_32L32, + .directions = CEDRUS_DECODE_DST, + }, }; #define CEDRUS_FORMATS_COUNT ARRAY_SIZE(cedrus_formats) From patchwork Wed Nov 2 18:08:08 2022 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: 13028776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9F493C433FE for ; Wed, 2 Nov 2022 18:22:02 +0000 (UTC) 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=Vp0Wk1qLvdnxNdWusJiYASKhGuOQeLbRUyXiX4Q3Qas=; b=rlq+dWubG3XzNm xrGrqHDjH50n4+cC+3Yr1CXKcdjZ+/wICPBpteIXHKjd22GB2iTqMRttoyun9we2d8zQ2SvLJ5bmR 3YqVau5KjprVpOjB34j841dPZTVQxiyNA7TYRLKNa/lPCfQ5FzCafmQ309G5wX7TRzrwXJxuaKFUw l3d6zmaY1oM/bb3BsxWfctY9CSrKymCNtBWV8AtjAK+qX/krzmjLOQ90fJY7ebDbxKTuVzSGPbZPG abKbVG/+1mxvX2g0grK0JDUxCdd4TOvrAP6bkw7O2tawfxIsH4MQmISfFqoPpgQFBE09mEq35nGLk kpRZPIMSbEPdSL1GIa4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqILw-00CwLT-VB; Wed, 02 Nov 2022 18:20:42 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIA9-00Comj-Ki for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:31 +0000 Received: by mail-ed1-x533.google.com with SMTP id f7so22045545edc.6 for ; Wed, 02 Nov 2022 11:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lOVecSCg58WLAt5MFbBf+7umb5iX32HjizH1LHXmtzY=; b=c4sCG5TAZ2UUoS2lgWb76UO1do1+DNv9lhf4f4V7zz8ljX4X5EhvcAsgEefuVLOg+q gaywl+w/4OLpyHt3F/9Bwyiwk5P2gVSKETjqXN25CxxveeMkl1P02LTapxNRpEbc4ncS y0DtjSpEZpoo2aYks0chPXEMt1SraV5egn74lh0bqLCfULmWstsxoJQzoNKJwcM24qu5 exgx3cKeSyDCHntD25R80Aed0dN9MnlXk9pnJP8nJ5srwQ3D4KTDuWMqgQDoOgnlpd23 V9+2EcH2DuN9nLi3yQK1rC1Vva6WPZ/ddX8HBC+0qQqm0AeUMYHozRY7sbi8QTnZCa4A ZmUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lOVecSCg58WLAt5MFbBf+7umb5iX32HjizH1LHXmtzY=; b=vS+wYzw9CA9u3OJ9uFyVbgho9uR4ESpHbFC0M3lJ4rCFf1kBQeElp4B8CkUGusGwoO j6TrdFmvxG19OeffzJuaXwGeJxj34coRcYWw+ZxZwy4ry49PtCD6wTVJB8agHNYMZXv2 FKKj+Vz/Ktca0VJvtCinI262CspTySNqiXsWYRu0CweeJ70ZdCq/z1vewN3Ge+X2uOTS Nza9CvMVTFAUle2PFDjaM+8yG8+s7602dtgW9FwMfMTDRU/OZrrGKb4pvQGRhU8a1obq ERdtbCKLJUTwekNsSoZ5BOXNX+mSkXaCK+WtgivlBVlNiYROaDy1RTFlWwvU3gvkMZpp i31A== X-Gm-Message-State: ACrzQf0Fso/2sl1EYFi6wFeD6vq5ZIQdwza2DjGTjkL01yoRYhuy+Cjf 0Re1RysR2lGN4pOzdT7dUxQ= X-Google-Smtp-Source: AMsMyM6muLY2M00Knxi/o8lVph4GJlPIjeZVu+nV5Y9ZTqSo+P6497kNAnSyQ3n27WFCtlCImp3mvg== X-Received: by 2002:a05:6402:249b:b0:460:cb11:27d4 with SMTP id q27-20020a056402249b00b00460cb1127d4mr25895603eda.410.1667412507718; Wed, 02 Nov 2022 11:08:27 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:27 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 09/11] media: cedrus: initialize controls a bit later Date: Wed, 2 Nov 2022 19:08:08 +0100 Message-Id: <20221102180810.267252-10-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110829_730926_8B332560 X-CRM114-Status: GOOD ( 12.74 ) 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 While it doesn't matter if controls are initialized before or after queues and formats from open handler standpoint, initializing them last helps keeping s_ctrl handler simpler, since everything has already valid values. This is just preparation for follow up changes. No functional change is intended. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 37b1df9a9d6a..6a2c08928613 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -355,27 +355,27 @@ static int cedrus_open(struct file *file) file->private_data = &ctx->fh; ctx->dev = dev; - ret = cedrus_init_ctrls(dev, ctx); - if (ret) - goto err_free; - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &cedrus_queue_init); if (IS_ERR(ctx->fh.m2m_ctx)) { ret = PTR_ERR(ctx->fh.m2m_ctx); - goto err_ctrls; + goto err_free; } cedrus_reset_out_format(ctx); + ret = cedrus_init_ctrls(dev, ctx); + if (ret) + goto err_m2m_release; + v4l2_fh_add(&ctx->fh); mutex_unlock(&dev->dev_mutex); return 0; -err_ctrls: - v4l2_ctrl_handler_free(&ctx->hdl); +err_m2m_release: + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); err_free: kfree(ctx); mutex_unlock(&dev->dev_mutex); From patchwork Wed Nov 2 18:08:09 2022 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: 13028766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 42CF0C4332F for ; Wed, 2 Nov 2022 18:20:36 +0000 (UTC) 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=cqIVGi7VIhbh+FCXfs3pu2d5SLivWFYTi0LONUAj9YM=; b=p2kOBYypUNsbz4 0dTOz8ecfO5bLQ3SUpwdF8yT85e4SHzu5kXP0j577FjmxK2awGMniDNPclRpXDwRY4fMd6g/hmzf/ BWZW7PqBbo0s3Pfu0wKppu+wWqmNQNUkvh7BCzOKEm3BQdc23+sGbhD998SKpiCjWSfZDXg9H9VvL GSV+7mqi7tGlMTsfh66BfaYvwleatngMatm+1PeQXB8Qz96SzXK4fg9UN7rACeq+MQ7JxtdayR912 zyQ/SCAtqd2M4lEnJ35S4T6mbJ8AJV0YCYptlWchqZ5nolsD2fJlgYSHnljEvHBal7HErHLZPnen1 sDce6BUlbR9K1lo/arpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIKX-00CvTA-1S; Wed, 02 Nov 2022 18:19:14 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIAA-00Conl-QW for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:32 +0000 Received: by mail-ed1-x52a.google.com with SMTP id a67so27705011edf.12 for ; Wed, 02 Nov 2022 11:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zTX/CJSb7MB7yBzrjB/XPnpPEfJPqcJy2sRni4DNHhc=; b=BWwH0PLp6JQ9eYWdTML13I1KDHGFTpJL2HjwEIHw81SznXWlFHTHSGWOlc7rSeX503 9wqgaJhi0gATwz9JUOCOVIlEvlOcAAxSSw4jpkKHc1XQj8MYdzptxvQQa10K74lJnjKO jYsqyFNonzO42fSV0aDTHyZcLt48Xwneh3+krvC2SQV75tXrTQ6zEY8ieSrftyVNXarC FxZCPMocPoPCtGFhYjDdZjDakeFDyxbJUOA5ueFmLMmXM7e5+tsZ8JllrRhSr7gjS0Tj QXKdq4b+3GH/aCvfMgDMokftvmjIQP3LAxTJP355QlPNg/lpS8lip99Qg0Ha4m7/3OA1 daRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zTX/CJSb7MB7yBzrjB/XPnpPEfJPqcJy2sRni4DNHhc=; b=uqr4o2qSd9HvR+2vsu6PLvlklpXFUu79+fuYCSPXL8ilQqxyg1+juwATX4ngDrP0+m wEwM1KEWVjLIWNF322fjkqx7hjSHGp6D5+QlxvqiPnfN1fyFWIN9DlDmuAJrRgs+6lWW jZxc7DtsoyGdvQBkgkRFX51H3uERuJkVJmaHpx6CCuL9GjvURktxvmRvOFEg/1T6GRwj 9QvhV+sTl8rRZELrzY1lObGYmY7PHmupjgQMacSrqbk3CM0lqRkl16wU+W/Q+91LjDpK jVHU93dAbEovwT8rsqMs/ZmNK0JzWUh+rmNwKq56NbejQ200HiVRKY/RhCeZpO/52EoC sfiw== X-Gm-Message-State: ACrzQf3fDJyV5IUg3GGQjDKNi/8UeyrUEz10M/e45uYLFqOlUjfxgKKz CUP7GfaXXDUGszxTvyuw2N4= X-Google-Smtp-Source: AMsMyM7IKKboWbODn0dEZMDDWaIh2XhF9lJrzZnIHY8gQG+UF2lAOeAb//oR918UqPONo5aKDRZFjg== X-Received: by 2002:a05:6402:528a:b0:454:8613:6560 with SMTP id en10-20020a056402528a00b0045486136560mr26656883edb.252.1667412508810; Wed, 02 Nov 2022 11:08:28 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:28 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 10/11] media: cedrus: Adjust buffer size based on control values Date: Wed, 2 Nov 2022 19:08:09 +0100 Message-Id: <20221102180810.267252-11-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110830_904221_9615C3FF X-CRM114-Status: GOOD ( 14.82 ) 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 In some cases decoding engine needs extra space in capture buffers. This is the case for decoding 10-bit HEVC frames into 8-bit capture format. This commit only adds infrastructure for such cases. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 14 ++++++++++++++ drivers/staging/media/sunxi/cedrus/cedrus.h | 2 ++ drivers/staging/media/sunxi/cedrus/cedrus_video.c | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 6a2c08928613..c36999e47591 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -68,8 +68,22 @@ static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl) return 0; } +static int cedrus_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct cedrus_ctx *ctx = container_of(ctrl->handler, + struct cedrus_ctx, hdl); + struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE); + + if (!vb2_is_busy(vq) && !vb2_is_streaming(vq)) + cedrus_reset_cap_format(ctx); + + return 0; +} + static const struct v4l2_ctrl_ops cedrus_ctrl_ops = { .try_ctrl = cedrus_try_ctrl, + .s_ctrl = cedrus_s_ctrl, }; static const struct cedrus_control cedrus_controls[] = { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 5904294f3108..774fe8048ce3 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -162,6 +162,8 @@ struct cedrus_dec_ops { int (*start)(struct cedrus_ctx *ctx); void (*stop)(struct cedrus_ctx *ctx); void (*trigger)(struct cedrus_ctx *ctx); + unsigned int (*extra_cap_size)(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt); }; struct cedrus_variant { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index dec5d3ae4871..dc67940f1ade 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -250,6 +250,10 @@ static int cedrus_try_fmt_vid_cap_p(struct cedrus_ctx *ctx, pix_fmt->height = ctx->src_fmt.height; cedrus_prepare_format(pix_fmt); + if (ctx->current_codec->extra_cap_size) + pix_fmt->sizeimage += + ctx->current_codec->extra_cap_size(ctx, pix_fmt); + return 0; } From patchwork Wed Nov 2 18:08:10 2022 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: 13028777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0B71CC4332F for ; Wed, 2 Nov 2022 18:23:25 +0000 (UTC) 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=eTGFoyX6dBR71bdsvdqoBy4I4snoG9JXevZuYo6rA1I=; b=L4NPjSWkPkIYmm mTzxLLrm+iO0hgfBuRAGXmEnIIwXDtk8inmFW/ursP8XTYndbJAxVOjRbeRve/5jUzg8dspNCzNjZ vIprCK53W0eXB+/uKdGQXGH9gt8vzlN3rSOQ6oW4/0A6PnErO15ExelehsUrn3tLa/kBcxjlKnmi7 BjU9FMMq4DIvCdc1eWSCLFAyM4bbN5tkU9wSdfZzho9yADgoWWIzEBA5YV1lP8kalmACjhQkyHdOh rM3/ZcbWOMaa2eUbDnMKq5kBqwCs2mNis4V++bQVG6Lw7StW+GtDzPQ9xau2MS8RsSeas2OYXdTKb CIABtk54oD7sp2IwlNDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqINJ-00CxJZ-Q8; Wed, 02 Nov 2022 18:22:06 +0000 Received: from mail-ej1-f44.google.com ([209.85.218.44]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIAD-00CoqX-Iv for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:35 +0000 Received: by mail-ej1-f44.google.com with SMTP id kt23so47410590ejc.7 for ; Wed, 02 Nov 2022 11:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UnsNN7r2W9xkEzjhO5QJbPuVldjOL5oHt6w+pHrcgpM=; b=HYcMm0Ufc9sLUzcVbUacmyLCBSPMGFY2g3U1wwwC0aff82njCuumTTQn90EMAJyhT5 XtEslqT4EgC6fr87jXNwXsVWmNLbsM8n88TM6jgrt/JATwt6q6Q6jI+FKV2+jpEqNfxi 6/GPUfQJ8brJyJuMYl3eemNdXiXZYVqzAOJhfOCU8IYe/cI5e+7w4uk0GagWQNcw60rl SK1h+ZTRmv+TyC1it+zzwtIbF7rgPrc3W3pHtEyHSFwNhUEUqeesk4ng7okbObhNoHh6 rVCnMmf6ydzErb+2kxT9X0yvfwMFMwT5TOlfwWPPmLG+Y0kFLGx4wfou7c0NzLx/q1E1 PWwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UnsNN7r2W9xkEzjhO5QJbPuVldjOL5oHt6w+pHrcgpM=; b=AxY61bF4dwSXHeMGpdPPxhxf8GepUToFue/jqgaDtACIDTvD+WrM+aBRvVEsqF2wqv XdQF3HZMku8Ok8w73/xEIc1sj9BjVOCCrrSWu9ATDcIc6oAc0VqA8klCJHP7KuqM1h0b f/dkz3Rvd5TwflRuMqWpOAm62PRgTyD3NXWuAD0A3WaEzdta3NTnzYxdb96RsaemTvL5 suwrE1VO0SeHdgXeisaBKVgEEiBG0o+pJVOFKERpr8qfBL4qMm0Q4hnHrQy9XW/uTV4g lEu7i/U3SoNjssNAuJk5FCEDxbDM3pXnsX9nJhElWaMluZc+BBO87xOjSqQPxyypKpGW ub+A== X-Gm-Message-State: ACrzQf3N2g7LwsfVNLUZ9J/bYSARrMPe2y6ZtZXptIDzx2roZZ389ph4 Eeivo2Ef5WziLEmQKfgtamU= X-Google-Smtp-Source: AMsMyM5KASGBahil6cWvOOQ33GgPmn+YKHhSuh2FkeXY0JHcuKHQXj8pBygQZFJ+xHd50o0EsJoFIA== X-Received: by 2002:a17:906:8458:b0:7ac:a48d:a680 with SMTP id e24-20020a170906845800b007aca48da680mr25750562ejy.105.1667412509956; Wed, 02 Nov 2022 11:08:29 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:29 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, hverkuil-cisco@xs4all.nl, 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 v2 11/11] media: cedrus: h265: Support decoding 10-bit frames Date: Wed, 2 Nov 2022 19:08:10 +0100 Message-Id: <20221102180810.267252-12-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110833_680122_39D1E53C X-CRM114-Status: GOOD ( 16.43 ) 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 10-bit frames needs extra buffer space when 8-bit capture format is used. Use previously prepared infrastructure to adjust buffer size. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 7 ++++ drivers/staging/media/sunxi/cedrus/cedrus.h | 1 + .../staging/media/sunxi/cedrus/cedrus_h265.c | 35 +++++++++++++++++++ .../staging/media/sunxi/cedrus/cedrus_regs.h | 16 +++++++++ 4 files changed, 59 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index c36999e47591..909f769b3ede 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -75,6 +75,13 @@ static int cedrus_s_ctrl(struct v4l2_ctrl *ctrl) struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + if (ctrl->id == V4L2_CID_STATELESS_HEVC_SPS) { + const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; + + ctx->bit_depth = max(sps->bit_depth_luma_minus8, + sps->bit_depth_chroma_minus8) + 8; + } + if (!vb2_is_busy(vq) && !vb2_is_streaming(vq)) cedrus_reset_cap_format(ctx); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 774fe8048ce3..522c184e2afc 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -119,6 +119,7 @@ struct cedrus_ctx { struct v4l2_pix_format src_fmt; struct v4l2_pix_format dst_fmt; struct cedrus_dec_ops *current_codec; + unsigned int bit_depth; struct v4l2_ctrl_handler hdl; struct v4l2_ctrl **ctrls; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index 5d3da50ce46a..fc9297232456 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -41,6 +41,19 @@ struct cedrus_h265_sram_pred_weight { __s8 offset; } __packed; +static unsigned int cedrus_h265_2bit_size(unsigned int width, + unsigned int height) +{ + /* + * Vendor library additionally aligns width and height to 16, + * but all capture formats are already aligned to that anyway, + * so we can skip that here. All formats are also one form of + * YUV 4:2:0 or another, so we can safely assume multiplication + * factor of 1.5. + */ + return ALIGN(width / 4, 32) * height * 3 / 2; +} + static enum cedrus_irq_status cedrus_h265_irq_status(struct cedrus_ctx *ctx) { struct cedrus_dev *dev = ctx->dev; @@ -802,6 +815,18 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) VE_DEC_H265_SRAM_OFFSET_PRED_WEIGHT_CHROMA_L1); } + if (ctx->bit_depth > 8) { + unsigned int stride = ALIGN(ctx->dst_fmt.width / 4, 32); + + reg = ctx->dst_fmt.sizeimage - + cedrus_h265_2bit_size(ctx->dst_fmt.width, + ctx->dst_fmt.height); + cedrus_write(dev, VE_DEC_H265_OFFSET_ADDR_FIRST_OUT, reg); + + reg = VE_DEC_H265_10BIT_CONFIGURE_FIRST_2BIT_STRIDE(stride); + cedrus_write(dev, VE_DEC_H265_10BIT_CONFIGURE, reg); + } + /* Enable appropriate interruptions. */ cedrus_write(dev, VE_DEC_H265_CTRL, VE_DEC_H265_CTRL_IRQ_MASK); @@ -874,6 +899,15 @@ static void cedrus_h265_trigger(struct cedrus_ctx *ctx) cedrus_write(dev, VE_DEC_H265_TRIGGER, VE_DEC_H265_TRIGGER_DEC_SLICE); } +static unsigned int cedrus_h265_extra_cap_size(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) +{ + if (ctx->bit_depth > 8) + return cedrus_h265_2bit_size(pix_fmt->width, pix_fmt->height); + + return 0; +} + struct cedrus_dec_ops cedrus_dec_ops_h265 = { .irq_clear = cedrus_h265_irq_clear, .irq_disable = cedrus_h265_irq_disable, @@ -882,4 +916,5 @@ struct cedrus_dec_ops cedrus_dec_ops_h265 = { .start = cedrus_h265_start, .stop = cedrus_h265_stop, .trigger = cedrus_h265_trigger, + .extra_cap_size = cedrus_h265_extra_cap_size, }; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h index 655c05b389cf..05e6cbc548ab 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h @@ -498,6 +498,22 @@ #define VE_DEC_H265_LOW_ADDR (VE_ENGINE_DEC_H265 + 0x80) +#define VE_DEC_H265_OFFSET_ADDR_FIRST_OUT (VE_ENGINE_DEC_H265 + 0x84) +#define VE_DEC_H265_OFFSET_ADDR_SECOND_OUT (VE_ENGINE_DEC_H265 + 0x88) + +#define VE_DEC_H265_SECOND_OUT_FMT_8BIT_PLUS_2BIT 0 +#define VE_DEC_H265_SECOND_OUT_FMT_P010 1 +#define VE_DEC_H265_SECOND_OUT_FMT_10BIT_4x4_TILED 2 + +#define VE_DEC_H265_10BIT_CONFIGURE_SECOND_OUT_FMT(v) \ + SHIFT_AND_MASK_BITS(v, 24, 23) +#define VE_DEC_H265_10BIT_CONFIGURE_SECOND_2BIT_ENABLE BIT(22) +#define VE_DEC_H265_10BIT_CONFIGURE_SECOND_2BIT_STRIDE(v) \ + SHIFT_AND_MASK_BITS(v, 21, 11) +#define VE_DEC_H265_10BIT_CONFIGURE_FIRST_2BIT_STRIDE(v) \ + SHIFT_AND_MASK_BITS(v, 10, 0) +#define VE_DEC_H265_10BIT_CONFIGURE (VE_ENGINE_DEC_H265 + 0x8c) + #define VE_DEC_H265_LOW_ADDR_PRIMARY_CHROMA(a) \ SHIFT_AND_MASK_BITS(a, 31, 24) #define VE_DEC_H265_LOW_ADDR_SECONDARY_CHROMA(a) \