Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: hantro: postproc: Introduce struct hantro_postproc_ops

Turns out the post-processor block on the G2 core is substantially
different from the one on the G1 core. Introduce hantro_postproc_ops
with .enable and .disable methods, which will allow to support
the G2 post-processor cleanly.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Ezequiel Garcia and committed by
Mauro Carvalho Chehab
04dad52e 9393761a

+45 -18
+3 -2
drivers/staging/media/hantro/hantro.h
··· 28 28 29 29 struct hantro_ctx; 30 30 struct hantro_codec_ops; 31 + struct hantro_postproc_ops; 31 32 32 33 #define HANTRO_JPEG_ENCODER BIT(0) 33 34 #define HANTRO_ENCODERS 0x0000ffff ··· 60 59 * @num_dec_fmts: Number of decoder formats. 61 60 * @postproc_fmts: Post-processor formats. 62 61 * @num_postproc_fmts: Number of post-processor formats. 62 + * @postproc_ops: Post-processor ops. 63 63 * @codec: Supported codecs 64 64 * @codec_ops: Codec ops. 65 65 * @init: Initialize hardware, optional. ··· 71 69 * @num_clocks: number of clocks in the array 72 70 * @reg_names: array of register range names 73 71 * @num_regs: number of register range names in the array 74 - * @postproc_regs: &struct hantro_postproc_regs pointer 75 72 */ 76 73 struct hantro_variant { 77 74 unsigned int enc_offset; ··· 81 80 unsigned int num_dec_fmts; 82 81 const struct hantro_fmt *postproc_fmts; 83 82 unsigned int num_postproc_fmts; 83 + const struct hantro_postproc_ops *postproc_ops; 84 84 unsigned int codec; 85 85 const struct hantro_codec_ops *codec_ops; 86 86 int (*init)(struct hantro_dev *vpu); ··· 92 90 int num_clocks; 93 91 const char * const *reg_names; 94 92 int num_regs; 95 - const struct hantro_postproc_regs *postproc_regs; 96 93 }; 97 94 98 95 /**
+12 -1
drivers/staging/media/hantro/hantro_hw.h
··· 175 175 }; 176 176 177 177 /** 178 + * struct hantro_postproc_ops - post-processor operations 179 + * 180 + * @enable: Enable the post-processor block. Optional. 181 + * @disable: Disable the post-processor block. Optional. 182 + */ 183 + struct hantro_postproc_ops { 184 + void (*enable)(struct hantro_ctx *ctx); 185 + void (*disable)(struct hantro_ctx *ctx); 186 + }; 187 + 188 + /** 178 189 * struct hantro_codec_ops - codec mode specific operations 179 190 * 180 191 * @init: If needed, can be used for initialization. ··· 232 221 extern const struct hantro_variant rk3399_vpu_variant; 233 222 extern const struct hantro_variant sama5d4_vdec_variant; 234 223 235 - extern const struct hantro_postproc_regs hantro_g1_postproc_regs; 224 + extern const struct hantro_postproc_ops hantro_g1_postproc_ops; 236 225 237 226 extern const u32 hantro_vp8_dec_mc_filter[8][6]; 238 227
+25 -10
drivers/staging/media/hantro/hantro_postproc.c
··· 15 15 #define HANTRO_PP_REG_WRITE(vpu, reg_name, val) \ 16 16 { \ 17 17 hantro_reg_write(vpu, \ 18 - &(vpu)->variant->postproc_regs->reg_name, \ 18 + &hantro_g1_postproc_regs.reg_name, \ 19 19 val); \ 20 20 } 21 21 22 22 #define HANTRO_PP_REG_WRITE_S(vpu, reg_name, val) \ 23 23 { \ 24 24 hantro_reg_write_s(vpu, \ 25 - &(vpu)->variant->postproc_regs->reg_name, \ 25 + &hantro_g1_postproc_regs.reg_name, \ 26 26 val); \ 27 27 } 28 28 ··· 64 64 return fmt->fourcc != V4L2_PIX_FMT_NV12; 65 65 } 66 66 67 - void hantro_postproc_enable(struct hantro_ctx *ctx) 67 + static void hantro_postproc_g1_enable(struct hantro_ctx *ctx) 68 68 { 69 69 struct hantro_dev *vpu = ctx->dev; 70 70 struct vb2_v4l2_buffer *dst_buf; 71 71 u32 src_pp_fmt, dst_pp_fmt; 72 72 dma_addr_t dst_dma; 73 - 74 - if (!vpu->variant->postproc_regs) 75 - return; 76 73 77 74 /* Turn on pipeline mode. Must be done first. */ 78 75 HANTRO_PP_REG_WRITE_S(vpu, pipeline_en, 0x1); ··· 151 154 return 0; 152 155 } 153 156 157 + static void hantro_postproc_g1_disable(struct hantro_ctx *ctx) 158 + { 159 + struct hantro_dev *vpu = ctx->dev; 160 + 161 + HANTRO_PP_REG_WRITE_S(vpu, pipeline_en, 0x0); 162 + } 163 + 154 164 void hantro_postproc_disable(struct hantro_ctx *ctx) 155 165 { 156 166 struct hantro_dev *vpu = ctx->dev; 157 167 158 - if (!vpu->variant->postproc_regs) 159 - return; 160 - 161 - HANTRO_PP_REG_WRITE_S(vpu, pipeline_en, 0x0); 168 + if (vpu->variant->postproc_ops && vpu->variant->postproc_ops->disable) 169 + vpu->variant->postproc_ops->disable(ctx); 162 170 } 171 + 172 + void hantro_postproc_enable(struct hantro_ctx *ctx) 173 + { 174 + struct hantro_dev *vpu = ctx->dev; 175 + 176 + if (vpu->variant->postproc_ops && vpu->variant->postproc_ops->enable) 177 + vpu->variant->postproc_ops->enable(ctx); 178 + } 179 + 180 + const struct hantro_postproc_ops hantro_g1_postproc_ops = { 181 + .enable = hantro_postproc_g1_enable, 182 + .disable = hantro_postproc_g1_disable, 183 + };
+1 -1
drivers/staging/media/hantro/imx8m_vpu_hw.c
··· 262 262 .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_dec_fmts), 263 263 .postproc_fmts = imx8m_vpu_postproc_fmts, 264 264 .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_postproc_fmts), 265 - .postproc_regs = &hantro_g1_postproc_regs, 265 + .postproc_ops = &hantro_g1_postproc_ops, 266 266 .codec = HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | 267 267 HANTRO_H264_DECODER, 268 268 .codec_ops = imx8mq_vpu_codec_ops,
+3 -3
drivers/staging/media/hantro/rockchip_vpu_hw.c
··· 460 460 .num_dec_fmts = ARRAY_SIZE(rk3066_vpu_dec_fmts), 461 461 .postproc_fmts = rockchip_vpu1_postproc_fmts, 462 462 .num_postproc_fmts = ARRAY_SIZE(rockchip_vpu1_postproc_fmts), 463 - .postproc_regs = &hantro_g1_postproc_regs, 463 + .postproc_ops = &hantro_g1_postproc_ops, 464 464 .codec = HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | 465 465 HANTRO_H264_DECODER, 466 466 .codec_ops = rk3036_vpu_codec_ops, ··· 485 485 .num_dec_fmts = ARRAY_SIZE(rk3066_vpu_dec_fmts), 486 486 .postproc_fmts = rockchip_vpu1_postproc_fmts, 487 487 .num_postproc_fmts = ARRAY_SIZE(rockchip_vpu1_postproc_fmts), 488 - .postproc_regs = &hantro_g1_postproc_regs, 488 + .postproc_ops = &hantro_g1_postproc_ops, 489 489 .codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER | 490 490 HANTRO_VP8_DECODER | HANTRO_H264_DECODER, 491 491 .codec_ops = rk3066_vpu_codec_ops, ··· 505 505 .num_dec_fmts = ARRAY_SIZE(rk3288_vpu_dec_fmts), 506 506 .postproc_fmts = rockchip_vpu1_postproc_fmts, 507 507 .num_postproc_fmts = ARRAY_SIZE(rockchip_vpu1_postproc_fmts), 508 - .postproc_regs = &hantro_g1_postproc_regs, 508 + .postproc_ops = &hantro_g1_postproc_ops, 509 509 .codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER | 510 510 HANTRO_VP8_DECODER | HANTRO_H264_DECODER, 511 511 .codec_ops = rk3288_vpu_codec_ops,
+1 -1
drivers/staging/media/hantro/sama5d4_vdec_hw.c
··· 100 100 .num_dec_fmts = ARRAY_SIZE(sama5d4_vdec_fmts), 101 101 .postproc_fmts = sama5d4_vdec_postproc_fmts, 102 102 .num_postproc_fmts = ARRAY_SIZE(sama5d4_vdec_postproc_fmts), 103 - .postproc_regs = &hantro_g1_postproc_regs, 103 + .postproc_ops = &hantro_g1_postproc_ops, 104 104 .codec = HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | 105 105 HANTRO_H264_DECODER, 106 106 .codec_ops = sama5d4_vdec_codec_ops,