decoder: h264: optimize support for grayscale surfaces.
[platform/upstream/libva-intel-driver.git] / src / i965_device_info.c
1 /*
2  * Copyright © 2014 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include "i965_drv_video.h"
29
30 /* Extra set of chroma formats supported for H.264 decoding (beyond YUV 4:2:0) */
31 #define EXTRA_H264_DEC_CHROMA_FORMATS \
32     (VA_RT_FORMAT_YUV400)
33
34 /* Extra set of chroma formats supported for JPEG decoding (beyond YUV 4:2:0) */
35 #define EXTRA_JPEG_DEC_CHROMA_FORMATS \
36     (VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV411 | VA_RT_FORMAT_YUV422 | \
37      VA_RT_FORMAT_YUV444)
38
39 extern struct hw_context *i965_proc_context_init(VADriverContextP, struct object_config *);
40 extern struct hw_context *g4x_dec_hw_context_init(VADriverContextP, struct object_config *);
41 extern bool genx_render_init(VADriverContextP);
42
43 static const struct hw_codec_info g4x_hw_codec_info = {
44     .dec_hw_context_init = g4x_dec_hw_context_init,
45     .enc_hw_context_init = NULL,
46     .proc_hw_context_init = NULL,
47     .render_init = genx_render_init,
48     .post_processing_context_init = NULL,
49
50     .max_width = 2048,
51     .max_height = 2048,
52     .min_linear_wpitch = 16,
53     .min_linear_hpitch = 16,
54
55     .has_mpeg2_decoding = 1,
56
57     .num_filters = 0,
58 };
59
60 extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, struct object_config *);
61 extern void i965_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
62
63 static const struct hw_codec_info ilk_hw_codec_info = {
64     .dec_hw_context_init = ironlake_dec_hw_context_init,
65     .enc_hw_context_init = NULL,
66     .proc_hw_context_init = i965_proc_context_init,
67     .render_init = genx_render_init,
68     .post_processing_context_init = i965_post_processing_context_init,
69
70     .max_width = 2048,
71     .max_height = 2048,
72     .min_linear_wpitch = 16,
73     .min_linear_hpitch = 16,
74
75     .has_mpeg2_decoding = 1,
76     .has_h264_decoding = 1,
77     .has_vpp = 1,
78     .has_accelerated_putimage = 1,
79
80     .num_filters = 0,
81 };
82
83 extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *);
84 extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, struct object_config *);
85 static const struct hw_codec_info snb_hw_codec_info = {
86     .dec_hw_context_init = gen6_dec_hw_context_init,
87     .enc_hw_context_init = gen6_enc_hw_context_init,
88     .proc_hw_context_init = i965_proc_context_init,
89     .render_init = genx_render_init,
90     .post_processing_context_init = i965_post_processing_context_init,
91
92     .max_width = 2048,
93     .max_height = 2048,
94     .min_linear_wpitch = 16,
95     .min_linear_hpitch = 16,
96
97     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
98
99     .has_mpeg2_decoding = 1,
100     .has_h264_decoding = 1,
101     .has_h264_encoding = 1,
102     .has_vc1_decoding = 1,
103     .has_vpp = 1,
104     .has_accelerated_getimage = 1,
105     .has_accelerated_putimage = 1,
106     .has_tiled_surface = 1,
107
108     .num_filters = 2,
109     .filters = {
110         { VAProcFilterNoiseReduction, I965_RING_NULL },
111         { VAProcFilterDeinterlacing, I965_RING_NULL },
112     },
113 };
114
115 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
116 extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *);
117 static const struct hw_codec_info ivb_hw_codec_info = {
118     .dec_hw_context_init = gen7_dec_hw_context_init,
119     .enc_hw_context_init = gen7_enc_hw_context_init,
120     .proc_hw_context_init = i965_proc_context_init,
121     .render_init = genx_render_init,
122     .post_processing_context_init = i965_post_processing_context_init,
123
124     .max_width = 4096,
125     .max_height = 4096,
126     .min_linear_wpitch = 64,
127     .min_linear_hpitch = 16,
128
129     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
130     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
131
132     .has_mpeg2_decoding = 1,
133     .has_mpeg2_encoding = 1,
134     .has_h264_decoding = 1,
135     .has_h264_encoding = 1,
136     .has_vc1_decoding = 1,
137     .has_jpeg_decoding = 1,
138     .has_vpp = 1,
139     .has_accelerated_getimage = 1,
140     .has_accelerated_putimage = 1,
141     .has_tiled_surface = 1,
142     .has_di_motion_adptive = 1,
143
144     .num_filters = 2,
145     .filters = {
146         { VAProcFilterNoiseReduction, I965_RING_NULL },
147         { VAProcFilterDeinterlacing, I965_RING_NULL },
148     },
149 };
150
151 extern struct hw_context *gen75_dec_hw_context_init(VADriverContextP, struct object_config *);
152 extern struct hw_context *gen75_enc_hw_context_init(VADriverContextP, struct object_config *);
153 extern struct hw_context *gen75_proc_context_init(VADriverContextP, struct object_config *);
154 static const struct hw_codec_info hsw_hw_codec_info = {
155     .dec_hw_context_init = gen75_dec_hw_context_init,
156     .enc_hw_context_init = gen75_enc_hw_context_init,
157     .proc_hw_context_init = gen75_proc_context_init,
158     .render_init = genx_render_init,
159     .post_processing_context_init = i965_post_processing_context_init,
160
161     .max_width = 4096,
162     .max_height = 4096,
163     .min_linear_wpitch = 64,
164     .min_linear_hpitch = 16,
165
166     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
167     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
168
169     .has_mpeg2_decoding = 1,
170     .has_mpeg2_encoding = 1,
171     .has_h264_decoding = 1,
172     .has_h264_encoding = 1,
173     .has_vc1_decoding = 1,
174     .has_jpeg_decoding = 1,
175     .has_vpp = 1,
176     .has_accelerated_getimage = 1,
177     .has_accelerated_putimage = 1,
178     .has_tiled_surface = 1,
179     .has_di_motion_adptive = 1,
180     .has_di_motion_compensated = 1,
181
182     .num_filters = 5,
183     .filters = {
184         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
185         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
186         { VAProcFilterSharpening, I965_RING_NULL },
187         { VAProcFilterColorBalance, I965_RING_VEBOX},
188         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
189     },
190 };
191
192 extern struct hw_context *gen8_dec_hw_context_init(VADriverContextP, struct object_config *);
193 extern struct hw_context *gen8_enc_hw_context_init(VADriverContextP, struct object_config *);
194 extern void gen8_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
195 static const struct hw_codec_info bdw_hw_codec_info = {
196     .dec_hw_context_init = gen8_dec_hw_context_init,
197     .enc_hw_context_init = gen8_enc_hw_context_init,
198     .proc_hw_context_init = gen75_proc_context_init,
199     .render_init = gen8_render_init,
200     .post_processing_context_init = gen8_post_processing_context_init,
201
202     .max_width = 4096,
203     .max_height = 4096,
204     .min_linear_wpitch = 64,
205     .min_linear_hpitch = 16,
206
207     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
208     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
209
210     .has_mpeg2_decoding = 1,
211     .has_mpeg2_encoding = 1,
212     .has_h264_decoding = 1,
213     .has_h264_encoding = 1,
214     .has_vc1_decoding = 1,
215     .has_jpeg_decoding = 1,
216     .has_vpp = 1,
217     .has_accelerated_getimage = 1,
218     .has_accelerated_putimage = 1,
219     .has_tiled_surface = 1,
220     .has_di_motion_adptive = 1,
221     .has_di_motion_compensated = 1,
222     .has_vp8_decoding = 1,
223
224     .num_filters = 5,
225     .filters = {
226         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
227         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
228         { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
229         { VAProcFilterColorBalance, I965_RING_VEBOX},
230         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
231     },
232 };
233
234 const struct hw_codec_info *
235 i965_get_codec_info(int devid)
236 {
237     switch (devid) {
238 #undef CHIPSET
239 #define CHIPSET(id, family, dev, str) case id: return &family##_hw_codec_info;
240 #include "i965_pciids.h"
241     default:
242         return NULL;
243     }
244 }
245
246 static const struct intel_device_info g4x_device_info = {
247     .gen = 4,
248
249     .urb_size = 384,
250     .max_wm_threads = 50,       /* 10 * 5 */
251
252     .is_g4x = 1,
253 };
254
255 static const struct intel_device_info ilk_device_info = {
256     .gen = 5,
257
258     .urb_size = 1024,
259     .max_wm_threads = 72,       /* 12 * 6 */
260 };
261
262 static const struct intel_device_info snb_gt1_device_info = {
263     .gen = 6,
264     .gt = 1,
265
266     .urb_size = 1024,
267     .max_wm_threads = 40,
268 };
269
270 static const struct intel_device_info snb_gt2_device_info = {
271     .gen = 6,
272     .gt = 2,
273
274     .urb_size = 1024,
275     .max_wm_threads = 80,
276 };
277
278 static const struct intel_device_info ivb_gt1_device_info = {
279     .gen = 7,
280     .gt = 1,
281
282     .urb_size = 4096,
283     .max_wm_threads = 48,
284
285     .is_ivybridge = 1,
286 };
287
288 static const struct intel_device_info ivb_gt2_device_info = {
289     .gen = 7,
290     .gt = 2,
291
292     .urb_size = 4096,
293     .max_wm_threads = 172,
294
295     .is_ivybridge = 1,
296 };
297
298 static const struct intel_device_info byt_device_info = {
299     .gen = 7,
300     .gt = 1,
301
302     .urb_size = 4096,
303     .max_wm_threads = 48,
304
305     .is_ivybridge = 1,
306     .is_baytrail = 1,
307 };
308
309 static const struct intel_device_info hsw_gt1_device_info = {
310     .gen = 7,
311     .gt = 1,
312
313     .urb_size = 4096,
314     .max_wm_threads = 102,
315
316     .is_haswell = 1,
317 };
318
319 static const struct intel_device_info hsw_gt2_device_info = {
320     .gen = 7,
321     .gt = 2,
322
323     .urb_size = 4096,
324     .max_wm_threads = 204,
325
326     .is_haswell = 1,
327 };
328
329 static const struct intel_device_info hsw_gt3_device_info = {
330     .gen = 7,
331     .gt = 3,
332
333     .urb_size = 4096,
334     .max_wm_threads = 408,
335
336     .is_haswell = 1,
337 };
338
339 static const struct intel_device_info bdw_device_info = {
340     .gen = 8,
341
342     .urb_size = 4096,
343     .max_wm_threads = 64,       /* per PSD */
344 };
345
346 const struct intel_device_info *
347 i965_get_device_info(int devid)
348 {
349     switch (devid) {
350 #undef CHIPSET
351 #define CHIPSET(id, family, dev, str) case id: return &dev##_device_info;
352 #include "i965_pciids.h"
353     default:
354         return NULL;
355     }
356 }