Check the pointer against NULL
[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     .has_di_motion_adptive = 1,
108
109     .num_filters = 2,
110     .filters = {
111         { VAProcFilterNoiseReduction, I965_RING_NULL },
112         { VAProcFilterDeinterlacing, I965_RING_NULL },
113     },
114 };
115
116 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
117 extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *);
118 static const struct hw_codec_info ivb_hw_codec_info = {
119     .dec_hw_context_init = gen7_dec_hw_context_init,
120     .enc_hw_context_init = gen7_enc_hw_context_init,
121     .proc_hw_context_init = i965_proc_context_init,
122     .render_init = genx_render_init,
123     .post_processing_context_init = i965_post_processing_context_init,
124
125     .max_width = 4096,
126     .max_height = 4096,
127     .min_linear_wpitch = 64,
128     .min_linear_hpitch = 16,
129
130     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
131     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
132
133     .has_mpeg2_decoding = 1,
134     .has_mpeg2_encoding = 1,
135     .has_h264_decoding = 1,
136     .has_h264_encoding = 1,
137     .has_vc1_decoding = 1,
138     .has_jpeg_decoding = 1,
139     .has_vpp = 1,
140     .has_accelerated_getimage = 1,
141     .has_accelerated_putimage = 1,
142     .has_tiled_surface = 1,
143     .has_di_motion_adptive = 1,
144
145     .num_filters = 2,
146     .filters = {
147         { VAProcFilterNoiseReduction, I965_RING_NULL },
148         { VAProcFilterDeinterlacing, I965_RING_NULL },
149     },
150 };
151
152 extern struct hw_context *gen75_dec_hw_context_init(VADriverContextP, struct object_config *);
153 extern struct hw_context *gen75_enc_hw_context_init(VADriverContextP, struct object_config *);
154 extern struct hw_context *gen75_proc_context_init(VADriverContextP, struct object_config *);
155 static const struct hw_codec_info hsw_hw_codec_info = {
156     .dec_hw_context_init = gen75_dec_hw_context_init,
157     .enc_hw_context_init = gen75_enc_hw_context_init,
158     .proc_hw_context_init = gen75_proc_context_init,
159     .render_init = genx_render_init,
160     .post_processing_context_init = i965_post_processing_context_init,
161
162     .max_width = 4096,
163     .max_height = 4096,
164     .min_linear_wpitch = 64,
165     .min_linear_hpitch = 16,
166
167     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
168     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
169
170     .has_mpeg2_decoding = 1,
171     .has_mpeg2_encoding = 1,
172     .has_h264_decoding = 1,
173     .has_h264_encoding = 1,
174     .has_vc1_decoding = 1,
175     .has_jpeg_decoding = 1,
176     .has_vpp = 1,
177     .has_accelerated_getimage = 1,
178     .has_accelerated_putimage = 1,
179     .has_tiled_surface = 1,
180     .has_di_motion_adptive = 1,
181     .has_di_motion_compensated = 1,
182
183     .num_filters = 5,
184     .filters = {
185         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
186         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
187         { VAProcFilterSharpening, I965_RING_NULL },
188         { VAProcFilterColorBalance, I965_RING_VEBOX},
189         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
190     },
191 };
192
193 extern struct hw_context *gen8_dec_hw_context_init(VADriverContextP, struct object_config *);
194 extern struct hw_context *gen8_enc_hw_context_init(VADriverContextP, struct object_config *);
195 extern void gen8_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
196 static const struct hw_codec_info bdw_hw_codec_info = {
197     .dec_hw_context_init = gen8_dec_hw_context_init,
198     .enc_hw_context_init = gen8_enc_hw_context_init,
199     .proc_hw_context_init = gen75_proc_context_init,
200     .render_init = gen8_render_init,
201     .post_processing_context_init = gen8_post_processing_context_init,
202
203     .max_width = 4096,
204     .max_height = 4096,
205     .min_linear_wpitch = 64,
206     .min_linear_hpitch = 16,
207
208     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
209     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
210
211     .has_mpeg2_decoding = 1,
212     .has_mpeg2_encoding = 1,
213     .has_h264_decoding = 1,
214     .has_h264_encoding = 1,
215     .has_vc1_decoding = 1,
216     .has_jpeg_decoding = 1,
217     .has_vpp = 1,
218     .has_accelerated_getimage = 1,
219     .has_accelerated_putimage = 1,
220     .has_tiled_surface = 1,
221     .has_di_motion_adptive = 1,
222     .has_di_motion_compensated = 1,
223     .has_vp8_decoding = 1,
224
225     .num_filters = 5,
226     .filters = {
227         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
228         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
229         { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
230         { VAProcFilterColorBalance, I965_RING_VEBOX},
231         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
232     },
233 };
234
235 const struct hw_codec_info *
236 i965_get_codec_info(int devid)
237 {
238     switch (devid) {
239 #undef CHIPSET
240 #define CHIPSET(id, family, dev, str) case id: return &family##_hw_codec_info;
241 #include "i965_pciids.h"
242     default:
243         return NULL;
244     }
245 }
246
247 static const struct intel_device_info g4x_device_info = {
248     .gen = 4,
249
250     .urb_size = 384,
251     .max_wm_threads = 50,       /* 10 * 5 */
252
253     .is_g4x = 1,
254 };
255
256 static const struct intel_device_info ilk_device_info = {
257     .gen = 5,
258
259     .urb_size = 1024,
260     .max_wm_threads = 72,       /* 12 * 6 */
261 };
262
263 static const struct intel_device_info snb_gt1_device_info = {
264     .gen = 6,
265     .gt = 1,
266
267     .urb_size = 1024,
268     .max_wm_threads = 40,
269 };
270
271 static const struct intel_device_info snb_gt2_device_info = {
272     .gen = 6,
273     .gt = 2,
274
275     .urb_size = 1024,
276     .max_wm_threads = 80,
277 };
278
279 static const struct intel_device_info ivb_gt1_device_info = {
280     .gen = 7,
281     .gt = 1,
282
283     .urb_size = 4096,
284     .max_wm_threads = 48,
285
286     .is_ivybridge = 1,
287 };
288
289 static const struct intel_device_info ivb_gt2_device_info = {
290     .gen = 7,
291     .gt = 2,
292
293     .urb_size = 4096,
294     .max_wm_threads = 172,
295
296     .is_ivybridge = 1,
297 };
298
299 static const struct intel_device_info byt_device_info = {
300     .gen = 7,
301     .gt = 1,
302
303     .urb_size = 4096,
304     .max_wm_threads = 48,
305
306     .is_ivybridge = 1,
307     .is_baytrail = 1,
308 };
309
310 static const struct intel_device_info hsw_gt1_device_info = {
311     .gen = 7,
312     .gt = 1,
313
314     .urb_size = 4096,
315     .max_wm_threads = 102,
316
317     .is_haswell = 1,
318 };
319
320 static const struct intel_device_info hsw_gt2_device_info = {
321     .gen = 7,
322     .gt = 2,
323
324     .urb_size = 4096,
325     .max_wm_threads = 204,
326
327     .is_haswell = 1,
328 };
329
330 static const struct intel_device_info hsw_gt3_device_info = {
331     .gen = 7,
332     .gt = 3,
333
334     .urb_size = 4096,
335     .max_wm_threads = 408,
336
337     .is_haswell = 1,
338 };
339
340 static const struct intel_device_info bdw_device_info = {
341     .gen = 8,
342
343     .urb_size = 4096,
344     .max_wm_threads = 64,       /* per PSD */
345 };
346
347 const struct intel_device_info *
348 i965_get_device_info(int devid)
349 {
350     switch (devid) {
351 #undef CHIPSET
352 #define CHIPSET(id, family, dev, str) case id: return &dev##_device_info;
353 #include "i965_pciids.h"
354     default:
355         return NULL;
356     }
357 }