Skip to content

Commit 86790a4

Browse files
jernejskmchehab
authored andcommitted
media: hantro: Add support for Allwinner H6
Allwinner H6 has a Hantro G2 core used for VP9 decoding. It's not clear at this time if HEVC is also supported or not. Signed-off-by: Jernej Skrabec <[email protected]> Acked-by: Andrzej Pietrasiewicz <[email protected]> Reviewed-by: Ezequiel Garcia <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent fd6be12 commit 86790a4

File tree

5 files changed

+102
-1
lines changed

5 files changed

+102
-1
lines changed

drivers/staging/media/hantro/Kconfig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
config VIDEO_HANTRO
33
tristate "Hantro VPU driver"
4-
depends on ARCH_MXC || ARCH_ROCKCHIP || ARCH_AT91 || COMPILE_TEST
4+
depends on ARCH_MXC || ARCH_ROCKCHIP || ARCH_AT91 || ARCH_SUNXI || COMPILE_TEST
55
depends on VIDEO_DEV && VIDEO_V4L2
66
select MEDIA_CONTROLLER
77
select MEDIA_CONTROLLER_REQUEST_API
@@ -40,3 +40,11 @@ config VIDEO_HANTRO_ROCKCHIP
4040
default y
4141
help
4242
Enable support for RK3288, RK3328, and RK3399 SoCs.
43+
44+
config VIDEO_HANTRO_SUNXI
45+
bool "Hantro VPU Allwinner support"
46+
depends on VIDEO_HANTRO
47+
depends on ARCH_SUNXI || COMPILE_TEST
48+
default y
49+
help
50+
Enable support for H6 SoC.

drivers/staging/media/hantro/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ hantro-vpu-$(CONFIG_VIDEO_HANTRO_SAMA5D4) += \
3333

3434
hantro-vpu-$(CONFIG_VIDEO_HANTRO_ROCKCHIP) += \
3535
rockchip_vpu_hw.o
36+
37+
hantro-vpu-$(CONFIG_VIDEO_HANTRO_SUNXI) += \
38+
sunxi_vpu_hw.o

drivers/staging/media/hantro/hantro_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ static const struct of_device_id of_hantro_match[] = {
620620
#endif
621621
#ifdef CONFIG_VIDEO_HANTRO_SAMA5D4
622622
{ .compatible = "microchip,sama5d4-vdec", .data = &sama5d4_vdec_variant, },
623+
#endif
624+
#ifdef CONFIG_VIDEO_HANTRO_SUNXI
625+
{ .compatible = "allwinner,sun50i-h6-vpu-g2", .data = &sunxi_vpu_variant, },
623626
#endif
624627
{ /* sentinel */ }
625628
};

drivers/staging/media/hantro/hantro_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ extern const struct hantro_variant rk3288_vpu_variant;
308308
extern const struct hantro_variant rk3328_vpu_variant;
309309
extern const struct hantro_variant rk3399_vpu_variant;
310310
extern const struct hantro_variant sama5d4_vdec_variant;
311+
extern const struct hantro_variant sunxi_vpu_variant;
311312

312313
extern const struct hantro_postproc_ops hantro_g1_postproc_ops;
313314
extern const struct hantro_postproc_ops hantro_g2_postproc_ops;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Allwinner Hantro G2 VPU codec driver
4+
*
5+
* Copyright (C) 2021 Jernej Skrabec <[email protected]>
6+
*/
7+
8+
#include <linux/clk.h>
9+
10+
#include "hantro.h"
11+
12+
static const struct hantro_fmt sunxi_vpu_postproc_fmts[] = {
13+
{
14+
.fourcc = V4L2_PIX_FMT_NV12,
15+
.codec_mode = HANTRO_MODE_NONE,
16+
.postprocessed = true,
17+
},
18+
};
19+
20+
static const struct hantro_fmt sunxi_vpu_dec_fmts[] = {
21+
{
22+
.fourcc = V4L2_PIX_FMT_NV12_4L4,
23+
.codec_mode = HANTRO_MODE_NONE,
24+
},
25+
{
26+
.fourcc = V4L2_PIX_FMT_VP9_FRAME,
27+
.codec_mode = HANTRO_MODE_VP9_DEC,
28+
.max_depth = 2,
29+
.frmsize = {
30+
.min_width = 48,
31+
.max_width = 3840,
32+
.step_width = MB_DIM,
33+
.min_height = 48,
34+
.max_height = 2160,
35+
.step_height = MB_DIM,
36+
},
37+
},
38+
};
39+
40+
static int sunxi_vpu_hw_init(struct hantro_dev *vpu)
41+
{
42+
clk_set_rate(vpu->clocks[0].clk, 300000000);
43+
44+
return 0;
45+
}
46+
47+
static void sunxi_vpu_reset(struct hantro_ctx *ctx)
48+
{
49+
struct hantro_dev *vpu = ctx->dev;
50+
51+
reset_control_reset(vpu->resets);
52+
}
53+
54+
static const struct hantro_codec_ops sunxi_vpu_codec_ops[] = {
55+
[HANTRO_MODE_VP9_DEC] = {
56+
.run = hantro_g2_vp9_dec_run,
57+
.done = hantro_g2_vp9_dec_done,
58+
.reset = sunxi_vpu_reset,
59+
.init = hantro_vp9_dec_init,
60+
.exit = hantro_vp9_dec_exit,
61+
},
62+
};
63+
64+
static const struct hantro_irq sunxi_irqs[] = {
65+
{ NULL, hantro_g2_irq },
66+
};
67+
68+
static const char * const sunxi_clk_names[] = { "mod", "bus" };
69+
70+
const struct hantro_variant sunxi_vpu_variant = {
71+
.dec_fmts = sunxi_vpu_dec_fmts,
72+
.num_dec_fmts = ARRAY_SIZE(sunxi_vpu_dec_fmts),
73+
.postproc_fmts = sunxi_vpu_postproc_fmts,
74+
.num_postproc_fmts = ARRAY_SIZE(sunxi_vpu_postproc_fmts),
75+
.postproc_ops = &hantro_g2_postproc_ops,
76+
.codec = HANTRO_VP9_DECODER,
77+
.codec_ops = sunxi_vpu_codec_ops,
78+
.init = sunxi_vpu_hw_init,
79+
.irqs = sunxi_irqs,
80+
.num_irqs = ARRAY_SIZE(sunxi_irqs),
81+
.clk_names = sunxi_clk_names,
82+
.num_clocks = ARRAY_SIZE(sunxi_clk_names),
83+
.double_buffer = 1,
84+
.legacy_regs = 1,
85+
.late_postproc = 1,
86+
};

0 commit comments

Comments
 (0)