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 6CB71CCD193 for ; Thu, 23 Oct 2025 19:36: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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YfiprKHjKj0+twR1hprY/ZTLVOP3wjMLYRVbKKhejq4=; b=UQ8aojp552Kj0M YCc9XHqYs9gLT3wVpl8Z2YF8Ihob0LKc3JF7Eo+VQnqcPiTkXG1RfO2GHbc7u/tcZ6Ry/ECgQAos3 maB0vMVx3mMk8JQikCE2rtTMIS0K9O7odHsyFcmgP4czVvv1l05eYrhM7ndeN9GF8Gjw9C3IlHxEr VkNmJOSk+pYk9N6IDYxalNxiDn0kqRRaCtRJjXDAPbGH7eE0ck2RKqW0frUD0qQzSo0nIqQYWYkb/ 6UVP5UDRllqPaRQKNXH1xQUftuSFvLltIKZJ+NAv4rAaGAYy3Dj9mKQi+SzVZDg2dbketHaf9F/2P 6yVrQERwKUkuODsvd/0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vC16C-00000007Nlf-1WDg; Thu, 23 Oct 2025 19:35:48 +0000 Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vC168-00000007Nl2-3sZQ; Thu, 23 Oct 2025 19:35:46 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1761248119; cv=none; d=zohomail.com; s=zohoarc; b=nv18uc+SyKl+K8SnLLTWpAq0fbUpluuoZJju1MeUj+H/X9bt51/ldBG63PC0/4u4BK/AzaRiCVKegxqnTYGFW6sgeQcO1qcz6nhGgc6/R2rg2MbmYPWuHPDHOjh7RHokXe5zoZF+wi84/s/4JuRd/ojvFfJ82tSfefflm5xe3C8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761248119; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=DoBeKc7k0tI/KT6rIVYw1QPBdWN+Yb/dqCkvda7xnq8=; b=lIKNEcyDva8gdJAeAtbnSr/3vdRnFgxZVz6Fxl5YVBbwLbulKabzGV8LWLUs0pEl64356H4Si+9zoI0J/j5KTR9ke9eCcQd+2lW4Pqy7FRMiUVc1JsfF4P+GMVwzq0oTQcAnflvVagNQggc4e/QbKq3UDPHmVJ10B4w8sUgcwd8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=detlev.casanova@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1761248119; s=zohomail; d=collabora.com; i=detlev.casanova@collabora.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=DoBeKc7k0tI/KT6rIVYw1QPBdWN+Yb/dqCkvda7xnq8=; b=eInEvmGEiPpCIw5+BSGE1S4LGFduLUjAMMsmQ9bPV9BCl8tZTEOEpuqUYqFl882L okc8uQUclwD6wSqoR3A36tguk0pR/Owy6MJITrvJBgDWM7nl3k6Gd7aGURHkscaBiqM FxT3cyYl3kxs/z2kGWsxqmU1+78vg8YhA3f+HIHI= Received: by mx.zohomail.com with SMTPS id 1761248113921586.062025324594; Thu, 23 Oct 2025 12:35:13 -0700 (PDT) Message-ID: <174217e1-2ec5-42fe-bdc8-57b8a5f943c1@collabora.com> Date: Thu, 23 Oct 2025 15:35:11 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 08/15] media: rkvdec: Add generic configuration for variants To: Jonas Karlman Cc: Mauro Carvalho Chehab , 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 , linux-kernel@vger.kernel.org References: <20251022174508.284929-1-detlev.casanova@collabora.com> <20251022174508.284929-9-detlev.casanova@collabora.com> <5d2f3b9c-3d1a-47a5-93f1-1a6d6ce540f3@kwiboo.se> Content-Language: en-US From: Detlev Casanova In-Reply-To: <5d2f3b9c-3d1a-47a5-93f1-1a6d6ce540f3@kwiboo.se> X-ZohoMailClient: External X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251023_123545_000054_898513CA X-CRM114-Status: GOOD ( 23.30 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Hi Jonas, On 10/22/25 16:57, Jonas Karlman wrote: > Hi Detlev, > > On 10/22/2025 7:45 PM, Detlev Casanova wrote: >> 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; >> +}; > Do we really need a separate config struct? This chould/should me merged > with the variant struct. > > Using a two layer variant/config mostly seem to complicate things based > on an initial review. I've been wondering about that and decided to go this way because multiple variants could use a common config and this makes less copy/paste. But I think you are right, it does complicate things unnecessarily, I'd rather see all variants with all their parameters directly. I'll change that :) > Regards, > Jonas > >> + >> struct rkvdec_dev { >> struct v4l2_device v4l2_dev; >> struct media_device mdev; > > _______________________________________________ > Linux-rockchip mailing list > Linux-rockchip@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-rockchip _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip