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 VDEC

Add support for STM32MP25 VDEC video hardware decoder.
Support of H264/VP8 decoding.
No post-processor support.
VDEC has its own reset/clock/irq.

Successfully tested up to full HD.

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
46c4dffb 60314831

+114 -3
+11 -3
drivers/media/platform/verisilicon/Kconfig
··· 4 4 5 5 config VIDEO_HANTRO 6 6 tristate "Hantro VPU driver" 7 - depends on ARCH_MXC || ARCH_ROCKCHIP || ARCH_AT91 || ARCH_SUNXI || COMPILE_TEST 7 + depends on ARCH_MXC || ARCH_ROCKCHIP || ARCH_AT91 || ARCH_SUNXI || ARCH_STM32 || COMPILE_TEST 8 8 depends on V4L_MEM2MEM_DRIVERS 9 9 depends on VIDEO_DEV 10 10 select MEDIA_CONTROLLER ··· 15 15 select V4L2_VP9 16 16 help 17 17 Support for the Hantro IP based Video Processing Units present on 18 - Rockchip and NXP i.MX8M SoCs, which accelerate video and image 19 - encoding and decoding. 18 + Rockchip, NXP i.MX8M and STM32MP25 SoCs, which accelerate video 19 + and image encoding and decoding. 20 20 To compile this driver as a module, choose M here: the module 21 21 will be called hantro-vpu. 22 22 ··· 51 51 default y 52 52 help 53 53 Enable support for H6 SoC. 54 + 55 + config VIDEO_HANTRO_STM32MP25 56 + bool "Hantro STM32MP25 support" 57 + depends on VIDEO_HANTRO 58 + depends on ARCH_STM32 || COMPILE_TEST 59 + default y 60 + help 61 + Enable support for STM32MP25 SoCs.
+3
drivers/media/platform/verisilicon/Makefile
··· 39 39 40 40 hantro-vpu-$(CONFIG_VIDEO_HANTRO_SUNXI) += \ 41 41 sunxi_vpu_hw.o 42 + 43 + hantro-vpu-$(CONFIG_VIDEO_HANTRO_STM32MP25) += \ 44 + stm32mp25_vpu_hw.o
+3
drivers/media/platform/verisilicon/hantro_drv.c
··· 736 736 #ifdef CONFIG_VIDEO_HANTRO_SUNXI 737 737 { .compatible = "allwinner,sun50i-h6-vpu-g2", .data = &sunxi_vpu_variant, }, 738 738 #endif 739 + #ifdef CONFIG_VIDEO_HANTRO_STM32MP25 740 + { .compatible = "st,stm32mp25-vdec", .data = &stm32mp25_vdec_variant, }, 741 + #endif 739 742 { /* sentinel */ } 740 743 }; 741 744 MODULE_DEVICE_TABLE(of, of_hantro_match);
+1
drivers/media/platform/verisilicon/hantro_hw.h
··· 408 408 extern const struct hantro_variant rk3588_vpu981_variant; 409 409 extern const struct hantro_variant sama5d4_vdec_variant; 410 410 extern const struct hantro_variant sunxi_vpu_variant; 411 + extern const struct hantro_variant stm32mp25_vdec_variant; 411 412 412 413 extern const struct hantro_postproc_ops hantro_g1_postproc_ops; 413 414 extern const struct hantro_postproc_ops hantro_g2_postproc_ops;
+96
drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * STM32MP25 video codec driver 4 + * 5 + * Copyright (C) STMicroelectronics SA 2024 6 + * Authors: Hugues Fruchet <hugues.fruchet@foss.st.com> 7 + * for STMicroelectronics. 8 + * 9 + */ 10 + 11 + #include "hantro.h" 12 + 13 + /* 14 + * Supported formats. 15 + */ 16 + 17 + static const struct hantro_fmt stm32mp25_vdec_fmts[] = { 18 + { 19 + .fourcc = V4L2_PIX_FMT_NV12, 20 + .codec_mode = HANTRO_MODE_NONE, 21 + .frmsize = { 22 + .min_width = FMT_MIN_WIDTH, 23 + .max_width = FMT_FHD_WIDTH, 24 + .step_width = MB_DIM, 25 + .min_height = FMT_MIN_HEIGHT, 26 + .max_height = FMT_FHD_HEIGHT, 27 + .step_height = MB_DIM, 28 + }, 29 + }, 30 + { 31 + .fourcc = V4L2_PIX_FMT_VP8_FRAME, 32 + .codec_mode = HANTRO_MODE_VP8_DEC, 33 + .max_depth = 2, 34 + .frmsize = { 35 + .min_width = FMT_MIN_WIDTH, 36 + .max_width = FMT_FHD_WIDTH, 37 + .step_width = MB_DIM, 38 + .min_height = FMT_MIN_HEIGHT, 39 + .max_height = FMT_FHD_HEIGHT, 40 + .step_height = MB_DIM, 41 + }, 42 + }, 43 + { 44 + .fourcc = V4L2_PIX_FMT_H264_SLICE, 45 + .codec_mode = HANTRO_MODE_H264_DEC, 46 + .max_depth = 2, 47 + .frmsize = { 48 + .min_width = FMT_MIN_WIDTH, 49 + .max_width = FMT_FHD_WIDTH, 50 + .step_width = MB_DIM, 51 + .min_height = FMT_MIN_HEIGHT, 52 + .max_height = FMT_FHD_HEIGHT, 53 + .step_height = MB_DIM, 54 + }, 55 + }, 56 + }; 57 + 58 + /* 59 + * Supported codec ops. 60 + */ 61 + 62 + static const struct hantro_codec_ops stm32mp25_vdec_codec_ops[] = { 63 + [HANTRO_MODE_VP8_DEC] = { 64 + .run = hantro_g1_vp8_dec_run, 65 + .reset = hantro_g1_reset, 66 + .init = hantro_vp8_dec_init, 67 + .exit = hantro_vp8_dec_exit, 68 + }, 69 + [HANTRO_MODE_H264_DEC] = { 70 + .run = hantro_g1_h264_dec_run, 71 + .reset = hantro_g1_reset, 72 + .init = hantro_h264_dec_init, 73 + .exit = hantro_h264_dec_exit, 74 + }, 75 + }; 76 + 77 + /* 78 + * Variants. 79 + */ 80 + 81 + static const struct hantro_irq stm32mp25_vdec_irqs[] = { 82 + { "vdec", hantro_g1_irq }, 83 + }; 84 + 85 + static const char * const stm32mp25_vdec_clk_names[] = { "vdec-clk" }; 86 + 87 + const struct hantro_variant stm32mp25_vdec_variant = { 88 + .dec_fmts = stm32mp25_vdec_fmts, 89 + .num_dec_fmts = ARRAY_SIZE(stm32mp25_vdec_fmts), 90 + .codec = HANTRO_VP8_DECODER | HANTRO_H264_DECODER, 91 + .codec_ops = stm32mp25_vdec_codec_ops, 92 + .irqs = stm32mp25_vdec_irqs, 93 + .num_irqs = ARRAY_SIZE(stm32mp25_vdec_irqs), 94 + .clk_names = stm32mp25_vdec_clk_names, 95 + .num_clocks = ARRAY_SIZE(stm32mp25_vdec_clk_names), 96 + };