From mboxrd@z Thu Jan 1 00:00:00 1970 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 43176CCF9E2 for ; Wed, 22 Oct 2025 16:26: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=mdyhipllybbFu+l8G6CQc5yKFQTnr4hZ2nhd5ws/U/U=; b=1Ci2PF846HXVIZ UsaAcDYVP3NXofCjRnFu7FkzktpryV/bRDWGGcZzOTpxinmtum32trazTRxWd9kQfGvg57fAM+6ee 1iFmryzMG1xznMfdCsxVOC3KaDqYD3iYrKVWzLnQtuVW/pCKZz4mlfMurE/XNm53B5uCmPoe7jTK5 6Rgns6IKDawVOitpowCUFPv85sWNWFOSIEwb0sNjwq+GfSW+Eb5eYw7XezlU2lrx4dyzF3X7hHFbC KDWpCOVmH2MtlMLPmvvvxb4osChfbvhoDPqgispWwVLMvSnlEygwD8BQQSRPwGbZCq5aThfBw3A8z eLjW6wRWJXuGXEBGxZGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vBbfB-00000003Z4q-49vp; Wed, 22 Oct 2025 16:26:14 +0000 Received: from bali.collaboradmins.com ([148.251.105.195]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vBbes-00000003Yce-47Gf; Wed, 22 Oct 2025 16:25:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1761150352; bh=5XepCE8oQ4CfIylcFNZHUx5cQS3sUUTvzh5DlZ/N4/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0t+K76hJcGBebSmfvjK9UEbNi++7UBmpAvQW/+8AF78GkTIhMMq6StOEC7V/evEZ xw/KvtT/owMWWVqWo6zwoBZgd9Dc27m2niz1y5H6AIZPayww+e5zFjiAZZPGlBWgMN Xb1JyLyvPKqFiIaT3FLAmI5JMhMO1F0lJ432D3OGxUriIUZ6k8+qi2O+Zk8gyP9EGr AhDXukGy1Ara2VyuZK9ExXGjLC83Bp2k/w8kpNouLnqI0Ioc+o+O0rVR8aGQ4wKsgG 2gEUg3h1C+Sx8qNzhqo82DXpCRsYP28f/jY95xnIgYv07m14tzDF0X1LBIOK7hKzj2 BMJVcJMxrW+MQ== Received: from trenzalore (unknown [23.233.251.139]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by bali.collaboradmins.com (Postfix) with ESMTPSA id 1B90E17E108C; Wed, 22 Oct 2025 18:25:50 +0200 (CEST) From: Detlev Casanova To: linux-kernel@vger.kernel.org Cc: Mauro Carvalho Chehab , Detlev Casanova , Ezequiel Garcia , Heiko Stuebner , Ricardo Ribalda , Hans Verkuil , Hans de Goede , Yunke Cao , Jonathan Corbet , Laurent Pinchart , Sakari Ailus , James Cowgill , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Nicolas Dufresne , Diederik de Haas Subject: [PATCH v3 08/15] media: rkvdec: Add generic configuration for variants Date: Wed, 22 Oct 2025 12:22:07 -0400 Message-ID: <20251022162459.271603-9-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.51.1.dirty In-Reply-To: <20251022162459.271603-1-detlev.casanova@collabora.com> References: <20251022162459.271603-1-detlev.casanova@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251022_092555_293292_B0AFFC1B X-CRM114-Status: GOOD ( 16.55 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org This is to prepare for adding new versions of the decoder and support specific formats and ops per version. Different rkvdec_variant instances will be able to share generic decoder configs. Tested-by: Diederik de Haas # Rock 5B Signed-off-by: Detlev Casanova --- .../media/platform/rockchip/rkvdec/rkvdec.c | 37 ++++++++++++------- .../media/platform/rockchip/rkvdec/rkvdec.h | 6 +++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c index 776149f871b0..a7af1e3fdebd 100644 --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c @@ -373,15 +373,16 @@ static bool rkvdec_is_capable(struct rkvdec_ctx *ctx, unsigned int capability) static const struct rkvdec_coded_fmt_desc * rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index) { + const struct rkvdec_config *cfg = ctx->dev->variant->config; int fmt_idx = -1; unsigned int i; - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { - if (!rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) + for (i = 0; i < cfg->coded_fmts_num; i++) { + if (!rkvdec_is_capable(ctx, cfg->coded_fmts[i].capability)) continue; fmt_idx++; if (index == fmt_idx) - return &rkvdec_coded_fmts[i]; + return &cfg->coded_fmts[i]; } return NULL; @@ -390,12 +391,13 @@ rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index) static const struct rkvdec_coded_fmt_desc * rkvdec_find_coded_fmt_desc(struct rkvdec_ctx *ctx, u32 fourcc) { + const struct rkvdec_config *cfg = ctx->dev->variant->config; unsigned int i; - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { - if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability) && - rkvdec_coded_fmts[i].fourcc == fourcc) - return &rkvdec_coded_fmts[i]; + for (i = 0; i < cfg->coded_fmts_num; i++) { + if (rkvdec_is_capable(ctx, cfg->coded_fmts[i].capability) && + cfg->coded_fmts[i].fourcc == fourcc) + return &cfg->coded_fmts[i]; } return NULL; @@ -1014,18 +1016,19 @@ static int rkvdec_add_ctrls(struct rkvdec_ctx *ctx, static int rkvdec_init_ctrls(struct rkvdec_ctx *ctx) { + const struct rkvdec_config *cfg = ctx->dev->variant->config; unsigned int i, nctrls = 0; int ret; - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) - if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) - nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls; + for (i = 0; i < cfg->coded_fmts_num; i++) + if (rkvdec_is_capable(ctx, cfg->coded_fmts[i].capability)) + nctrls += cfg->coded_fmts[i].ctrls->num_ctrls; v4l2_ctrl_handler_init(&ctx->ctrl_hdl, nctrls); - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { - if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) { - ret = rkvdec_add_ctrls(ctx, rkvdec_coded_fmts[i].ctrls); + for (i = 0; i < cfg->coded_fmts_num; i++) { + if (rkvdec_is_capable(ctx, cfg->coded_fmts[i].capability)) { + ret = rkvdec_add_ctrls(ctx, cfg->coded_fmts[i].ctrls); if (ret) goto err_free_handler; } @@ -1240,13 +1243,20 @@ static void rkvdec_watchdog_func(struct work_struct *work) } } +static const struct rkvdec_config config_rkvdec = { + .coded_fmts = rkvdec_coded_fmts, + .coded_fmts_num = ARRAY_SIZE(rkvdec_coded_fmts), +}; + static const struct rkvdec_variant rk3288_rkvdec_variant = { .num_regs = 68, + .config = &config_rkvdec, .capabilities = RKVDEC_CAPABILITY_HEVC, }; static const struct rkvdec_variant rk3328_rkvdec_variant = { .num_regs = 109, + .config = &config_rkvdec, .capabilities = RKVDEC_CAPABILITY_HEVC | RKVDEC_CAPABILITY_H264 | RKVDEC_CAPABILITY_VP9, @@ -1255,6 +1265,7 @@ static const struct rkvdec_variant rk3328_rkvdec_variant = { static const struct rkvdec_variant rk3399_rkvdec_variant = { .num_regs = 78, + .config = &config_rkvdec, .capabilities = RKVDEC_CAPABILITY_HEVC | RKVDEC_CAPABILITY_H264 | RKVDEC_CAPABILITY_VP9, diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.h b/drivers/media/platform/rockchip/rkvdec/rkvdec.h index f35f6e80ea2e..3b1cc511412e 100644 --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.h +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.h @@ -71,6 +71,7 @@ vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf) struct rkvdec_variant { unsigned int num_regs; + const struct rkvdec_config *config; unsigned int capabilities; unsigned int quirks; }; @@ -113,6 +114,11 @@ struct rkvdec_coded_fmt_desc { unsigned int capability; }; +struct rkvdec_config { + const struct rkvdec_coded_fmt_desc *coded_fmts; + size_t coded_fmts_num; +}; + struct rkvdec_dev { struct v4l2_device v4l2_dev; struct media_device mdev; -- 2.51.1.dirty _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip