From nobody Wed Jul 1 03:08:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC015C433F5 for ; Tue, 4 Jan 2022 07:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233391AbiADHi7 (ORCPT ); Tue, 4 Jan 2022 02:38:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiADHiy (ORCPT ); Tue, 4 Jan 2022 02:38:54 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB9CFC061761; Mon, 3 Jan 2022 23:38:53 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d353:5de8:6c9d:602a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id DED4E1F416F9; Tue, 4 Jan 2022 07:38:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1641281932; bh=27jKMgWeYwR8aVibrTCtYSknu0GLlBzN0y68vGHFqSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UsP3azh0JXkSM/HxX5C3ttJybNb1GBA2feHuu406N/TCvNDi42/T05Xy9uRXjxtEp PAhTne11bugJB7AH5+gWwDDfoBVGSsoE0nK9P6GRR9ieqPOzL7+4izv46oGlflKtTv v95JS9IRMc7v3vogdFkccNjFZtZgoShxhThsUhlBKNP0F2xUcSC6sZTtSIrUJ+2HiG 7zt/l4gcgergLpa5NAUVyvII13LEoKlV+m/ZnpeYckBC69px26lbgmTFTzoRtptlYX SQUqQ6GfAYccqn+8VnDJo8Ki9dgPexJpMA0V9vpx4w5fDOAQNpeJtX6EDHdNom4RKb U6bE5Qx2PrW+A== From: Benjamin Gaignard To: mchehab@kernel.org, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, jernej.skrabec@gmail.com, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v4 1/2] media: hevc: Remove RPS named flags Date: Tue, 4 Jan 2022 08:38:41 +0100 Message-Id: <20220104073842.1791639-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220104073842.1791639-1-benjamin.gaignard@collabora.com> References: <20220104073842.1791639-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Marking a picture as long-term reference is valid for DPB but not for RPS. Change flag name to match with it description in HEVC spec chapiter "8.3.2 Decoding process for reference picture set". Remove the other unused RPS flags. Signed-off-by: Benjamin Gaignard Reviewed-by: Ezequiel Garcia Reviewed-by: Jernej Skrabec --- version 4: - check flags with & and not =3D=3D Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 8 +++----- drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 2 +- include/media/hevc-ctrls.h | 6 ++---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Do= cumentation/userspace-api/media/v4l/ext-ctrls-codec.rst index e141f0e4eec9..38da33e61c3d 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -3166,11 +3166,9 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - :c:func:`v4l2_timeval_to_ns()` function to convert the struct :c:type:`timeval` in struct :c:type:`v4l2_buffer` to a __u64. * - __u8 - - ``rps`` - - The reference set for the reference frame - (V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_BEFORE, - V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_AFTER or - V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR) + - ``flags`` + - Long term flag for the reference frame + (V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE) * - __u8 - ``field_pic`` - Whether the reference is a field picture or a frame. diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/st= aging/media/hantro/hantro_g2_hevc_dec.c index 99d8ea7543da..14e0e6414100 100644 --- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c +++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c @@ -433,7 +433,7 @@ static int set_ref(struct hantro_ctx *ctx) chroma_addr =3D luma_addr + cr_offset; mv_addr =3D luma_addr + mv_offset; =20 - if (dpb[i].rps =3D=3D V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR) + if (dpb[i].flags & V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE) dpb_longterm_e |=3D BIT(V4L2_HEVC_DPB_ENTRIES_NUM_MAX - 1 - i); =20 hantro_write_addr(vpu, G2_REF_LUMA_ADDR(i), luma_addr); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/sta= ging/media/sunxi/cedrus/cedrus_h265.c index 8829a7bab07e..8ab2d9c6f048 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -169,7 +169,7 @@ static void cedrus_h265_ref_pic_list_write(struct cedru= s_dev *dev, unsigned int index =3D list[i]; u8 value =3D list[i]; =20 - if (dpb[index].rps =3D=3D V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR) + if (dpb[index].flags & V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE) value |=3D VE_DEC_H265_SRAM_REF_PIC_LIST_LT_REF; =20 /* Each SRAM word gathers up to 4 references. */ diff --git a/include/media/hevc-ctrls.h b/include/media/hevc-ctrls.h index ef63bc205756..01ccda48d8c5 100644 --- a/include/media/hevc-ctrls.h +++ b/include/media/hevc-ctrls.h @@ -127,15 +127,13 @@ struct v4l2_ctrl_hevc_pps { __u64 flags; }; =20 -#define V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_BEFORE 0x01 -#define V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_AFTER 0x02 -#define V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR 0x03 +#define V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE 0x01 =20 #define V4L2_HEVC_DPB_ENTRIES_NUM_MAX 16 =20 struct v4l2_hevc_dpb_entry { __u64 timestamp; - __u8 rps; + __u8 flags; __u8 field_pic; __u16 pic_order_cnt[2]; __u8 padding[2]; --=20 2.30.2 From nobody Wed Jul 1 03:08:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2153EC4332F for ; Tue, 4 Jan 2022 07:39:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233495AbiADHjB (ORCPT ); Tue, 4 Jan 2022 02:39:01 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:54368 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232649AbiADHiy (ORCPT ); Tue, 4 Jan 2022 02:38:54 -0500 Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d353:5de8:6c9d:602a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 6CD281F41F70; Tue, 4 Jan 2022 07:38:52 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1641281932; bh=SAi1ztXP7xeJzkfvtdO9T3ZNImLIw7Mi5FVGPlgxY34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ModcKljVmIsvVo2rGzp9vzjPiziRX7eN5+UF5OFmeXChLVWlMvH9c5NerZvmTpX1o DpfiejHMRJBGDfxkpZpkqnW8Idv/B7unQgJjxOyxXamGcYAr83ZVFPfr7ghUMGKR+K FarLORhy0yeT4QJWsK7hXCLaYDXicKR5m6MyZSDDVqgovWWg4JABibNOUhFgsPVikA NWlwJRxFXT3VD/7iPB3Nn4rAqghiN/PWZTey4YxVKzQZSfb2v/a4rCG1FYzcUNoX6+ zrElabH2EbYalM9SyOJgaa6Tt8bWUz0190QqTDFJ4KY9yA1FL/5H3tDS7FiHWZO6k6 IhiRtSoctrSFw== From: Benjamin Gaignard To: mchehab@kernel.org, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, jernej.skrabec@gmail.com, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v4 2/2] media: hevc: Embedded indexes in RPS Date: Tue, 4 Jan 2022 08:38:42 +0100 Message-Id: <20220104073842.1791639-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220104073842.1791639-1-benjamin.gaignard@collabora.com> References: <20220104073842.1791639-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Reference Picture Set lists provide indexes of short and long term reference in DBP array. Fix Hantro to not do a look up in DBP entries. Make documentation more clear about it. Signed-off-by: Benjamin Gaignard --- .../media/v4l/ext-ctrls-codec.rst | 6 ++--- .../staging/media/hantro/hantro_g2_hevc_dec.c | 25 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Do= cumentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 38da33e61c3d..b12ad5b3eaba 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -3381,15 +3381,15 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - * - __u8 - ``poc_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]`` - PocStCurrBefore as described in section 8.3.2 "Decoding process fo= r reference - picture set. + picture set": provides the index of the short term before referenc= es in DPB array. * - __u8 - ``poc_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]`` - PocStCurrAfter as described in section 8.3.2 "Decoding process for= reference - picture set. + picture set": provides the index of the short term after reference= s in DPB array. * - __u8 - ``poc_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]`` - PocLtCurr as described in section 8.3.2 "Decoding process for refe= rence - picture set. + picture set": provides the index of the long term references in DP= B array. * - __u64 - ``flags`` - See :ref:`Decode Parameters Flags ` diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/st= aging/media/hantro/hantro_g2_hevc_dec.c index 14e0e6414100..c524af41baf5 100644 --- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c +++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c @@ -255,24 +255,11 @@ static void set_params(struct hantro_ctx *ctx) hantro_reg_write(vpu, &g2_apf_threshold, 8); } =20 -static int find_ref_pic_index(const struct v4l2_hevc_dpb_entry *dpb, int p= ic_order_cnt) -{ - int i; - - for (i =3D 0; i < V4L2_HEVC_DPB_ENTRIES_NUM_MAX; i++) { - if (dpb[i].pic_order_cnt[0] =3D=3D pic_order_cnt) - return i; - } - - return 0x0; -} - static void set_ref_pic_list(struct hantro_ctx *ctx) { const struct hantro_hevc_dec_ctrls *ctrls =3D &ctx->hevc_dec.ctrls; struct hantro_dev *vpu =3D ctx->dev; const struct v4l2_ctrl_hevc_decode_params *decode_params =3D ctrls->decod= e_params; - const struct v4l2_hevc_dpb_entry *dpb =3D decode_params->dpb; u32 list0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] =3D {}; u32 list1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX] =3D {}; static const struct hantro_reg ref_pic_regs0[] =3D { @@ -316,11 +303,11 @@ static void set_ref_pic_list(struct hantro_ctx *ctx) /* List 0 contains: short term before, short term after and long term */ j =3D 0; for (i =3D 0; i < decode_params->num_poc_st_curr_before && j < ARRAY_SIZE= (list0); i++) - list0[j++] =3D find_ref_pic_index(dpb, decode_params->poc_st_curr_before= [i]); + list0[j++] =3D decode_params->poc_st_curr_before[i]; for (i =3D 0; i < decode_params->num_poc_st_curr_after && j < ARRAY_SIZE(= list0); i++) - list0[j++] =3D find_ref_pic_index(dpb, decode_params->poc_st_curr_after[= i]); + list0[j++] =3D decode_params->poc_st_curr_after[i]; for (i =3D 0; i < decode_params->num_poc_lt_curr && j < ARRAY_SIZE(list0)= ; i++) - list0[j++] =3D find_ref_pic_index(dpb, decode_params->poc_lt_curr[i]); + list0[j++] =3D decode_params->poc_lt_curr[i]; =20 /* Fill the list, copying over and over */ i =3D 0; @@ -329,11 +316,11 @@ static void set_ref_pic_list(struct hantro_ctx *ctx) =20 j =3D 0; for (i =3D 0; i < decode_params->num_poc_st_curr_after && j < ARRAY_SIZE(= list1); i++) - list1[j++] =3D find_ref_pic_index(dpb, decode_params->poc_st_curr_after[= i]); + list1[j++] =3D decode_params->poc_st_curr_after[i]; for (i =3D 0; i < decode_params->num_poc_st_curr_before && j < ARRAY_SIZE= (list1); i++) - list1[j++] =3D find_ref_pic_index(dpb, decode_params->poc_st_curr_before= [i]); + list1[j++] =3D decode_params->poc_st_curr_before[i]; for (i =3D 0; i < decode_params->num_poc_lt_curr && j < ARRAY_SIZE(list1)= ; i++) - list1[j++] =3D find_ref_pic_index(dpb, decode_params->poc_lt_curr[i]); + list1[j++] =3D decode_params->poc_lt_curr[i]; =20 i =3D 0; while (j < ARRAY_SIZE(list1)) --=20 2.30.2