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

media: hantro: add support for STM32MP25 VENC

Add support for STM32MP25 VENC video hardware encoder.
Support of JPEG encoding.
VENC has its own reset/clock/irq.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Hugues Fruchet and committed by
Mauro Carvalho Chehab
b0fb9ca3 46c4dffb

+92
+1
drivers/media/platform/verisilicon/hantro_drv.c
··· 738 738 #endif 739 739 #ifdef CONFIG_VIDEO_HANTRO_STM32MP25 740 740 { .compatible = "st,stm32mp25-vdec", .data = &stm32mp25_vdec_variant, }, 741 + { .compatible = "st,stm32mp25-venc", .data = &stm32mp25_venc_variant, }, 741 742 #endif 742 743 { /* sentinel */ } 743 744 };
+1
drivers/media/platform/verisilicon/hantro_hw.h
··· 409 409 extern const struct hantro_variant sama5d4_vdec_variant; 410 410 extern const struct hantro_variant sunxi_vpu_variant; 411 411 extern const struct hantro_variant stm32mp25_vdec_variant; 412 + extern const struct hantro_variant stm32mp25_venc_variant; 412 413 413 414 extern const struct hantro_postproc_ops hantro_g1_postproc_ops; 414 415 extern const struct hantro_postproc_ops hantro_g2_postproc_ops;
+90
drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
··· 9 9 */ 10 10 11 11 #include "hantro.h" 12 + #include "hantro_jpeg.h" 13 + #include "hantro_h1_regs.h" 12 14 13 15 /* 14 16 * Supported formats. ··· 57 55 }, 58 56 }; 59 57 58 + static const struct hantro_fmt stm32mp25_venc_fmts[] = { 59 + { 60 + .fourcc = V4L2_PIX_FMT_YUV420M, 61 + .codec_mode = HANTRO_MODE_NONE, 62 + .enc_fmt = ROCKCHIP_VPU_ENC_FMT_YUV420P, 63 + }, 64 + { 65 + .fourcc = V4L2_PIX_FMT_NV12M, 66 + .codec_mode = HANTRO_MODE_NONE, 67 + .enc_fmt = ROCKCHIP_VPU_ENC_FMT_YUV420SP, 68 + }, 69 + { 70 + .fourcc = V4L2_PIX_FMT_YUYV, 71 + .codec_mode = HANTRO_MODE_NONE, 72 + .enc_fmt = ROCKCHIP_VPU_ENC_FMT_YUYV422, 73 + }, 74 + { 75 + .fourcc = V4L2_PIX_FMT_UYVY, 76 + .codec_mode = HANTRO_MODE_NONE, 77 + .enc_fmt = ROCKCHIP_VPU_ENC_FMT_UYVY422, 78 + }, 79 + { 80 + .fourcc = V4L2_PIX_FMT_JPEG, 81 + .codec_mode = HANTRO_MODE_JPEG_ENC, 82 + .max_depth = 2, 83 + .header_size = JPEG_HEADER_SIZE, 84 + .frmsize = { 85 + .min_width = 96, 86 + .max_width = FMT_4K_WIDTH, 87 + .step_width = MB_DIM, 88 + .min_height = 96, 89 + .max_height = FMT_4K_HEIGHT, 90 + .step_height = MB_DIM, 91 + }, 92 + }, 93 + }; 94 + 95 + static irqreturn_t stm32mp25_venc_irq(int irq, void *dev_id) 96 + { 97 + struct hantro_dev *vpu = dev_id; 98 + enum vb2_buffer_state state; 99 + u32 status; 100 + 101 + status = vepu_read(vpu, H1_REG_INTERRUPT); 102 + state = (status & H1_REG_INTERRUPT_FRAME_RDY) ? 103 + VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR; 104 + 105 + vepu_write(vpu, H1_REG_INTERRUPT_BIT, H1_REG_INTERRUPT); 106 + 107 + hantro_irq_done(vpu, state); 108 + 109 + return IRQ_HANDLED; 110 + } 111 + 112 + static void stm32mp25_venc_reset(struct hantro_ctx *ctx) 113 + { 114 + struct hantro_dev *vpu = ctx->dev; 115 + 116 + reset_control_reset(vpu->resets); 117 + } 118 + 60 119 /* 61 120 * Supported codec ops. 62 121 */ ··· 134 71 .reset = hantro_g1_reset, 135 72 .init = hantro_h264_dec_init, 136 73 .exit = hantro_h264_dec_exit, 74 + }, 75 + }; 76 + 77 + static const struct hantro_codec_ops stm32mp25_venc_codec_ops[] = { 78 + [HANTRO_MODE_JPEG_ENC] = { 79 + .run = hantro_h1_jpeg_enc_run, 80 + .reset = stm32mp25_venc_reset, 81 + .done = hantro_h1_jpeg_enc_done, 137 82 }, 138 83 }; 139 84 ··· 164 93 .num_irqs = ARRAY_SIZE(stm32mp25_vdec_irqs), 165 94 .clk_names = stm32mp25_vdec_clk_names, 166 95 .num_clocks = ARRAY_SIZE(stm32mp25_vdec_clk_names), 96 + }; 97 + 98 + static const struct hantro_irq stm32mp25_venc_irqs[] = { 99 + { "venc", stm32mp25_venc_irq }, 100 + }; 101 + 102 + static const char * const stm32mp25_venc_clk_names[] = { 103 + "venc-clk" 104 + }; 105 + 106 + const struct hantro_variant stm32mp25_venc_variant = { 107 + .enc_fmts = stm32mp25_venc_fmts, 108 + .num_enc_fmts = ARRAY_SIZE(stm32mp25_venc_fmts), 109 + .codec = HANTRO_JPEG_ENCODER, 110 + .codec_ops = stm32mp25_venc_codec_ops, 111 + .irqs = stm32mp25_venc_irqs, 112 + .num_irqs = ARRAY_SIZE(stm32mp25_venc_irqs), 113 + .clk_names = stm32mp25_venc_clk_names, 114 + .num_clocks = ARRAY_SIZE(stm32mp25_venc_clk_names) 167 115 };