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 /* Defines VA profile as a 32-bit unsigned integer mask */
45 #define VA_PROFILE_MASK(PROFILE) \
46 (1U << VAProfile##PROFILE)
48 extern struct hw_context *i965_proc_context_init(VADriverContextP, struct object_config *);
49 extern struct hw_context *g4x_dec_hw_context_init(VADriverContextP, struct object_config *);
50 extern bool genx_render_init(VADriverContextP);
52 static struct hw_codec_info g4x_hw_codec_info = {
53 .dec_hw_context_init = g4x_dec_hw_context_init,
54 .enc_hw_context_init = NULL,
55 .proc_hw_context_init = NULL,
56 .render_init = genx_render_init,
57 .post_processing_context_init = NULL,
61 .min_linear_wpitch = 16,
62 .min_linear_hpitch = 16,
64 .has_mpeg2_decoding = 1,
69 extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, struct object_config *);
70 extern void i965_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
72 static struct hw_codec_info ilk_hw_codec_info = {
73 .dec_hw_context_init = ironlake_dec_hw_context_init,
74 .enc_hw_context_init = NULL,
75 .proc_hw_context_init = i965_proc_context_init,
76 .render_init = genx_render_init,
77 .post_processing_context_init = i965_post_processing_context_init,
81 .min_linear_wpitch = 16,
82 .min_linear_hpitch = 16,
84 .has_mpeg2_decoding = 1,
85 .has_h264_decoding = 1,
87 .has_accelerated_putimage = 1,
92 extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *);
93 extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, struct object_config *);
94 static struct hw_codec_info snb_hw_codec_info = {
95 .dec_hw_context_init = gen6_dec_hw_context_init,
96 .enc_hw_context_init = gen6_enc_hw_context_init,
97 .proc_hw_context_init = i965_proc_context_init,
98 .render_init = genx_render_init,
99 .post_processing_context_init = i965_post_processing_context_init,
103 .min_linear_wpitch = 16,
104 .min_linear_hpitch = 16,
106 .h264_mvc_dec_profiles = VA_PROFILE_MASK(H264StereoHigh),
107 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
109 .has_mpeg2_decoding = 1,
110 .has_h264_decoding = 1,
111 .has_h264_encoding = 1,
112 .has_vc1_decoding = 1,
114 .has_accelerated_getimage = 1,
115 .has_accelerated_putimage = 1,
116 .has_tiled_surface = 1,
117 .has_di_motion_adptive = 1,
121 { VAProcFilterNoiseReduction, I965_RING_NULL },
122 { VAProcFilterDeinterlacing, I965_RING_NULL },
126 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
127 extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *);
128 static struct hw_codec_info ivb_hw_codec_info = {
129 .dec_hw_context_init = gen7_dec_hw_context_init,
130 .enc_hw_context_init = gen7_enc_hw_context_init,
131 .proc_hw_context_init = i965_proc_context_init,
132 .render_init = genx_render_init,
133 .post_processing_context_init = i965_post_processing_context_init,
137 .min_linear_wpitch = 64,
138 .min_linear_hpitch = 16,
140 .h264_mvc_dec_profiles = VA_PROFILE_MASK(H264StereoHigh),
141 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
142 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
144 .has_mpeg2_decoding = 1,
145 .has_mpeg2_encoding = 1,
146 .has_h264_decoding = 1,
147 .has_h264_encoding = 1,
148 .has_vc1_decoding = 1,
149 .has_jpeg_decoding = 1,
151 .has_accelerated_getimage = 1,
152 .has_accelerated_putimage = 1,
153 .has_tiled_surface = 1,
154 .has_di_motion_adptive = 1,
158 { VAProcFilterNoiseReduction, I965_RING_NULL },
159 { VAProcFilterDeinterlacing, I965_RING_NULL },
163 static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
165 extern struct hw_context *gen75_dec_hw_context_init(VADriverContextP, struct object_config *);
166 extern struct hw_context *gen75_enc_hw_context_init(VADriverContextP, struct object_config *);
167 extern struct hw_context *gen75_proc_context_init(VADriverContextP, struct object_config *);
168 static struct hw_codec_info hsw_hw_codec_info = {
169 .dec_hw_context_init = gen75_dec_hw_context_init,
170 .enc_hw_context_init = gen75_enc_hw_context_init,
171 .proc_hw_context_init = gen75_proc_context_init,
172 .render_init = genx_render_init,
173 .post_processing_context_init = i965_post_processing_context_init,
174 .preinit_hw_codec = hsw_hw_codec_preinit,
178 .min_linear_wpitch = 64,
179 .min_linear_hpitch = 16,
181 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
182 VA_PROFILE_MASK(H264MultiviewHigh)),
183 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
184 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
186 .has_mpeg2_decoding = 1,
187 .has_mpeg2_encoding = 1,
188 .has_h264_decoding = 1,
189 .has_h264_encoding = 1,
190 .has_vc1_decoding = 1,
191 .has_jpeg_decoding = 1,
193 .has_accelerated_getimage = 1,
194 .has_accelerated_putimage = 1,
195 .has_tiled_surface = 1,
196 .has_di_motion_adptive = 1,
197 .has_di_motion_compensated = 1,
198 .has_h264_mvc_encoding = 1,
202 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
203 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
204 { VAProcFilterSharpening, I965_RING_NULL },
205 { VAProcFilterColorBalance, I965_RING_VEBOX},
206 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
210 extern struct hw_context *gen8_dec_hw_context_init(VADriverContextP, struct object_config *);
211 extern struct hw_context *gen8_enc_hw_context_init(VADriverContextP, struct object_config *);
212 extern void gen8_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
213 static struct hw_codec_info bdw_hw_codec_info = {
214 .dec_hw_context_init = gen8_dec_hw_context_init,
215 .enc_hw_context_init = gen8_enc_hw_context_init,
216 .proc_hw_context_init = gen75_proc_context_init,
217 .render_init = gen8_render_init,
218 .post_processing_context_init = gen8_post_processing_context_init,
222 .min_linear_wpitch = 64,
223 .min_linear_hpitch = 16,
225 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
226 VA_PROFILE_MASK(H264MultiviewHigh)),
227 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
228 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
230 .has_mpeg2_decoding = 1,
231 .has_mpeg2_encoding = 1,
232 .has_h264_decoding = 1,
233 .has_h264_encoding = 1,
234 .has_vc1_decoding = 1,
235 .has_jpeg_decoding = 1,
237 .has_accelerated_getimage = 1,
238 .has_accelerated_putimage = 1,
239 .has_tiled_surface = 1,
240 .has_di_motion_adptive = 1,
241 .has_di_motion_compensated = 1,
242 .has_vp8_decoding = 1,
243 .has_h264_mvc_encoding = 1,
247 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
248 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
249 { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
250 { VAProcFilterColorBalance, I965_RING_VEBOX},
251 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
255 static struct hw_codec_info chv_hw_codec_info = {
256 .dec_hw_context_init = gen8_dec_hw_context_init,
257 .enc_hw_context_init = gen8_enc_hw_context_init,
258 .proc_hw_context_init = gen75_proc_context_init,
259 .render_init = gen8_render_init,
260 .post_processing_context_init = gen8_post_processing_context_init,
264 .min_linear_wpitch = 64,
265 .min_linear_hpitch = 16,
267 .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
268 VA_PROFILE_MASK(H264MultiviewHigh)),
269 .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
270 .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
272 .has_mpeg2_decoding = 1,
273 .has_mpeg2_encoding = 1,
274 .has_h264_decoding = 1,
275 .has_h264_encoding = 1,
276 .has_vc1_decoding = 1,
277 .has_jpeg_decoding = 1,
279 .has_accelerated_getimage = 1,
280 .has_accelerated_putimage = 1,
281 .has_tiled_surface = 1,
282 .has_di_motion_adptive = 1,
283 .has_di_motion_compensated = 1,
284 .has_vp8_decoding = 1,
285 .has_h264_mvc_encoding = 1,
289 { VAProcFilterNoiseReduction, I965_RING_VEBOX },
290 { VAProcFilterDeinterlacing, I965_RING_VEBOX },
291 { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
292 { VAProcFilterColorBalance, I965_RING_VEBOX},
293 { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
297 struct hw_codec_info *
298 i965_get_codec_info(int devid)
302 #define CHIPSET(id, family, dev, str) case id: return &family##_hw_codec_info;
303 #include "i965_pciids.h"
309 static const struct intel_device_info g4x_device_info = {
313 .max_wm_threads = 50, /* 10 * 5 */
318 static const struct intel_device_info ilk_device_info = {
322 .max_wm_threads = 72, /* 12 * 6 */
325 static const struct intel_device_info snb_gt1_device_info = {
330 .max_wm_threads = 40,
333 static const struct intel_device_info snb_gt2_device_info = {
338 .max_wm_threads = 80,
341 static const struct intel_device_info ivb_gt1_device_info = {
346 .max_wm_threads = 48,
351 static const struct intel_device_info ivb_gt2_device_info = {
356 .max_wm_threads = 172,
361 static const struct intel_device_info byt_device_info = {
366 .max_wm_threads = 48,
372 static const struct intel_device_info hsw_gt1_device_info = {
377 .max_wm_threads = 102,
382 static const struct intel_device_info hsw_gt2_device_info = {
387 .max_wm_threads = 204,
392 static const struct intel_device_info hsw_gt3_device_info = {
397 .max_wm_threads = 408,
402 static const struct intel_device_info bdw_device_info = {
406 .max_wm_threads = 64, /* per PSD */
409 static const struct intel_device_info chv_device_info = {
413 .max_wm_threads = 64, /* per PSD */
418 const struct intel_device_info *
419 i965_get_device_info(int devid)
423 #define CHIPSET(id, family, dev, str) case id: return &dev##_device_info;
424 #include "i965_pciids.h"
430 static void cpuid(unsigned int op,
431 uint32_t *eax, uint32_t *ebx,
432 uint32_t *ecx, uint32_t *edx)
434 __cpuid_count(op, 0, *eax, *ebx, *ecx, *edx);
438 * This function doesn't check the length. And the caller should
439 * assure that the length of input string should be greater than 48.
442 static int intel_driver_detect_cpustring(char *model_id)
446 if (model_id == NULL)
449 rdata = (uint32_t *)model_id;
451 /* obtain the max supported extended CPUID info */
452 cpuid(0x80000000, &rdata[0], &rdata[1], &rdata[2], &rdata[3]);
454 /* If the max extended CPUID info is less than 0x80000004, fail */
455 if (rdata[0] < 0x80000004)
458 /* obtain the CPUID string */
459 cpuid(0x80000002, &rdata[0], &rdata[1], &rdata[2], &rdata[3]);
460 cpuid(0x80000003, &rdata[4], &rdata[5], &rdata[6], &rdata[7]);
461 cpuid(0x80000004, &rdata[8], &rdata[9], &rdata[10], &rdata[11]);
463 *(model_id + 48) = '\0';
468 * the hook_list for HSW.
469 * It is captured by /proc/cpuinfo and the space character is stripped.
471 const static char *hsw_cpu_hook_list[] = {
472 "Intel(R)Pentium(R)3556U",
473 "Intel(R)Pentium(R)3560Y",
474 "Intel(R)Pentium(R)3550M",
475 "Intel(R)Celeron(R)2980U",
476 "Intel(R)Celeron(R)2955U",
477 "Intel(R)Celeron(R)2950M",
480 static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
482 char model_string[64];
483 char *model_ptr, *tmp_ptr;
484 int i, model_len, list_len;
487 memset(model_string, 0, sizeof(model_string));
489 /* If it can't detect cpu model_string, leave it alone */
490 if (intel_driver_detect_cpustring(model_string))
493 /* strip the cpufreq info */
494 model_ptr = model_string;
495 tmp_ptr = strstr(model_ptr, "@");
500 /* strip the space character */
501 model_ptr = model_string;
502 model_len = strlen(model_string);
503 for (i = 0; i < model_len; i++) {
504 if (model_string[i] != ' ') {
505 *model_ptr = model_string[i];
512 list_len = sizeof(hsw_cpu_hook_list) / sizeof(char *);
513 model_len = strlen(model_string);
514 for (i = 0; i < list_len; i++) {
515 model_ptr = (char *)hsw_cpu_hook_list[i];
517 if (strlen(model_ptr) != model_len)
520 if (strncasecmp(model_string, model_ptr, model_len) == 0) {
527 codec_info->has_h264_encoding = 0;
528 codec_info->has_h264_mvc_encoding = 0;
529 codec_info->has_mpeg2_encoding = 0;