mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benjamin Gaignard <benjamin.gaignard@collabora.com>
To: nicolas.dufresne@collabora.com, p.zabel@pengutronix.de,
	mchehab@kernel.org, heiko@sntech.de, hverkuil@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, kernel@collabora.com,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>
Subject: [PATCH v9 2/4] media: verisilicon: Use V4L2_AV1_PRIMARY_REF_NONE and V4L2_AV1_REF_FRAME_INVALID
Date: Wed, 25 Nov 2026 13:28:23 +0100	[thread overview]
Message-ID: <20261125122825.236422-3-benjamin.gaignard@collabora.com> (raw)
In-Reply-To: <20261125122825.236422-1-benjamin.gaignard@collabora.com>

Use V4L2_AV1_PRIMARY_REF_NONE and V4L2_AV1_REF_FRAME_INVALID instead
of local definition.
Since ref_frame_idx[] values have been checked inside v4l2-ctrl-core.c
remove the useless duplicate check.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
changes in v9:
- Split core changes and drivers changes
- Use V4L2_AV1_REF_FRAME_INVALID

 .../verisilicon/rockchip_vpu981_hw_av1_dec.c       | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
index 2a145433e6d1..087a944b3394 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
@@ -18,9 +18,7 @@
 #define AV1_TILE_INFO_SIZE	(AV1_MAX_TILES * 16)
 #define AV1DEC_MAX_PIC_BUFFERS	24
 #define AV1_REF_SCALE_SHIFT	14
-#define AV1_INVALID_IDX		-1
 #define MAX_FRAME_DISTANCE	31
-#define AV1_PRIMARY_REF_NONE	7
 #define AV1_TILE_SIZE		ALIGN(32 * 128, 4096)
 /*
  * These 3 values aren't defined enum v4l2_av1_segment_feature because
@@ -123,8 +121,8 @@ static int rockchip_vpu981_get_frame_index(struct hantro_ctx *ctx, int ref)
 	u64 timestamp;
 	int i, idx = frame->ref_frame_idx[ref];
 
-	if (idx >= V4L2_AV1_TOTAL_REFS_PER_FRAME || idx < 0)
-		return AV1_INVALID_IDX;
+	if (idx < 0)
+		return V4L2_AV1_REF_FRAME_INVALID;
 
 	timestamp = frame->reference_frame_ts[idx];
 	for (i = 0; i < AV1_MAX_FRAME_BUF_COUNT; i++) {
@@ -134,7 +132,7 @@ static int rockchip_vpu981_get_frame_index(struct hantro_ctx *ctx, int ref)
 			return i;
 	}
 
-	return AV1_INVALID_IDX;
+	return V4L2_AV1_REF_FRAME_INVALID;
 }
 
 static int rockchip_vpu981_get_order_hint(struct hantro_ctx *ctx, int ref)
@@ -142,7 +140,7 @@ static int rockchip_vpu981_get_order_hint(struct hantro_ctx *ctx, int ref)
 	struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
 	int idx = rockchip_vpu981_get_frame_index(ctx, ref);
 
-	if (idx != AV1_INVALID_IDX)
+	if (idx != V4L2_AV1_REF_FRAME_INVALID)
 		return av1_dec->frame_refs[idx].order_hint;
 
 	return 0;
@@ -179,7 +177,7 @@ static int rockchip_vpu981_av1_dec_frame_ref(struct hantro_ctx *ctx,
 		return i;
 	}
 
-	return AV1_INVALID_IDX;
+	return V4L2_AV1_REF_FRAME_INVALID;
 }
 
 static void rockchip_vpu981_av1_dec_frame_unref(struct hantro_ctx *ctx, int idx)
@@ -1256,7 +1254,7 @@ static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx)
 	bool frame_is_intra = IS_INTRA(frame->frame_type);
 
 	if (error_resilient_mode || frame_is_intra ||
-	    frame->primary_ref_frame == AV1_PRIMARY_REF_NONE) {
+	    frame->primary_ref_frame == V4L2_AV1_PRIMARY_REF_NONE) {
 		av1_dec->cdfs = &av1_dec->default_cdfs;
 		av1_dec->cdfs_ndvc = &av1_dec->default_cdfs_ndvc;
 		rockchip_av1_default_coeff_probs(quantization->base_q_idx,
-- 
2.53.0


  parent reply	other threads:[~2026-11-25 12:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 12:28 [PATCH v9 0/4] media: verisilicon: Create AV1 helper library Benjamin Gaignard
2026-11-25 12:28 ` [PATCH v9 1/4] media: v4l2-ctrls: validate AV1 reference frame index Benjamin Gaignard
2026-11-25 12:28 ` Benjamin Gaignard [this message]
2026-11-25 12:28 ` [PATCH v9 3/4] media: verisilicon: AV1: Fix luma size Benjamin Gaignard
2026-11-25 12:28 ` [PATCH v9 4/4] media: verisilicon: Create AV1 helper library Benjamin Gaignard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125122825.236422-3-benjamin.gaignard@collabora.com \
    --to=benjamin.gaignard@collabora.com \
    --cc=heiko@sntech.de \
    --cc=hverkuil@kernel.org \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®