Il 19/01/22 12:28, AngeloGioacchino Del Regno ha scritto:
Il 17/01/22 10:40, Yunfei Dong ha scritto:
Add support for VP9 decoding using the stateless API,
as supported by MT8192. And the drivers is lat and core architecture.

Signed-off-by: Yunfei Dong <[email protected]>
Signed-off-by: George Sun <[email protected]>
---
  drivers/media/platform/mtk-vcodec/Makefile    |    1 +
  .../mtk-vcodec/mtk_vcodec_dec_stateless.c     |   26 +-
  .../platform/mtk-vcodec/mtk_vcodec_drv.h      |    1 +
  .../mtk-vcodec/vdec/vdec_vp9_req_lat_if.c     | 1973 +++++++++++++++++
  .../media/platform/mtk-vcodec/vdec_drv_if.c   |    4 +
  .../media/platform/mtk-vcodec/vdec_drv_if.h   |    1 +
  6 files changed, 2003 insertions(+), 3 deletions(-)
  create mode 100644 
drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_req_lat_if.c


Hello Yunfei,
this driver is based on an older version of the VP9 stateless decoder uAPI,
hence this is not applicable upstream.

The latest linux-next tag (as of today) already contains the new and
accepted code; can you please rebase over that one?

Thanks,
Angelo

While finishing a rebase, I had time to do a fast port of this patch; in hopes
to spare you some time, I'm giving you my (fast) take at this.

Feel free to use it as you wish!


From 5f329ad271c94bf82d2dd12075372159466c28f9 Mon Sep 17 00:00:00 2001

From: AngeloGioacchino Del Regno <[email protected]>

Date: Wed, 19 Jan 2022 12:45:18 +0100

Subject: [PATCH] media: mtk-vcodec: Port VP9 stateless driver to upstream uAPI



This driver was written based on an old VP9 uAPI, but that code

changed over time: port this over the newest, and upstream accepted,

VP9 uAPI.



Signed-off-by: AngeloGioacchino Del Regno 
<[email protected]>

---

 .../mtk-vcodec/mtk_vcodec_dec_stateless.c     |  2 +-

 .../mtk-vcodec/vdec/vdec_vp9_req_lat_if.c     | 29 +++++++------------

 2 files changed, 12 insertions(+), 19 deletions(-)



diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c

index 26fd97d867e9..7f4baa39bf6c 100644

--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c

+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c

@@ -94,7 +94,7 @@ static const struct mtk_stateless_control mtk_stateless_controls[] = {

        },

        {

                .cfg = {

-                       .id = V4L2_CID_MPEG_VIDEO_VP9_FRAME_DECODE_PARAMS,

+                       .id = V4L2_CID_STATELESS_VP9_FRAME,

                        },

                .codec_type = V4L2_PIX_FMT_VP9_FRAME,

        },

diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_req_lat_if.c

index 92cd39f00840..8caf4f28db29 100644

--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_req_lat_if.c

+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_req_lat_if.c

