1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2018 BayLibre, SAS
4  * Author: Maxime Jourdan <mjourdan@baylibre.com>
5  */
6 
7 #include "vdec_platform.h"
8 #include "vdec.h"
9 
10 #include "vdec_1.h"
11 #include "vdec_hevc.h"
12 #include "codec_mpeg12.h"
13 #include "codec_h264.h"
14 #include "codec_vp9.h"
15 
16 static const struct amvdec_format vdec_formats_gxbb[] = {
17 	{
18 		.pixfmt = V4L2_PIX_FMT_H264,
19 		.min_buffers = 2,
20 		.max_buffers = 24,
21 		.max_width = 1920,
22 		.max_height = 1080,
23 		.vdec_ops = &vdec_1_ops,
24 		.codec_ops = &codec_h264_ops,
25 		.firmware_path = "meson/vdec/gxbb_h264.bin",
26 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
27 		.flags = V4L2_FMT_FLAG_COMPRESSED |
28 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
29 	}, {
30 		.pixfmt = V4L2_PIX_FMT_MPEG1,
31 		.min_buffers = 8,
32 		.max_buffers = 8,
33 		.max_width = 1920,
34 		.max_height = 1080,
35 		.vdec_ops = &vdec_1_ops,
36 		.codec_ops = &codec_mpeg12_ops,
37 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
38 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
39 		.flags = V4L2_FMT_FLAG_COMPRESSED,
40 	}, {
41 		.pixfmt = V4L2_PIX_FMT_MPEG2,
42 		.min_buffers = 8,
43 		.max_buffers = 8,
44 		.max_width = 1920,
45 		.max_height = 1080,
46 		.vdec_ops = &vdec_1_ops,
47 		.codec_ops = &codec_mpeg12_ops,
48 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
49 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
50 		.flags = V4L2_FMT_FLAG_COMPRESSED,
51 	},
52 };
53 
54 static const struct amvdec_format vdec_formats_gxl[] = {
55 	{
56 		.pixfmt = V4L2_PIX_FMT_VP9,
57 		.min_buffers = 16,
58 		.max_buffers = 24,
59 		.max_width = 3840,
60 		.max_height = 2160,
61 		.vdec_ops = &vdec_hevc_ops,
62 		.codec_ops = &codec_vp9_ops,
63 		.firmware_path = "meson/vdec/gxl_vp9.bin",
64 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
65 		.flags = V4L2_FMT_FLAG_COMPRESSED |
66 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
67 	}, {
68 		.pixfmt = V4L2_PIX_FMT_H264,
69 		.min_buffers = 2,
70 		.max_buffers = 24,
71 		.max_width = 3840,
72 		.max_height = 2160,
73 		.vdec_ops = &vdec_1_ops,
74 		.codec_ops = &codec_h264_ops,
75 		.firmware_path = "meson/vdec/gxl_h264.bin",
76 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
77 		.flags = V4L2_FMT_FLAG_COMPRESSED |
78 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
79 	}, {
80 		.pixfmt = V4L2_PIX_FMT_MPEG1,
81 		.min_buffers = 8,
82 		.max_buffers = 8,
83 		.max_width = 1920,
84 		.max_height = 1080,
85 		.vdec_ops = &vdec_1_ops,
86 		.codec_ops = &codec_mpeg12_ops,
87 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
88 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
89 		.flags = V4L2_FMT_FLAG_COMPRESSED,
90 	}, {
91 		.pixfmt = V4L2_PIX_FMT_MPEG2,
92 		.min_buffers = 8,
93 		.max_buffers = 8,
94 		.max_width = 1920,
95 		.max_height = 1080,
96 		.vdec_ops = &vdec_1_ops,
97 		.codec_ops = &codec_mpeg12_ops,
98 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
99 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
100 		.flags = V4L2_FMT_FLAG_COMPRESSED,
101 	},
102 };
103 
104 static const struct amvdec_format vdec_formats_gxm[] = {
105 	{
106 		.pixfmt = V4L2_PIX_FMT_H264,
107 		.min_buffers = 2,
108 		.max_buffers = 24,
109 		.max_width = 3840,
110 		.max_height = 2160,
111 		.vdec_ops = &vdec_1_ops,
112 		.codec_ops = &codec_h264_ops,
113 		.firmware_path = "meson/vdec/gxm_h264.bin",
114 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
115 		.flags = V4L2_FMT_FLAG_COMPRESSED |
116 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
117 	}, {
118 		.pixfmt = V4L2_PIX_FMT_MPEG1,
119 		.min_buffers = 8,
120 		.max_buffers = 8,
121 		.max_width = 1920,
122 		.max_height = 1080,
123 		.vdec_ops = &vdec_1_ops,
124 		.codec_ops = &codec_mpeg12_ops,
125 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
126 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
127 		.flags = V4L2_FMT_FLAG_COMPRESSED,
128 	}, {
129 		.pixfmt = V4L2_PIX_FMT_MPEG2,
130 		.min_buffers = 8,
131 		.max_buffers = 8,
132 		.max_width = 1920,
133 		.max_height = 1080,
134 		.vdec_ops = &vdec_1_ops,
135 		.codec_ops = &codec_mpeg12_ops,
136 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
137 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
138 		.flags = V4L2_FMT_FLAG_COMPRESSED,
139 	},
140 };
141 
142 static const struct amvdec_format vdec_formats_g12a[] = {
143 	{
144 		.pixfmt = V4L2_PIX_FMT_VP9,
145 		.min_buffers = 16,
146 		.max_buffers = 24,
147 		.max_width = 3840,
148 		.max_height = 2160,
149 		.vdec_ops = &vdec_hevc_ops,
150 		.codec_ops = &codec_vp9_ops,
151 		.firmware_path = "meson/vdec/g12a_vp9.bin",
152 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
153 		.flags = V4L2_FMT_FLAG_COMPRESSED |
154 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
155 	}, {
156 		.pixfmt = V4L2_PIX_FMT_H264,
157 		.min_buffers = 2,
158 		.max_buffers = 24,
159 		.max_width = 3840,
160 		.max_height = 2160,
161 		.vdec_ops = &vdec_1_ops,
162 		.codec_ops = &codec_h264_ops,
163 		.firmware_path = "meson/vdec/g12a_h264.bin",
164 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
165 		.flags = V4L2_FMT_FLAG_COMPRESSED |
166 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
167 	}, {
168 		.pixfmt = V4L2_PIX_FMT_MPEG1,
169 		.min_buffers = 8,
170 		.max_buffers = 8,
171 		.max_width = 1920,
172 		.max_height = 1080,
173 		.vdec_ops = &vdec_1_ops,
174 		.codec_ops = &codec_mpeg12_ops,
175 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
176 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
177 		.flags = V4L2_FMT_FLAG_COMPRESSED,
178 	}, {
179 		.pixfmt = V4L2_PIX_FMT_MPEG2,
180 		.min_buffers = 8,
181 		.max_buffers = 8,
182 		.max_width = 1920,
183 		.max_height = 1080,
184 		.vdec_ops = &vdec_1_ops,
185 		.codec_ops = &codec_mpeg12_ops,
186 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
187 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
188 		.flags = V4L2_FMT_FLAG_COMPRESSED,
189 	},
190 };
191 
192 static const struct amvdec_format vdec_formats_sm1[] = {
193 	{
194 		.pixfmt = V4L2_PIX_FMT_VP9,
195 		.min_buffers = 16,
196 		.max_buffers = 24,
197 		.max_width = 3840,
198 		.max_height = 2160,
199 		.vdec_ops = &vdec_hevc_ops,
200 		.codec_ops = &codec_vp9_ops,
201 		.firmware_path = "meson/vdec/sm1_vp9_mmu.bin",
202 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
203 		.flags = V4L2_FMT_FLAG_COMPRESSED |
204 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
205 	}, {
206 		.pixfmt = V4L2_PIX_FMT_H264,
207 		.min_buffers = 2,
208 		.max_buffers = 24,
209 		.max_width = 3840,
210 		.max_height = 2160,
211 		.vdec_ops = &vdec_1_ops,
212 		.codec_ops = &codec_h264_ops,
213 		.firmware_path = "meson/vdec/g12a_h264.bin",
214 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 },
215 		.flags = V4L2_FMT_FLAG_COMPRESSED |
216 			 V4L2_FMT_FLAG_DYN_RESOLUTION,
217 	}, {
218 		.pixfmt = V4L2_PIX_FMT_MPEG1,
219 		.min_buffers = 8,
220 		.max_buffers = 8,
221 		.max_width = 1920,
222 		.max_height = 1080,
223 		.vdec_ops = &vdec_1_ops,
224 		.codec_ops = &codec_mpeg12_ops,
225 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
226 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
227 		.flags = V4L2_FMT_FLAG_COMPRESSED,
228 	}, {
229 		.pixfmt = V4L2_PIX_FMT_MPEG2,
230 		.min_buffers = 8,
231 		.max_buffers = 8,
232 		.max_width = 1920,
233 		.max_height = 1080,
234 		.vdec_ops = &vdec_1_ops,
235 		.codec_ops = &codec_mpeg12_ops,
236 		.firmware_path = "meson/vdec/gxl_mpeg12.bin",
237 		.pixfmts_cap = { V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_YUV420M, 0 },
238 		.flags = V4L2_FMT_FLAG_COMPRESSED,
239 	},
240 };
241 
242 const struct vdec_platform vdec_platform_gxbb = {
243 	.formats = vdec_formats_gxbb,
244 	.num_formats = ARRAY_SIZE(vdec_formats_gxbb),
245 	.revision = VDEC_REVISION_GXBB,
246 };
247 
248 const struct vdec_platform vdec_platform_gxl = {
249 	.formats = vdec_formats_gxl,
250 	.num_formats = ARRAY_SIZE(vdec_formats_gxl),
251 	.revision = VDEC_REVISION_GXL,
252 };
253 
254 const struct vdec_platform vdec_platform_gxm = {
255 	.formats = vdec_formats_gxm,
256 	.num_formats = ARRAY_SIZE(vdec_formats_gxm),
257 	.revision = VDEC_REVISION_GXM,
258 };
259 
260 const struct vdec_platform vdec_platform_g12a = {
261 	.formats = vdec_formats_g12a,
262 	.num_formats = ARRAY_SIZE(vdec_formats_g12a),
263 	.revision = VDEC_REVISION_G12A,
264 };
265 
266 const struct vdec_platform vdec_platform_sm1 = {
267 	.formats = vdec_formats_sm1,
268 	.num_formats = ARRAY_SIZE(vdec_formats_sm1),
269 	.revision = VDEC_REVISION_SM1,
270 };
271