2 * Copyright © 2014 Intel Corporation
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
28 #include "i965_drv_video.h"
35 /* Extra set of chroma formats supported for H.264 decoding (beyond YUV 4:2:0) */
36 #define EXTRA_H264_DEC_CHROMA_FORMATS \
39 /* Extra set of chroma formats supported for JPEG decoding (beyond YUV 4:2:0) */
40 #define EXTRA_JPEG_DEC_CHROMA_FORMATS \
41 (VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV411 | VA_RT_FORMAT_YUV422 | \
44 /* Extra set of chroma formats supported for JPEG encoding (beyond YUV 4:2:0) */
45 #define EXTRA_JPEG_ENC_CHROMA_FORMATS \
46 (VA_RT_FORMAT_YUV400| VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_RGB32)
48 #define EXTRA_HEVC_DEC_CHROMA_FORMATS \
49 (VA_RT_FORMAT_YUV420_10BPP)
51 #define EXTRA_VP9_DEC_CHROMA_FORMATS \
52 (VA_RT_FORMAT_YUV420_10BPP)
54 /* Defines VA profile as a 32-bit unsigned integer mask */
55 #define VA_PROFILE_MASK(PROFILE) \
56 (1U << VAProfile##PROFILE)
58 #define VP9_PROFILE_MASK(PROFILE) \
61 extern struct hw_context *i965_proc_context_init(VADriverContextP, struct object_config *);
62 extern struct hw_context *g4x_dec_hw_context_init(VADriverContextP, struct object_config *);
63 extern bool genx_render_init(VADriverContextP);
65 static struct hw_codec_info g4x_hw_codec_info = {
66 .dec_hw_context_init = g4x_dec_hw_context_init,
67 .enc_hw_context_init = NULL,
68 .proc_hw_context_init = NULL,
69 .render_init = genx_render_init,
70 .post_processing_context_init = NULL,
74 .min_linear_wpitch = 16,
75 .min_linear_hpitch = 4,
77 .has_mpeg2_decoding = 1,
82 extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, struct object_config *);
83 extern void i965_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
85 static struct hw_codec_info ilk_hw_codec_info = {
86 .dec_hw_context_init = ironlake_dec_hw_context_init,
87 .enc_hw_context_init = NULL,
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,
94 .min_linear_wpitch = 16,
95 .min_linear_hpitch = 4,
97 .has_mpeg2_decoding = 1,
98 .has_h264_decoding = 1,
100 .has_accelerated_putimage = 1,
105 static void gen6_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
107 extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *);
108 extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, struct object_config *);
109 static struct hw_codec_info snb_hw_codec_info = {
110 .dec_hw_context_init = gen6_dec_hw_context_init,
111 .enc_hw_context_init = gen6_enc_hw_context_init,
112 .proc_hw_context_init = i965_proc_context_init,
113 .render_init = genx_render_init,
114 .post_processing_context_init = i965_post_processing_context_init,
115 .preinit_hw_codec = gen6_hw_codec_preinit,
119 .min_linear_wpitch = 16,
120 .min_linear_hpitch = 4,
122 .h264_mvc_dec_profiles = VA_PROFILE_MASK(H264StereoHigh),
123 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
125 .has_mpeg2_decoding = 1,
126 .has_h264_decoding = 1,
127 .has_h264_encoding = 1,
128 .has_vc1_decoding = 1,
130 .has_accelerated_getimage = 1,
131 .has_accelerated_putimage = 1,
132 .has_tiled_surface = 1,
133 .has_di_motion_adptive = 1,
135 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
139 { VAProcFilterNoiseReduction, I965_RING_NULL },
140 { VAProcFilterDeinterlacing, I965_RING_NULL },
144 static void gen7_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
146 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
147 extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *);
148 static struct hw_codec_info ivb_hw_codec_info = {
149 .dec_hw_context_init = gen7_dec_hw_context_init,
150 .enc_hw_context_init = gen7_enc_hw_context_init,
151 .proc_hw_context_init = i965_proc_context_init,
152 .render_init = genx_render_init,
153 .post_processing_context_init = i965_post_processing_context_init,
154 .preinit_hw_codec = gen7_hw_codec_preinit,
158 .min_linear_wpitch = 64,
159 .min_linear_hpitch = 4,
161 .h264_mvc_dec_profiles = VA_PROFILE_MASK(H264StereoHigh),
162 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
163 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
165 .has_mpeg2_decoding = 1,
166 .has_mpeg2_encoding = 1,
167 .has_h264_decoding = 1,
168 .has_h264_encoding = 1,
169 .has_vc1_decoding = 1,
170 .has_jpeg_decoding = 1,
172 .has_accelerated_getimage = 1,
173 .has_accelerated_putimage = 1,
174 .has_tiled_surface = 1,
175 .has_di_motion_adptive = 1,
176 .has_di_motion_compensated = 1,
178 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
182 { VAProcFilterNoiseReduction, I965_RING_NULL },
183 { VAProcFilterDeinterlacing, I965_RING_NULL },
187 static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
189 extern struct hw_context *gen75_dec_hw_context_init(VADriverContextP, struct object_config *);
190 extern struct hw_context *gen75_enc_hw_context_init(VADriverContextP, struct object_config *);
191 extern struct hw_context *gen75_proc_context_init(VADriverContextP, struct object_config *);
192 static struct hw_codec_info hsw_hw_codec_info = {
193 .dec_hw_context_init = gen75_dec_hw_context_init,
194 .enc_hw_context_init = gen75_enc_hw_context_init,
195 .proc_hw_context_init = gen75_proc_context_init,
196 .render_init = genx_render_init,
197 .post_processing_context_init = i965_post_processing_context_init,
198 .preinit_hw_codec = hsw_hw_codec_preinit,
202 .min_linear_wpitch = 64,
203 .min_linear_hpitch = 4,
205 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
206 VA_PROFILE_MASK(H264MultiviewHigh)),
207 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
208 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
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,
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_h264_mvc_encoding = 1,
224 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
228 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
229 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
230 { VAProcFilterSharpening, I965_RING_NULL },
231 { VAProcFilterColorBalance, I965_RING_VEBOX},
232 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
236 extern struct hw_context *gen8_dec_hw_context_init(VADriverContextP, struct object_config *);
237 extern struct hw_context *gen8_enc_hw_context_init(VADriverContextP, struct object_config *);
238 extern void gen8_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
239 static struct hw_codec_info bdw_hw_codec_info = {
240 .dec_hw_context_init = gen8_dec_hw_context_init,
241 .enc_hw_context_init = gen8_enc_hw_context_init,
242 .proc_hw_context_init = gen75_proc_context_init,
243 .render_init = gen8_render_init,
244 .post_processing_context_init = gen8_post_processing_context_init,
248 .min_linear_wpitch = 64,
249 .min_linear_hpitch = 4,
251 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
252 VA_PROFILE_MASK(H264MultiviewHigh)),
253 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
254 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
256 .has_mpeg2_decoding = 1,
257 .has_mpeg2_encoding = 1,
258 .has_h264_decoding = 1,
259 .has_h264_encoding = 1,
260 .has_vc1_decoding = 1,
261 .has_jpeg_decoding = 1,
263 .has_accelerated_getimage = 1,
264 .has_accelerated_putimage = 1,
265 .has_tiled_surface = 1,
266 .has_di_motion_adptive = 1,
267 .has_di_motion_compensated = 1,
268 .has_vp8_decoding = 1,
269 .has_h264_mvc_encoding = 1,
271 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
275 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
276 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
277 { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
278 { VAProcFilterColorBalance, I965_RING_VEBOX},
279 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
283 extern struct hw_context *gen9_dec_hw_context_init(VADriverContextP, struct object_config *);
284 static struct hw_codec_info chv_hw_codec_info = {
285 .dec_hw_context_init = gen9_dec_hw_context_init,
286 .enc_hw_context_init = gen8_enc_hw_context_init,
287 .proc_hw_context_init = gen75_proc_context_init,
288 .render_init = gen8_render_init,
289 .post_processing_context_init = gen8_post_processing_context_init,
293 .min_linear_wpitch = 64,
294 .min_linear_hpitch = 4,
296 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
297 VA_PROFILE_MASK(H264MultiviewHigh)),
298 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
299 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
300 .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
302 .has_mpeg2_decoding = 1,
303 .has_mpeg2_encoding = 1,
304 .has_h264_decoding = 1,
305 .has_h264_encoding = 1,
306 .has_vc1_decoding = 1,
307 .has_jpeg_decoding = 1,
308 .has_jpeg_encoding = 1,
310 .has_accelerated_getimage = 1,
311 .has_accelerated_putimage = 1,
312 .has_tiled_surface = 1,
313 .has_di_motion_adptive = 1,
314 .has_di_motion_compensated = 1,
315 .has_vp8_decoding = 1,
316 .has_vp8_encoding = 1,
317 .has_h264_mvc_encoding = 1,
318 .has_hevc_decoding = 1,
320 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
324 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
325 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
326 { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
327 { VAProcFilterColorBalance, I965_RING_VEBOX},
328 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
332 static void gen9_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
334 extern struct hw_context *gen9_enc_hw_context_init(VADriverContextP, struct object_config *);
335 extern void gen9_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
336 extern void gen9_max_resolution(struct i965_driver_data *, struct object_config *, int *, int *);
337 static struct hw_codec_info skl_hw_codec_info = {
338 .dec_hw_context_init = gen9_dec_hw_context_init,
339 .enc_hw_context_init = gen9_enc_hw_context_init,
340 .proc_hw_context_init = gen75_proc_context_init,
341 .render_init = gen9_render_init,
342 .post_processing_context_init = gen9_post_processing_context_init,
343 .max_resolution = gen9_max_resolution,
344 .preinit_hw_codec = gen9_hw_codec_preinit,
346 .max_width = 4096, /* default. See max_resolution */
347 .max_height = 4096, /* default. See max_resolution */
348 .min_linear_wpitch = 64,
349 .min_linear_hpitch = 4,
351 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
352 VA_PROFILE_MASK(H264MultiviewHigh)),
353 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
354 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
355 .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
357 .has_mpeg2_decoding = 1,
358 .has_mpeg2_encoding = 1,
359 .has_h264_decoding = 1,
360 .has_h264_encoding = 1,
361 .has_vc1_decoding = 1,
362 .has_jpeg_decoding = 1,
363 .has_jpeg_encoding = 1,
365 .has_accelerated_getimage = 1,
366 .has_accelerated_putimage = 1,
367 .has_tiled_surface = 1,
368 .has_di_motion_adptive = 1,
369 .has_di_motion_compensated = 1,
370 .has_vp8_decoding = 1,
371 .has_vp8_encoding = 1,
372 .has_h264_mvc_encoding = 1,
373 .has_hevc_decoding = 1,
374 .has_hevc_encoding = 1,
375 .has_lp_h264_encoding = 1,
376 .has_fei_h264_encoding = 1,
377 .has_h264_preenc = 1,
379 .lp_h264_brc_mode = VA_RC_CQP,
380 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR | VA_RC_MB,
384 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
385 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
386 { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
387 { VAProcFilterColorBalance, I965_RING_VEBOX},
388 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
393 static struct hw_codec_info bxt_hw_codec_info = {
394 .dec_hw_context_init = gen9_dec_hw_context_init,
395 .enc_hw_context_init = gen9_enc_hw_context_init,
396 .proc_hw_context_init = gen75_proc_context_init,
397 .render_init = gen9_render_init,
398 .post_processing_context_init = gen9_post_processing_context_init,
399 .max_resolution = gen9_max_resolution,
400 .preinit_hw_codec = gen9_hw_codec_preinit,
402 .max_width = 4096, /* default. See max_resolution */
403 .max_height = 4096, /* default. See max_resolution */
404 .min_linear_wpitch = 64,
405 .min_linear_hpitch = 4,
407 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
408 VA_PROFILE_MASK(H264MultiviewHigh)),
409 .vp9_dec_profiles = VP9_PROFILE_MASK(0),
411 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
412 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
413 .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
414 .hevc_dec_chroma_formats = EXTRA_HEVC_DEC_CHROMA_FORMATS,
416 .has_mpeg2_decoding = 1,
417 .has_h264_decoding = 1,
418 .has_h264_encoding = 1,
419 .has_vc1_decoding = 1,
420 .has_jpeg_decoding = 1,
421 .has_jpeg_encoding = 1,
423 .has_accelerated_getimage = 1,
424 .has_accelerated_putimage = 1,
425 .has_tiled_surface = 1,
426 .has_di_motion_adptive = 1,
427 .has_di_motion_compensated = 1,
428 .has_vp8_decoding = 1,
429 .has_vp8_encoding = 1,
430 .has_h264_mvc_encoding = 1,
431 .has_hevc_decoding = 1,
432 .has_hevc_encoding = 1,
433 .has_hevc10_decoding = 1,
434 .has_vp9_decoding = 1,
436 .has_lp_h264_encoding = 1,
438 .lp_h264_brc_mode = VA_RC_CQP,
439 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR | VA_RC_MB,
443 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
444 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
445 { VAProcFilterSharpening, I965_RING_NULL },
446 { VAProcFilterColorBalance, I965_RING_VEBOX},
447 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
451 static struct hw_codec_info kbl_hw_codec_info = {
452 .dec_hw_context_init = gen9_dec_hw_context_init,
453 .enc_hw_context_init = gen9_enc_hw_context_init,
454 .proc_hw_context_init = gen75_proc_context_init,
455 .render_init = gen9_render_init,
456 .post_processing_context_init = gen9_post_processing_context_init,
457 .max_resolution = gen9_max_resolution,
458 .preinit_hw_codec = gen9_hw_codec_preinit,
460 .max_width = 4096, /* default. See max_resolution */
461 .max_height = 4096, /* default. See max_resolution */
462 .min_linear_wpitch = 64,
463 .min_linear_hpitch = 4,
465 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
466 VA_PROFILE_MASK(H264MultiviewHigh)),
467 .vp9_dec_profiles = VP9_PROFILE_MASK(0) |
469 .vp9_enc_profiles = VP9_PROFILE_MASK(0),
471 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
472 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
473 .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
474 .hevc_dec_chroma_formats = EXTRA_HEVC_DEC_CHROMA_FORMATS,
475 .vp9_dec_chroma_formats = EXTRA_VP9_DEC_CHROMA_FORMATS,
477 .has_mpeg2_decoding = 1,
478 .has_mpeg2_encoding = 1,
479 .has_h264_decoding = 1,
480 .has_h264_encoding = 1,
481 .has_vc1_decoding = 1,
482 .has_jpeg_decoding = 1,
483 .has_jpeg_encoding = 1,
485 .has_accelerated_getimage = 1,
486 .has_accelerated_putimage = 1,
487 .has_tiled_surface = 1,
488 .has_di_motion_adptive = 1,
489 .has_di_motion_compensated = 1,
490 .has_vp8_decoding = 1,
491 .has_vp8_encoding = 1,
492 .has_h264_mvc_encoding = 1,
493 .has_hevc_decoding = 1,
494 .has_hevc_encoding = 1,
495 .has_hevc10_encoding = 1,
496 .has_hevc10_decoding = 1,
497 .has_vp9_decoding = 1,
499 .has_vp9_encoding = 1,
500 .has_lp_h264_encoding = 1,
502 .lp_h264_brc_mode = VA_RC_CQP,
503 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR | VA_RC_MB,
505 .vp9_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
509 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
510 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
511 { VAProcFilterSharpening, I965_RING_NULL },
512 { VAProcFilterColorBalance, I965_RING_VEBOX},
513 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
517 static struct hw_codec_info glk_hw_codec_info = {
518 .dec_hw_context_init = gen9_dec_hw_context_init,
519 .enc_hw_context_init = gen9_enc_hw_context_init,
520 .proc_hw_context_init = gen75_proc_context_init,
521 .render_init = gen9_render_init,
522 .post_processing_context_init = gen9_post_processing_context_init,
524 .max_resolution = gen9_max_resolution,
525 .preinit_hw_codec = gen9_hw_codec_preinit,
529 .min_linear_wpitch = 64,
530 .min_linear_hpitch = 4,
532 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
533 VA_PROFILE_MASK(H264MultiviewHigh)),
534 .vp9_dec_profiles = VP9_PROFILE_MASK(0) |
537 .vp9_enc_profiles = VP9_PROFILE_MASK(0),
539 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
540 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
541 .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
542 .hevc_dec_chroma_formats = EXTRA_HEVC_DEC_CHROMA_FORMATS,
543 .vp9_dec_chroma_formats = EXTRA_VP9_DEC_CHROMA_FORMATS,
545 .has_mpeg2_decoding = 1,
546 .has_h264_decoding = 1,
547 .has_h264_encoding = 1,
548 .has_vc1_decoding = 1,
549 .has_jpeg_decoding = 1,
550 .has_jpeg_encoding = 1,
552 .has_accelerated_getimage = 1,
553 .has_accelerated_putimage = 1,
554 .has_tiled_surface = 1,
555 .has_di_motion_adptive = 1,
556 .has_di_motion_compensated = 1,
557 .has_vp8_decoding = 1,
558 .has_vp8_encoding = 1,
559 .has_h264_mvc_encoding = 1,
560 .has_hevc_decoding = 1,
561 .has_hevc_encoding = 1,
562 .has_hevc10_decoding = 1,
563 .has_hevc10_encoding = 1,
564 .has_vp9_decoding = 1,
566 .has_vp9_encoding = 1,
567 .has_lp_h264_encoding = 1,
569 .lp_h264_brc_mode = VA_RC_CQP,
570 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR | VA_RC_MB,
572 .vp9_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
576 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
577 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
578 { VAProcFilterSharpening, I965_RING_NULL },
579 { VAProcFilterColorBalance, I965_RING_VEBOX},
580 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
584 static struct hw_codec_info cfl_hw_codec_info = {
585 .dec_hw_context_init = gen9_dec_hw_context_init,
586 .enc_hw_context_init = gen9_enc_hw_context_init,
587 .proc_hw_context_init = gen75_proc_context_init,
588 .render_init = gen9_render_init,
589 .post_processing_context_init = gen9_post_processing_context_init,
590 .max_resolution = gen9_max_resolution,
591 .preinit_hw_codec = gen9_hw_codec_preinit,
593 .max_width = 4096, /* default. See max_resolution */
594 .max_height = 4096, /* default. See max_resolution */
595 .min_linear_wpitch = 64,
596 .min_linear_hpitch = 16,
598 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
599 VA_PROFILE_MASK(H264MultiviewHigh)),
600 .vp9_dec_profiles = VP9_PROFILE_MASK(0) |
602 .vp9_enc_profiles = VP9_PROFILE_MASK(0),
604 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
605 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
606 .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
607 .hevc_dec_chroma_formats = EXTRA_HEVC_DEC_CHROMA_FORMATS,
608 .vp9_dec_chroma_formats = EXTRA_VP9_DEC_CHROMA_FORMATS,
610 .has_mpeg2_decoding = 1,
611 .has_mpeg2_encoding = 1,
612 .has_h264_decoding = 1,
613 .has_h264_encoding = 1,
614 .has_vc1_decoding = 1,
615 .has_jpeg_decoding = 1,
616 .has_jpeg_encoding = 1,
618 .has_accelerated_getimage = 1,
619 .has_accelerated_putimage = 1,
620 .has_tiled_surface = 1,
621 .has_di_motion_adptive = 1,
622 .has_di_motion_compensated = 1,
623 .has_vp8_decoding = 1,
624 .has_vp8_encoding = 1,
625 .has_h264_mvc_encoding = 1,
626 .has_hevc_decoding = 1,
627 .has_hevc_encoding = 1,
628 .has_hevc10_encoding = 1,
629 .has_hevc10_decoding = 1,
630 .has_vp9_decoding = 1,
632 .has_vp9_encoding = 1,
633 .has_lp_h264_encoding = 1,
635 .lp_h264_brc_mode = VA_RC_CQP,
636 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR | VA_RC_MB,
638 .vp9_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
642 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
643 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
644 { VAProcFilterSharpening, I965_RING_NULL },
645 { VAProcFilterColorBalance, I965_RING_VEBOX},
646 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
650 static struct hw_codec_info cnl_hw_codec_info = {
651 .dec_hw_context_init = gen9_dec_hw_context_init,
652 .enc_hw_context_init = gen9_enc_hw_context_init,
653 .proc_hw_context_init = gen75_proc_context_init,
654 .render_init = gen9_render_init,
655 .post_processing_context_init = gen9_post_processing_context_init,
656 .max_resolution = gen9_max_resolution,
657 .preinit_hw_codec = gen9_hw_codec_preinit,
659 .max_width = 4096, /* default. See max_resolution */
660 .max_height = 4096, /* default. See max_resolution */
661 .min_linear_wpitch = 64,
662 .min_linear_hpitch = 16,
664 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) | VA_PROFILE_MASK(H264MultiviewHigh)),
665 .vp9_dec_profiles = VP9_PROFILE_MASK(0) | VP9_PROFILE_MASK(2),
666 .vp9_enc_profiles = VP9_PROFILE_MASK(0),
668 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
669 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
670 .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
671 .hevc_dec_chroma_formats = EXTRA_HEVC_DEC_CHROMA_FORMATS,
672 .vp9_dec_chroma_formats = EXTRA_VP9_DEC_CHROMA_FORMATS,
674 .has_mpeg2_decoding = 1,
675 .has_mpeg2_encoding = 1,
676 .has_h264_decoding = 1,
677 .has_h264_encoding = 1,
678 .has_vc1_decoding = 1,
679 .has_jpeg_decoding = 1,
680 .has_jpeg_encoding = 1,
682 .has_accelerated_getimage = 1,
683 .has_accelerated_putimage = 1,
684 .has_tiled_surface = 1,
685 .has_di_motion_adptive = 1,
686 .has_di_motion_compensated = 1,
687 .has_vp8_decoding = 1,
688 .has_vp8_encoding = 1,
689 .has_h264_mvc_encoding = 1,
690 .has_hevc_decoding = 1,
691 .has_hevc_encoding = 1,
692 .has_hevc10_decoding = 1,
693 .has_hevc10_encoding = 1,
694 .has_vp9_decoding = 1,
696 .has_vp9_encoding = 1,
697 .has_lp_h264_encoding = 1,
698 .has_lp_vp9_encoding = 1,
700 .lp_h264_brc_mode = VA_RC_CQP,
701 .h264_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR | VA_RC_MB,
703 .vp9_brc_mode = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR,
707 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
708 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
709 { VAProcFilterSharpening, I965_RING_NULL },
710 { VAProcFilterColorBalance, I965_RING_VEBOX},
711 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
715 struct hw_codec_info *
716 i965_get_codec_info(int devid)
720 #define CHIPSET(id, family, dev, str) case id: return &family##_hw_codec_info;
721 #include "i965_pciids.h"
727 static const struct intel_device_info g4x_device_info = {
731 .max_wm_threads = 50, /* 10 * 5 */
736 static const struct intel_device_info ilk_device_info = {
740 .max_wm_threads = 72, /* 12 * 6 */
743 static const struct intel_device_info snb_gt1_device_info = {
748 .max_wm_threads = 40,
751 static const struct intel_device_info snb_gt2_device_info = {
756 .max_wm_threads = 80,
759 static const struct intel_device_info ivb_gt1_device_info = {
764 .max_wm_threads = 48,
769 static const struct intel_device_info ivb_gt2_device_info = {
774 .max_wm_threads = 172,
779 static const struct intel_device_info byt_device_info = {
784 .max_wm_threads = 48,
790 static const struct intel_device_info hsw_gt1_device_info = {
795 .max_wm_threads = 102,
800 static const struct intel_device_info hsw_gt2_device_info = {
805 .max_wm_threads = 204,
810 static const struct intel_device_info hsw_gt3_device_info = {
815 .max_wm_threads = 408,
820 static const struct intel_device_info bdw_device_info = {
824 .max_wm_threads = 64, /* per PSD */
827 static const struct intel_device_info chv_device_info = {
831 .max_wm_threads = 64, /* per PSD */
836 static const struct intel_device_info skl_device_info = {
840 .max_wm_threads = 64, /* per PSD */
845 static const struct intel_device_info bxt_device_info = {
849 .max_wm_threads = 64, /* per PSD */
853 static const struct intel_device_info kbl_device_info = {
857 .max_wm_threads = 64, /* per PSD */
862 static const struct intel_device_info glk_device_info = {
866 .max_wm_threads = 64, /* per PSD */
871 static const struct intel_device_info cfl_device_info = {
875 .max_wm_threads = 64, /* per PSD */
880 static const struct intel_device_info cnl_device_info = {
884 .max_wm_threads = 64, /* per PSD */
887 const struct intel_device_info *
888 i965_get_device_info(int devid)
892 #define CHIPSET(id, family, dev, str) case id: return &dev##_device_info;
893 #include "i965_pciids.h"
899 static void cpuid(unsigned int op,
900 uint32_t *eax, uint32_t *ebx,
901 uint32_t *ecx, uint32_t *edx)
903 __cpuid_count(op, 0, *eax, *ebx, *ecx, *edx);
907 * This function doesn't check the length. And the caller should
908 * assure that the length of input string should be greater than 48.
910 static int intel_driver_detect_cpustring(char *model_id)
914 if (model_id == NULL)
917 rdata = (uint32_t *)model_id;
919 /* obtain the max supported extended CPUID info */
920 cpuid(0x80000000, &rdata[0], &rdata[1], &rdata[2], &rdata[3]);
922 /* If the max extended CPUID info is less than 0x80000004, fail */
923 if (rdata[0] < 0x80000004)
926 /* obtain the CPUID string */
927 cpuid(0x80000002, &rdata[0], &rdata[1], &rdata[2], &rdata[3]);
928 cpuid(0x80000003, &rdata[4], &rdata[5], &rdata[6], &rdata[7]);
929 cpuid(0x80000004, &rdata[8], &rdata[9], &rdata[10], &rdata[11]);
931 *(model_id + 48) = '\0';
936 * the hook_list for HSW.
937 * It is captured by /proc/cpuinfo and the space character is stripped.
939 const static char *hsw_cpu_hook_list[] = {
940 "Intel(R)Pentium(R)3556U",
941 "Intel(R)Pentium(R)3560Y",
942 "Intel(R)Pentium(R)3550M",
943 "Intel(R)Celeron(R)2980U",
944 "Intel(R)Celeron(R)2955U",
945 "Intel(R)Celeron(R)2950M",
948 static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
950 char model_string[64];
951 char *model_ptr, *tmp_ptr;
952 int i, model_len, list_len;
955 memset(model_string, 0, sizeof(model_string));
957 /* If it can't detect cpu model_string, leave it alone */
958 if (intel_driver_detect_cpustring(model_string))
961 /* strip the cpufreq info */
962 model_ptr = model_string;
963 tmp_ptr = strstr(model_ptr, "@");
968 /* strip the space character and convert to the lower case */
969 model_ptr = model_string;
970 model_len = strlen(model_string);
971 for (i = 0; i < model_len; i++) {
972 if (model_string[i] != ' ') {
973 *model_ptr = model_string[i];
980 list_len = sizeof(hsw_cpu_hook_list) / sizeof(char *);
981 model_len = strlen(model_string);
982 for (i = 0; i < list_len; i++) {
983 model_ptr = (char *)hsw_cpu_hook_list[i];
985 if (strlen(model_ptr) != model_len)
988 if (strncasecmp(model_string, model_ptr, model_len) == 0) {
995 codec_info->has_h264_encoding = 0;
996 codec_info->has_h264_mvc_encoding = 0;
997 codec_info->has_mpeg2_encoding = 0;
1003 * the hook_list for Sandybride.
1004 * It is captured by /proc/cpuinfo and the space character is stripped.
1006 const static char *gen6_cpu_hook_list[] = {
1007 "Intel(R)Celeron(R)CPU847",
1008 "Intel(R)Celeron(R)CPU867",
1011 static void gen6_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
1013 char model_string[64];
1014 char *model_ptr, *tmp_ptr;
1015 int i, model_len, list_len;
1018 memset(model_string, 0, sizeof(model_string));
1020 /* If it can't detect cpu model_string, leave it alone */
1021 if (intel_driver_detect_cpustring(model_string))
1024 /* strip the cpufreq info */
1025 model_ptr = model_string;
1026 tmp_ptr = strstr(model_ptr, "@");
1031 /* strip the space character and convert to the lower case */
1032 model_ptr = model_string;
1033 model_len = strlen(model_string);
1034 for (i = 0; i < model_len; i++) {
1035 if (model_string[i] != ' ') {
1036 *model_ptr = model_string[i];
1043 list_len = sizeof(gen6_cpu_hook_list) / sizeof(char *);
1044 model_len = strlen(model_string);
1045 for (i = 0; i < list_len; i++) {
1046 model_ptr = (char *)gen6_cpu_hook_list[i];
1048 if (strlen(model_ptr) != model_len)
1051 if (strncasecmp(model_string, model_ptr, model_len) == 0) {
1058 codec_info->has_h264_encoding = 0;
1064 * the hook_list for Ivybridge.
1065 * It is captured by /proc/cpuinfo and the space character is stripped.
1067 const static char *gen7_cpu_hook_list[] = {
1068 "Intel(R)Celeron(R)CPU1007U",
1069 "Intel(R)Celeron(R)CPU1037U",
1070 "Intel(R)Pentium(R)CPUG2130",
1073 static void gen7_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
1075 char model_string[64];
1076 char *model_ptr, *tmp_ptr;
1077 int i, model_len, list_len;
1080 memset(model_string, 0, sizeof(model_string));
1082 /* If it can't detect cpu model_string, leave it alone */
1083 if (intel_driver_detect_cpustring(model_string))
1086 /* strip the cpufreq info */
1087 model_ptr = model_string;
1088 tmp_ptr = strstr(model_ptr, "@");
1093 /* strip the space character and convert to the lower case */
1094 model_ptr = model_string;
1095 model_len = strlen(model_string);
1096 for (i = 0; i < model_len; i++) {
1097 if (model_string[i] != ' ') {
1098 *model_ptr = model_string[i];
1105 list_len = sizeof(gen7_cpu_hook_list) / sizeof(char *);
1106 model_len = strlen(model_string);
1107 for (i = 0; i < list_len; i++) {
1108 model_ptr = (char *)gen7_cpu_hook_list[i];
1110 if (strlen(model_ptr) != model_len)
1113 if (strncasecmp(model_string, model_ptr, model_len) == 0) {
1120 codec_info->has_h264_encoding = 0;
1121 codec_info->has_mpeg2_encoding = 0;
1126 static void gen9_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
1128 struct i965_driver_data *i965 = i965_driver_data(ctx);
1130 if (i965->intel.has_huc && codec_info->has_lp_h264_encoding)
1131 codec_info->lp_h264_brc_mode |= (VA_RC_CBR | VA_RC_VBR);
1133 if (i965->intel.has_huc && codec_info->has_lp_vp9_encoding)
1134 codec_info->lp_vp9_brc_mode |= (VA_RC_CQP | VA_RC_CBR | VA_RC_VBR);