1 // SPDX-License-Identifier: GPL-2.0
3 * Allwinner Hantro G2 VPU codec driver
5 * Copyright (C) 2021 Jernej Skrabec <jernej.skrabec@gmail.com>
12 static const struct hantro_fmt sunxi_vpu_postproc_fmts[] = {
14 .fourcc = V4L2_PIX_FMT_NV12,
15 .codec_mode = HANTRO_MODE_NONE,
16 .postprocessed = true,
18 .min_width = FMT_MIN_WIDTH,
19 .max_width = FMT_UHD_WIDTH,
21 .min_height = FMT_MIN_HEIGHT,
22 .max_height = FMT_UHD_HEIGHT,
27 .fourcc = V4L2_PIX_FMT_P010,
28 .codec_mode = HANTRO_MODE_NONE,
29 .postprocessed = true,
31 .min_width = FMT_MIN_WIDTH,
32 .max_width = FMT_UHD_WIDTH,
34 .min_height = FMT_MIN_HEIGHT,
35 .max_height = FMT_UHD_HEIGHT,
41 static const struct hantro_fmt sunxi_vpu_dec_fmts[] = {
43 .fourcc = V4L2_PIX_FMT_NV12_4L4,
44 .codec_mode = HANTRO_MODE_NONE,
47 .min_width = FMT_MIN_WIDTH,
48 .max_width = FMT_UHD_WIDTH,
50 .min_height = FMT_MIN_HEIGHT,
51 .max_height = FMT_UHD_HEIGHT,
56 .fourcc = V4L2_PIX_FMT_P010_4L4,
57 .codec_mode = HANTRO_MODE_NONE,
60 .min_width = FMT_MIN_WIDTH,
61 .max_width = FMT_UHD_WIDTH,
63 .min_height = FMT_MIN_HEIGHT,
64 .max_height = FMT_UHD_HEIGHT,
69 .fourcc = V4L2_PIX_FMT_VP9_FRAME,
70 .codec_mode = HANTRO_MODE_VP9_DEC,
73 .min_width = FMT_MIN_WIDTH,
74 .max_width = FMT_UHD_WIDTH,
76 .min_height = FMT_MIN_HEIGHT,
77 .max_height = FMT_UHD_HEIGHT,
83 static int sunxi_vpu_hw_init(struct hantro_dev *vpu)
85 clk_set_rate(vpu->clocks[0].clk, 300000000);
90 static void sunxi_vpu_reset(struct hantro_ctx *ctx)
92 struct hantro_dev *vpu = ctx->dev;
94 reset_control_reset(vpu->resets);
97 static const struct hantro_codec_ops sunxi_vpu_codec_ops[] = {
98 [HANTRO_MODE_VP9_DEC] = {
99 .run = hantro_g2_vp9_dec_run,
100 .done = hantro_g2_vp9_dec_done,
101 .reset = sunxi_vpu_reset,
102 .init = hantro_vp9_dec_init,
103 .exit = hantro_vp9_dec_exit,
107 static const struct hantro_irq sunxi_irqs[] = {
108 { NULL, hantro_g2_irq },
111 static const char * const sunxi_clk_names[] = { "mod", "bus" };
113 const struct hantro_variant sunxi_vpu_variant = {
114 .dec_fmts = sunxi_vpu_dec_fmts,
115 .num_dec_fmts = ARRAY_SIZE(sunxi_vpu_dec_fmts),
116 .postproc_fmts = sunxi_vpu_postproc_fmts,
117 .num_postproc_fmts = ARRAY_SIZE(sunxi_vpu_postproc_fmts),
118 .postproc_ops = &hantro_g2_postproc_ops,
119 .codec = HANTRO_VP9_DECODER,
120 .codec_ops = sunxi_vpu_codec_ops,
121 .init = sunxi_vpu_hw_init,
123 .num_irqs = ARRAY_SIZE(sunxi_irqs),
124 .clk_names = sunxi_clk_names,
125 .num_clocks = ARRAY_SIZE(sunxi_clk_names),