aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/hantro/sama5d4_vdec_hw.c
blob: b2fc1c5613e19abd6948495040ad70e309538b47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// SPDX-License-Identifier: GPL-2.0
/*
 * Hantro VDEC driver
 *
 * Copyright (C) 2021 Collabora Ltd, Emil Velikov <emil.velikov@collabora.com>
 */

#include "hantro.h"

/*
 * Supported formats.
 */

static const struct hantro_fmt sama5d4_vdec_postproc_fmts[] = {
	{
		.fourcc = V4L2_PIX_FMT_YUYV,
		.codec_mode = HANTRO_MODE_NONE,
		.postprocessed = true,
	},
};

static const struct hantro_fmt sama5d4_vdec_fmts[] = {
	{
		.fourcc = V4L2_PIX_FMT_NV12,
		.codec_mode = HANTRO_MODE_NONE,
	},
	{
		.fourcc = V4L2_PIX_FMT_MPEG2_SLICE,
		.codec_mode = HANTRO_MODE_MPEG2_DEC,
		.max_depth = 2,
		.frmsize = {
			.min_width = 48,
			.max_width = 1280,
			.step_width = MB_DIM,
			.min_height = 48,
			.max_height = 720,
			.step_height = MB_DIM,
		},
	},
	{
		.fourcc = V4L2_PIX_FMT_VP8_FRAME,
		.codec_mode = HANTRO_MODE_VP8_DEC,
		.max_depth = 2,
		.frmsize = {
			.min_width = 48,
			.max_width = 1280,
			.step_width = MB_DIM,
			.min_height = 48,
			.max_height = 720,
			.step_height = MB_DIM,
		},
	},
	{
		.fourcc = V4L2_PIX_FMT_H264_SLICE,
		.codec_mode = HANTRO_MODE_H264_DEC,
		.max_depth = 2,
		.frmsize = {
			.min_width = 48,
			.max_width = 1280,
			.step_width = MB_DIM,
			.min_height = 48,
			.max_height = 720,
			.step_height = MB_DIM,
		},
	},
};

/*
 * Supported codec ops.
 */

static const struct hantro_codec_ops sama5d4_vdec_codec_ops[] = {
	[HANTRO_MODE_MPEG2_DEC] = {
		.run = hantro_g1_mpeg2_dec_run,
		.reset = hantro_g1_reset,
		.init = hantro_mpeg2_dec_init,
		.exit = hantro_mpeg2_dec_exit,
	},
	[HANTRO_MODE_VP8_DEC] = {
		.run = hantro_g1_vp8_dec_run,
		.reset = hantro_g1_reset,
		.init = hantro_vp8_dec_init,
		.exit = hantro_vp8_dec_exit,
	},
	[HANTRO_MODE_H264_DEC] = {
		.run = hantro_g1_h264_dec_run,
		.reset = hantro_g1_reset,
		.init = hantro_h264_dec_init,
		.exit = hantro_h264_dec_exit,
	},
};

static const struct hantro_irq sama5d4_irqs[] = {
	{ "vdec", hantro_g1_irq },
};

static const char * const sama5d4_clk_names[] = { "vdec_clk" };

const struct hantro_variant sama5d4_vdec_variant = {
	.dec_fmts = sama5d4_vdec_fmts,
	.num_dec_fmts = ARRAY_SIZE(sama5d4_vdec_fmts),
	.postproc_fmts = sama5d4_vdec_postproc_fmts,
	.num_postproc_fmts = ARRAY_SIZE(sama5d4_vdec_postproc_fmts),
	.postproc_ops = &hantro_g1_postproc_ops,
	.codec = HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER |
		 HANTRO_H264_DECODER,
	.codec_ops = sama5d4_vdec_codec_ops,
	.irqs = sama5d4_irqs,
	.num_irqs = ARRAY_SIZE(sama5d4_irqs),
	.clk_names = sama5d4_clk_names,
	.num_clocks = ARRAY_SIZE(sama5d4_clk_names),
};