From: Ezequiel Garcia <ezequiel@collabora.com> To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org Cc: Hans Verkuil <hverkuil@xs4all.nl>, Philipp Zabel <p.zabel@pengutronix.de>, Heiko Stuebner <heiko@sntech.de>, Alex Bee <knaerzche@gmail.com>, maccraft123mc@gmail.com, Chris Healy <cphealy@gmail.com>, Paul Kocialkowski <paul.kocialkowski@bootlin.com>, Jernej Skrabec <jernej.skrabec@gmail.com>, Jonas Karlman <jonas@kwiboo.se>, Rob Herring <robh+dt@kernel.org>, Nicolas Dufresne <nicolas.dufresne@collabora.com>, Kever Yang <kever.yang@rock-chips.com>, Ezequiel Garcia <ezequiel@collabora.com>, kernel@collabora.com Subject: [PATCH RESEND v2 05/10] media: hantro: h264: Move reference picture number to a helper Date: Mon, 19 Jul 2021 11:37:06 -0300 [thread overview] Message-ID: <20210719143711.55749-6-ezequiel@collabora.com> (raw) In-Reply-To: <20210719143711.55749-1-ezequiel@collabora.com> Add a hantro_h264_get_ref_nbr() helper function to get the reference picture numbers. This will be used by the Rockchip VDPU2 H.264 driver. This idea was originally proposed by Jonas Karlman in "[RFC 09/12] media: hantro: Refactor G1 H264 code" posted a while ago. Link: https://lore.kernel.org/linux-media/HE1PR06MB401165F2BA0AD8A634FDFAF2ACBF0@HE1PR06MB4011.eurprd06.prod.outlook.com/ Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Tested-by: Alex Bee <knaerzche@gmail.com> --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 14 ++------------ drivers/staging/media/hantro/hantro_h264.c | 11 +++++++++++ drivers/staging/media/hantro/hantro_hw.h | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index 6faacfc44c7c..236ce24ca00c 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -126,7 +126,6 @@ static void set_params(struct hantro_ctx *ctx, struct vb2_v4l2_buffer *src_buf) static void set_ref(struct hantro_ctx *ctx) { - struct v4l2_h264_dpb_entry *dpb = ctx->h264_dec.dpb; const u8 *b0_reflist, *b1_reflist, *p_reflist; struct hantro_dev *vpu = ctx->dev; int reg_num; @@ -143,17 +142,8 @@ static void set_ref(struct hantro_ctx *ctx) * subsequential reference pictures. */ for (i = 0; i < HANTRO_H264_DPB_SIZE; i += 2) { - reg = 0; - if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) - reg |= G1_REG_REF_PIC_REFER0_NBR(dpb[i].pic_num); - else - reg |= G1_REG_REF_PIC_REFER0_NBR(dpb[i].frame_num); - - if (dpb[i + 1].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) - reg |= G1_REG_REF_PIC_REFER1_NBR(dpb[i + 1].pic_num); - else - reg |= G1_REG_REF_PIC_REFER1_NBR(dpb[i + 1].frame_num); - + reg = G1_REG_REF_PIC_REFER0_NBR(hantro_h264_get_ref_nbr(ctx, i)) | + G1_REG_REF_PIC_REFER1_NBR(hantro_h264_get_ref_nbr(ctx, i + 1)); vdpu_write_relaxed(vpu, reg, G1_REG_REF_PIC(i / 2)); } diff --git a/drivers/staging/media/hantro/hantro_h264.c b/drivers/staging/media/hantro/hantro_h264.c index 6d72136760e7..0b4d2491be3b 100644 --- a/drivers/staging/media/hantro/hantro_h264.c +++ b/drivers/staging/media/hantro/hantro_h264.c @@ -348,6 +348,17 @@ dma_addr_t hantro_h264_get_ref_buf(struct hantro_ctx *ctx, return dma_addr; } +u16 hantro_h264_get_ref_nbr(struct hantro_ctx *ctx, unsigned int dpb_idx) +{ + const struct v4l2_h264_dpb_entry *dpb = &ctx->h264_dec.dpb[dpb_idx]; + + if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) + return 0; + if (dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) + return dpb->pic_num; + return dpb->frame_num; +} + int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx) { struct hantro_h264_dec_hw_ctx *h264_ctx = &ctx->h264_dec; diff --git a/drivers/staging/media/hantro/hantro_hw.h b/drivers/staging/media/hantro/hantro_hw.h index ce678fedaad6..7a8048afe357 100644 --- a/drivers/staging/media/hantro/hantro_hw.h +++ b/drivers/staging/media/hantro/hantro_hw.h @@ -238,6 +238,8 @@ void hantro_jpeg_enc_done(struct hantro_ctx *ctx); dma_addr_t hantro_h264_get_ref_buf(struct hantro_ctx *ctx, unsigned int dpb_idx); +u16 hantro_h264_get_ref_nbr(struct hantro_ctx *ctx, + unsigned int dpb_idx); int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx); int hantro_g1_h264_dec_run(struct hantro_ctx *ctx); int hantro_h264_dec_init(struct hantro_ctx *ctx); -- 2.32.0
WARNING: multiple messages have this Message-ID (diff)
From: Ezequiel Garcia <ezequiel@collabora.com> To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org Cc: Hans Verkuil <hverkuil@xs4all.nl>, Philipp Zabel <p.zabel@pengutronix.de>, Heiko Stuebner <heiko@sntech.de>, Alex Bee <knaerzche@gmail.com>, maccraft123mc@gmail.com, Chris Healy <cphealy@gmail.com>, Paul Kocialkowski <paul.kocialkowski@bootlin.com>, Jernej Skrabec <jernej.skrabec@gmail.com>, Jonas Karlman <jonas@kwiboo.se>, Rob Herring <robh+dt@kernel.org>, Nicolas Dufresne <nicolas.dufresne@collabora.com>, Kever Yang <kever.yang@rock-chips.com>, Ezequiel Garcia <ezequiel@collabora.com>, kernel@collabora.com Subject: [PATCH RESEND v2 05/10] media: hantro: h264: Move reference picture number to a helper Date: Mon, 19 Jul 2021 11:37:06 -0300 [thread overview] Message-ID: <20210719143711.55749-6-ezequiel@collabora.com> (raw) In-Reply-To: <20210719143711.55749-1-ezequiel@collabora.com> Add a hantro_h264_get_ref_nbr() helper function to get the reference picture numbers. This will be used by the Rockchip VDPU2 H.264 driver. This idea was originally proposed by Jonas Karlman in "[RFC 09/12] media: hantro: Refactor G1 H264 code" posted a while ago. Link: https://lore.kernel.org/linux-media/HE1PR06MB401165F2BA0AD8A634FDFAF2ACBF0@HE1PR06MB4011.eurprd06.prod.outlook.com/ Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Tested-by: Alex Bee <knaerzche@gmail.com> --- drivers/staging/media/hantro/hantro_g1_h264_dec.c | 14 ++------------ drivers/staging/media/hantro/hantro_h264.c | 11 +++++++++++ drivers/staging/media/hantro/hantro_hw.h | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c index 6faacfc44c7c..236ce24ca00c 100644 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c @@ -126,7 +126,6 @@ static void set_params(struct hantro_ctx *ctx, struct vb2_v4l2_buffer *src_buf) static void set_ref(struct hantro_ctx *ctx) { - struct v4l2_h264_dpb_entry *dpb = ctx->h264_dec.dpb; const u8 *b0_reflist, *b1_reflist, *p_reflist; struct hantro_dev *vpu = ctx->dev; int reg_num; @@ -143,17 +142,8 @@ static void set_ref(struct hantro_ctx *ctx) * subsequential reference pictures. */ for (i = 0; i < HANTRO_H264_DPB_SIZE; i += 2) { - reg = 0; - if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) - reg |= G1_REG_REF_PIC_REFER0_NBR(dpb[i].pic_num); - else - reg |= G1_REG_REF_PIC_REFER0_NBR(dpb[i].frame_num); - - if (dpb[i + 1].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) - reg |= G1_REG_REF_PIC_REFER1_NBR(dpb[i + 1].pic_num); - else - reg |= G1_REG_REF_PIC_REFER1_NBR(dpb[i + 1].frame_num); - + reg = G1_REG_REF_PIC_REFER0_NBR(hantro_h264_get_ref_nbr(ctx, i)) | + G1_REG_REF_PIC_REFER1_NBR(hantro_h264_get_ref_nbr(ctx, i + 1)); vdpu_write_relaxed(vpu, reg, G1_REG_REF_PIC(i / 2)); } diff --git a/drivers/staging/media/hantro/hantro_h264.c b/drivers/staging/media/hantro/hantro_h264.c index 6d72136760e7..0b4d2491be3b 100644 --- a/drivers/staging/media/hantro/hantro_h264.c +++ b/drivers/staging/media/hantro/hantro_h264.c @@ -348,6 +348,17 @@ dma_addr_t hantro_h264_get_ref_buf(struct hantro_ctx *ctx, return dma_addr; } +u16 hantro_h264_get_ref_nbr(struct hantro_ctx *ctx, unsigned int dpb_idx) +{ + const struct v4l2_h264_dpb_entry *dpb = &ctx->h264_dec.dpb[dpb_idx]; + + if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) + return 0; + if (dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) + return dpb->pic_num; + return dpb->frame_num; +} + int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx) { struct hantro_h264_dec_hw_ctx *h264_ctx = &ctx->h264_dec; diff --git a/drivers/staging/media/hantro/hantro_hw.h b/drivers/staging/media/hantro/hantro_hw.h index ce678fedaad6..7a8048afe357 100644 --- a/drivers/staging/media/hantro/hantro_hw.h +++ b/drivers/staging/media/hantro/hantro_hw.h @@ -238,6 +238,8 @@ void hantro_jpeg_enc_done(struct hantro_ctx *ctx); dma_addr_t hantro_h264_get_ref_buf(struct hantro_ctx *ctx, unsigned int dpb_idx); +u16 hantro_h264_get_ref_nbr(struct hantro_ctx *ctx, + unsigned int dpb_idx); int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx); int hantro_g1_h264_dec_run(struct hantro_ctx *ctx); int hantro_h264_dec_init(struct hantro_ctx *ctx); -- 2.32.0 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2021-07-19 14:38 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-19 14:37 [PATCH RESEND v2 00/10] hantro: Enable H.264 VDPU2 Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 01/10] hantro: vp8: Move noisy WARN_ON to vpu_debug Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 02/10] hantro: Make struct hantro_variant.init() optional Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 03/10] media: hantro: Avoid redundant hantro_get_{dst,src}_buf() calls Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 03/10] media: hantro: Avoid redundant hantro_get_{dst, src}_buf() calls Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 04/10] media: hantro: h264: Move DPB valid and long-term bitmaps Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia [this message] 2021-07-19 14:37 ` [PATCH RESEND v2 05/10] media: hantro: h264: Move reference picture number to a helper Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 06/10] media: hantro: Add H.264 support for Rockchip VDPU2 Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 07/10] media: hantro: Enable H.264 on " Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 08/10] media: hantro: Add support for the Rockchip PX30 Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 09/10] dt-bindings: media: rockchip-vpu: Add PX30 compatible Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia 2021-07-19 14:37 ` [PATCH RESEND v2 10/10] arm64: dts: rockchip: Add VPU support for the PX30 Ezequiel Garcia 2021-07-19 14:37 ` Ezequiel Garcia
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=20210719143711.55749-6-ezequiel@collabora.com \ --to=ezequiel@collabora.com \ --cc=cphealy@gmail.com \ --cc=devicetree@vger.kernel.org \ --cc=heiko@sntech.de \ --cc=hverkuil@xs4all.nl \ --cc=jernej.skrabec@gmail.com \ --cc=jonas@kwiboo.se \ --cc=kernel@collabora.com \ --cc=kever.yang@rock-chips.com \ --cc=knaerzche@gmail.com \ --cc=linux-media@vger.kernel.org \ --cc=linux-rockchip@lists.infradead.org \ --cc=maccraft123mc@gmail.com \ --cc=nicolas.dufresne@collabora.com \ --cc=p.zabel@pengutronix.de \ --cc=paul.kocialkowski@bootlin.com \ --cc=robh+dt@kernel.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.