@@ -711,7 +711,7 @@ static int vdec_vp9_slice_setup_lat_from_src_buf(struct vdec_vp9_slice_instance



 static void vdec_vp9_slice_setup_hdr(struct vdec_vp9_slice_instance *instance,

                                     struct vdec_vp9_slice_uncompressed_header 
*uh,

-                                    struct v4l2_ctrl_vp9_frame_decode_params 
*hdr)

+                                    struct v4l2_ctrl_vp9_frame *hdr)

 {

        int i;



@@ -749,13 +749,13 @@ static void vdec_vp9_slice_setup_hdr(struct vdec_vp9_slice_instance *instance,

         * - LAST_FRAME = 1,

         * - GOLDEN_FRAME = 2,

         * - ALTREF_FRAME = 3,

-        * ref_frame_sign_biases[INTRA_FRAME] is always 0

+        * ref_frame_sign_bias[INTRA_FRAME] is always 0

         * and VDA only passes another 3 directions

         */

        uh->ref_frame_sign_bias[0] = 0;

        for (i = 0; i < 3; i++)

                uh->ref_frame_sign_bias[i + 1] =

-                       !!(hdr->ref_frame_sign_biases & (1 << i));

+                       !!(hdr->ref_frame_sign_bias & (1 << i));

        uh->allow_high_precision_mv = HDR_FLAG(ALLOW_HIGH_PREC_MV);

        uh->interpolation_filter = hdr->interpolation_filter;

        uh->refresh_frame_context = HDR_FLAG(REFRESH_FRAME_CTX);

@@ -772,7 +772,7 @@ static void vdec_vp9_slice_setup_hdr(struct vdec_vp9_slice_instance *instance,



 static void vdec_vp9_slice_setup_frame_ctx(struct vdec_vp9_slice_instance 
*instance,

                                           struct 
vdec_vp9_slice_uncompressed_header *uh,

-                                          struct 
v4l2_ctrl_vp9_frame_decode_params *hdr)

+                                          struct v4l2_ctrl_vp9_frame *hdr)

 {

        int error_resilient_mode;

        int reset_frame_context;

@@ -857,7 +857,7 @@ static void vdec_vp9_slice_setup_segmentation(struct vdec_vp9_slice_uncompressed

 }



 static int vdec_vp9_slice_setup_tile(struct vdec_vp9_slice_vsi *vsi,

-                                    struct v4l2_ctrl_vp9_frame_decode_params 
*hdr)

+                                    struct v4l2_ctrl_vp9_frame *hdr)

 {

        unsigned int rows_log2;

        unsigned int cols_log2;

@@ -909,19 +909,10 @@ static void vdec_vp9_slice_setup_state(struct vdec_vp9_slice_vsi *vsi)

        memset(&vsi->state, 0, sizeof(vsi->state));

 }



-static void vdec_vp9_slice_setup_ref_idx(struct vdec_vp9_slice_pfc *pfc,

-                                        struct 
v4l2_ctrl_vp9_frame_decode_params *hdr)

-{

-       int i;

-

-       for (i = 0; i < 3; i++)

-               pfc->ref_idx[i] = hdr->refs[i];

-}

-

 static int vdec_vp9_slice_setup_pfc(struct vdec_vp9_slice_instance *instance,

                                    struct vdec_vp9_slice_pfc *pfc)

 {

-       struct v4l2_ctrl_vp9_frame_decode_params *hdr;

+       struct v4l2_ctrl_vp9_frame *hdr;

        struct vdec_vp9_slice_uncompressed_header *uh;

        struct v4l2_ctrl *hdr_ctrl;

        struct vdec_vp9_slice_vsi *vsi;

@@ -929,7 +920,7 @@ static int vdec_vp9_slice_setup_pfc(struct vdec_vp9_slice_instance *instance,



        /* frame header */

        hdr_ctrl = v4l2_ctrl_find(&instance->ctx->ctrl_hdl,

-                                 V4L2_CID_MPEG_VIDEO_VP9_FRAME_DECODE_PARAMS);

+                                 V4L2_CID_STATELESS_VP9_FRAME);

        if (!hdr_ctrl || !hdr_ctrl->p_cur.p)

                return -EINVAL;



@@ -949,7 +940,9 @@ static int vdec_vp9_slice_setup_pfc(struct vdec_vp9_slice_instance *instance,

        vdec_vp9_slice_setup_state(vsi);



        /* core stage needs buffer index to get ref y/c ... */

-       vdec_vp9_slice_setup_ref_idx(pfc, hdr);

+       pfc->ref_idx[0] = hdr->last_frame_ts;

+       pfc->ref_idx[1] = hdr->golden_frame_ts;

+       pfc->ref_idx[2] = hdr->alt_frame_ts;



        pfc->seq = instance->seq;

        instance->seq++;

@@ -1789,7 +1782,7 @@ static void vdec_vp9_slice_get_crop_info(struct vdec_vp9_slice_instance *instanc

                         cr->left, cr->top, cr->width, cr->height);

 }



-static int vdec_vp9_slice_get_param(void *h_vdec, vdec_get_param_type type, 
void *out)

+static int vdec_vp9_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out)

 {

        struct vdec_vp9_slice_instance *instance = h_vdec;



--

2.33.1

Reply via email to