OSDN Git Service

Initial support for Broxton in the intel-driver
[android-x86/hardware-intel-common-vaapi.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 #include <string.h>
31 #include <strings.h>
32 #include <errno.h>
33 #include <cpuid.h>
34
35 /* Extra set of chroma formats supported for H.264 decoding (beyond YUV 4:2:0) */
36 #define EXTRA_H264_DEC_CHROMA_FORMATS \
37     (VA_RT_FORMAT_YUV400)
38
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 | \
42      VA_RT_FORMAT_YUV444)
43
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)
47      
48 /* Defines VA profile as a 32-bit unsigned integer mask */
49 #define VA_PROFILE_MASK(PROFILE) \
50     (1U << VAProfile##PROFILE)
51
52 extern struct hw_context *i965_proc_context_init(VADriverContextP, struct object_config *);
53 extern struct hw_context *g4x_dec_hw_context_init(VADriverContextP, struct object_config *);
54 extern bool genx_render_init(VADriverContextP);
55
56 static struct hw_codec_info g4x_hw_codec_info = {
57     .dec_hw_context_init = g4x_dec_hw_context_init,
58     .enc_hw_context_init = NULL,
59     .proc_hw_context_init = NULL,
60     .render_init = genx_render_init,
61     .post_processing_context_init = NULL,
62
63     .max_width = 2048,
64     .max_height = 2048,
65     .min_linear_wpitch = 16,
66     .min_linear_hpitch = 16,
67
68     .has_mpeg2_decoding = 1,
69
70     .num_filters = 0,
71 };
72
73 extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, struct object_config *);
74 extern void i965_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
75
76 static struct hw_codec_info ilk_hw_codec_info = {
77     .dec_hw_context_init = ironlake_dec_hw_context_init,
78     .enc_hw_context_init = NULL,
79     .proc_hw_context_init = i965_proc_context_init,
80     .render_init = genx_render_init,
81     .post_processing_context_init = i965_post_processing_context_init,
82
83     .max_width = 2048,
84     .max_height = 2048,
85     .min_linear_wpitch = 16,
86     .min_linear_hpitch = 16,
87
88     .has_mpeg2_decoding = 1,
89     .has_h264_decoding = 1,
90     .has_vpp = 1,
91     .has_accelerated_putimage = 1,
92
93     .num_filters = 0,
94 };
95
96 static void gen6_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
97
98 extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *);
99 extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, struct object_config *);
100 static struct hw_codec_info snb_hw_codec_info = {
101     .dec_hw_context_init = gen6_dec_hw_context_init,
102     .enc_hw_context_init = gen6_enc_hw_context_init,
103     .proc_hw_context_init = i965_proc_context_init,
104     .render_init = genx_render_init,
105     .post_processing_context_init = i965_post_processing_context_init,
106     .preinit_hw_codec = gen6_hw_codec_preinit,
107
108     .max_width = 2048,
109     .max_height = 2048,
110     .min_linear_wpitch = 16,
111     .min_linear_hpitch = 16,
112
113     .h264_mvc_dec_profiles = VA_PROFILE_MASK(H264StereoHigh),
114     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
115
116     .has_mpeg2_decoding = 1,
117     .has_h264_decoding = 1,
118     .has_h264_encoding = 1,
119     .has_vc1_decoding = 1,
120     .has_vpp = 1,
121     .has_accelerated_getimage = 1,
122     .has_accelerated_putimage = 1,
123     .has_tiled_surface = 1,
124     .has_di_motion_adptive = 1,
125
126     .num_filters = 2,
127     .filters = {
128         { VAProcFilterNoiseReduction, I965_RING_NULL },
129         { VAProcFilterDeinterlacing, I965_RING_NULL },
130     },
131 };
132
133 static void gen7_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
134
135 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
136 extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *);
137 static struct hw_codec_info ivb_hw_codec_info = {
138     .dec_hw_context_init = gen7_dec_hw_context_init,
139     .enc_hw_context_init = gen7_enc_hw_context_init,
140     .proc_hw_context_init = i965_proc_context_init,
141     .render_init = genx_render_init,
142     .post_processing_context_init = i965_post_processing_context_init,
143     .preinit_hw_codec = gen7_hw_codec_preinit,
144
145     .max_width = 4096,
146     .max_height = 4096,
147     .min_linear_wpitch = 64,
148     .min_linear_hpitch = 16,
149
150     .h264_mvc_dec_profiles = VA_PROFILE_MASK(H264StereoHigh),
151     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
152     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
153
154     .has_mpeg2_decoding = 1,
155     .has_mpeg2_encoding = 1,
156     .has_h264_decoding = 1,
157     .has_h264_encoding = 1,
158     .has_vc1_decoding = 1,
159     .has_jpeg_decoding = 1,
160     .has_vpp = 1,
161     .has_accelerated_getimage = 1,
162     .has_accelerated_putimage = 1,
163     .has_tiled_surface = 1,
164     .has_di_motion_adptive = 1,
165     .has_di_motion_compensated = 1,
166
167     .num_filters = 2,
168     .filters = {
169         { VAProcFilterNoiseReduction, I965_RING_NULL },
170         { VAProcFilterDeinterlacing, I965_RING_NULL },
171     },
172 };
173
174 static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info);
175
176 extern struct hw_context *gen75_dec_hw_context_init(VADriverContextP, struct object_config *);
177 extern struct hw_context *gen75_enc_hw_context_init(VADriverContextP, struct object_config *);
178 extern struct hw_context *gen75_proc_context_init(VADriverContextP, struct object_config *);
179 static struct hw_codec_info hsw_hw_codec_info = {
180     .dec_hw_context_init = gen75_dec_hw_context_init,
181     .enc_hw_context_init = gen75_enc_hw_context_init,
182     .proc_hw_context_init = gen75_proc_context_init,
183     .render_init = genx_render_init,
184     .post_processing_context_init = i965_post_processing_context_init,
185     .preinit_hw_codec = hsw_hw_codec_preinit,
186
187     .max_width = 4096,
188     .max_height = 4096,
189     .min_linear_wpitch = 64,
190     .min_linear_hpitch = 16,
191
192     .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
193                               VA_PROFILE_MASK(H264MultiviewHigh)),
194     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
195     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
196
197     .has_mpeg2_decoding = 1,
198     .has_mpeg2_encoding = 1,
199     .has_h264_decoding = 1,
200     .has_h264_encoding = 1,
201     .has_vc1_decoding = 1,
202     .has_jpeg_decoding = 1,
203     .has_vpp = 1,
204     .has_accelerated_getimage = 1,
205     .has_accelerated_putimage = 1,
206     .has_tiled_surface = 1,
207     .has_di_motion_adptive = 1,
208     .has_di_motion_compensated = 1,
209     .has_h264_mvc_encoding = 1,
210
211     .num_filters = 5,
212     .filters = {
213         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
214         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
215         { VAProcFilterSharpening, I965_RING_NULL },
216         { VAProcFilterColorBalance, I965_RING_VEBOX},
217         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
218     },
219 };
220
221 extern struct hw_context *gen8_dec_hw_context_init(VADriverContextP, struct object_config *);
222 extern struct hw_context *gen8_enc_hw_context_init(VADriverContextP, struct object_config *);
223 extern void gen8_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
224 static struct hw_codec_info bdw_hw_codec_info = {
225     .dec_hw_context_init = gen8_dec_hw_context_init,
226     .enc_hw_context_init = gen8_enc_hw_context_init,
227     .proc_hw_context_init = gen75_proc_context_init,
228     .render_init = gen8_render_init,
229     .post_processing_context_init = gen8_post_processing_context_init,
230
231     .max_width = 4096,
232     .max_height = 4096,
233     .min_linear_wpitch = 128,
234     .min_linear_hpitch = 16,
235
236     .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
237                               VA_PROFILE_MASK(H264MultiviewHigh)),
238     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
239     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
240
241     .has_mpeg2_decoding = 1,
242     .has_mpeg2_encoding = 1,
243     .has_h264_decoding = 1,
244     .has_h264_encoding = 1,
245     .has_vc1_decoding = 1,
246     .has_jpeg_decoding = 1,
247     .has_vpp = 1,
248     .has_accelerated_getimage = 1,
249     .has_accelerated_putimage = 1,
250     .has_tiled_surface = 1,
251     .has_di_motion_adptive = 1,
252     .has_di_motion_compensated = 1,
253     .has_vp8_decoding = 1,
254     .has_h264_mvc_encoding = 1,
255
256     .num_filters = 5,
257     .filters = {
258         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
259         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
260         { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
261         { VAProcFilterColorBalance, I965_RING_VEBOX},
262         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
263     },
264 };
265
266 extern struct hw_context *gen9_dec_hw_context_init(VADriverContextP, struct object_config *);
267 static struct hw_codec_info chv_hw_codec_info = {
268     .dec_hw_context_init = gen9_dec_hw_context_init,
269     .enc_hw_context_init = gen8_enc_hw_context_init,
270     .proc_hw_context_init = gen75_proc_context_init,
271     .render_init = gen8_render_init,
272     .post_processing_context_init = gen8_post_processing_context_init,
273
274     .max_width = 4096,
275     .max_height = 4096,
276     .min_linear_wpitch = 128,
277     .min_linear_hpitch = 16,
278
279     .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
280                               VA_PROFILE_MASK(H264MultiviewHigh)),
281     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
282     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
283     .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
284
285     .has_mpeg2_decoding = 1,
286     .has_mpeg2_encoding = 1,
287     .has_h264_decoding = 1,
288     .has_h264_encoding = 1,
289     .has_vc1_decoding = 1,
290     .has_jpeg_decoding = 1,
291     .has_jpeg_encoding = 1,
292     .has_vpp = 1,
293     .has_accelerated_getimage = 1,
294     .has_accelerated_putimage = 1,
295     .has_tiled_surface = 1,
296     .has_di_motion_adptive = 1,
297     .has_di_motion_compensated = 1,
298     .has_vp8_decoding = 1,
299     .has_vp8_encoding = 1,
300     .has_h264_mvc_encoding = 1,
301     .has_hevc_decoding = 1,
302
303     .num_filters = 5,
304     .filters = {
305         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
306         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
307         { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
308         { VAProcFilterColorBalance, I965_RING_VEBOX},
309         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
310     },
311 };
312
313 extern struct hw_context *gen9_enc_hw_context_init(VADriverContextP, struct object_config *);
314 extern void gen9_post_processing_context_init(VADriverContextP, void *, struct intel_batchbuffer *);
315 static struct hw_codec_info skl_hw_codec_info = {
316     .dec_hw_context_init = gen9_dec_hw_context_init,
317     .enc_hw_context_init = gen9_enc_hw_context_init,
318     .proc_hw_context_init = gen75_proc_context_init,
319     .render_init = gen9_render_init,
320     .post_processing_context_init = gen9_post_processing_context_init,
321
322     .max_width = 4096,
323     .max_height = 4096,
324     .min_linear_wpitch = 128,
325     .min_linear_hpitch = 16,
326
327     .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
328                               VA_PROFILE_MASK(H264MultiviewHigh)),
329     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
330     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
331     .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
332
333     .has_mpeg2_decoding = 1,
334     .has_mpeg2_encoding = 1,
335     .has_h264_decoding = 1,
336     .has_h264_encoding = 1,
337     .has_vc1_decoding = 1,
338     .has_jpeg_decoding = 1,
339     .has_jpeg_encoding = 1,
340     .has_vpp = 1,
341     .has_accelerated_getimage = 1,
342     .has_accelerated_putimage = 1,
343     .has_tiled_surface = 1,
344     .has_di_motion_adptive = 1,
345     .has_di_motion_compensated = 1,
346     .has_vp8_decoding = 1,
347     .has_vp8_encoding = 1,
348     .has_h264_mvc_encoding = 1,
349     .has_hevc_decoding = 1,
350     .has_hevc_encoding = 1,
351
352     .num_filters = 5,
353     .filters = {
354         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
355         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
356         { VAProcFilterSharpening, I965_RING_NULL }, /* need to rebuild the shader for BDW */
357         { VAProcFilterColorBalance, I965_RING_VEBOX},
358         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
359     },
360 };
361
362
363 static struct hw_codec_info bxt_hw_codec_info = {
364     .dec_hw_context_init = gen9_dec_hw_context_init,
365     .enc_hw_context_init = gen9_enc_hw_context_init,
366     .proc_hw_context_init = gen75_proc_context_init,
367     .render_init = gen9_render_init,
368     .post_processing_context_init = gen9_post_processing_context_init,
369
370     .max_width = 4096,
371     .max_height = 4096,
372     .min_linear_wpitch = 64,
373     .min_linear_hpitch = 16,
374
375     .h264_mvc_dec_profiles = (VA_PROFILE_MASK(H264StereoHigh) |
376                               VA_PROFILE_MASK(H264MultiviewHigh)),
377     .h264_dec_chroma_formats = EXTRA_H264_DEC_CHROMA_FORMATS,
378     .jpeg_dec_chroma_formats = EXTRA_JPEG_DEC_CHROMA_FORMATS,
379     .jpeg_enc_chroma_formats = EXTRA_JPEG_ENC_CHROMA_FORMATS,
380
381     .has_mpeg2_decoding = 1,
382     .has_h264_decoding = 1,
383     .has_h264_encoding = 1,
384     .has_vc1_decoding = 1,
385     .has_jpeg_decoding = 1,
386     .has_jpeg_encoding = 1,
387     .has_vpp = 1,
388     .has_accelerated_getimage = 1,
389     .has_accelerated_putimage = 1,
390     .has_tiled_surface = 1,
391     .has_di_motion_adptive = 1,
392     .has_di_motion_compensated = 1,
393     .has_vp8_decoding = 1,
394     .has_vp8_encoding = 1,
395     .has_h264_mvc_encoding = 1,
396     .has_hevc_decoding = 1,
397     .has_hevc_encoding = 1,
398
399     .num_filters = 5,
400     .filters = {
401         { VAProcFilterNoiseReduction, I965_RING_VEBOX },
402         { VAProcFilterDeinterlacing, I965_RING_VEBOX },
403         { VAProcFilterSharpening, I965_RING_NULL },
404         { VAProcFilterColorBalance, I965_RING_VEBOX},
405         { VAProcFilterSkinToneEnhancement, I965_RING_VEBOX},
406     },
407 };
408
409
410 struct hw_codec_info *
411 i965_get_codec_info(int devid)
412 {
413     switch (devid) {
414 #undef CHIPSET
415 #define CHIPSET(id, family, dev, str) case id: return &family##_hw_codec_info;
416 #include "i965_pciids.h"
417     default:
418         return NULL;
419     }
420 }
421
422 static const struct intel_device_info g4x_device_info = {
423     .gen = 4,
424
425     .urb_size = 384,
426     .max_wm_threads = 50,       /* 10 * 5 */
427
428     .is_g4x = 1,
429 };
430
431 static const struct intel_device_info ilk_device_info = {
432     .gen = 5,
433
434     .urb_size = 1024,
435     .max_wm_threads = 72,       /* 12 * 6 */
436 };
437
438 static const struct intel_device_info snb_gt1_device_info = {
439     .gen = 6,
440     .gt = 1,
441
442     .urb_size = 1024,
443     .max_wm_threads = 40,
444 };
445
446 static const struct intel_device_info snb_gt2_device_info = {
447     .gen = 6,
448     .gt = 2,
449
450     .urb_size = 1024,
451     .max_wm_threads = 80,
452 };
453
454 static const struct intel_device_info ivb_gt1_device_info = {
455     .gen = 7,
456     .gt = 1,
457
458     .urb_size = 4096,
459     .max_wm_threads = 48,
460
461     .is_ivybridge = 1,
462 };
463
464 static const struct intel_device_info ivb_gt2_device_info = {
465     .gen = 7,
466     .gt = 2,
467
468     .urb_size = 4096,
469     .max_wm_threads = 172,
470
471     .is_ivybridge = 1,
472 };
473
474 static const struct intel_device_info byt_device_info = {
475     .gen = 7,
476     .gt = 1,
477
478     .urb_size = 4096,
479     .max_wm_threads = 48,
480
481     .is_ivybridge = 1,
482     .is_baytrail = 1,
483 };
484
485 static const struct intel_device_info hsw_gt1_device_info = {
486     .gen = 7,
487     .gt = 1,
488
489     .urb_size = 4096,
490     .max_wm_threads = 102,
491
492     .is_haswell = 1,
493 };
494
495 static const struct intel_device_info hsw_gt2_device_info = {
496     .gen = 7,
497     .gt = 2,
498
499     .urb_size = 4096,
500     .max_wm_threads = 204,
501
502     .is_haswell = 1,
503 };
504
505 static const struct intel_device_info hsw_gt3_device_info = {
506     .gen = 7,
507     .gt = 3,
508
509     .urb_size = 4096,
510     .max_wm_threads = 408,
511
512     .is_haswell = 1,
513 };
514
515 static const struct intel_device_info bdw_device_info = {
516     .gen = 8,
517
518     .urb_size = 4096,
519     .max_wm_threads = 64,       /* per PSD */
520 };
521
522 static const struct intel_device_info chv_device_info = {
523     .gen = 8,
524
525     .urb_size = 4096,
526     .max_wm_threads = 64,       /* per PSD */
527
528     .is_cherryview = 1,
529 };
530
531 static const struct intel_device_info skl_device_info = {
532     .gen = 9,
533
534     .urb_size = 4096,
535     .max_wm_threads = 64,       /* per PSD */
536 };
537
538 static const struct intel_device_info bxt_device_info = {
539     .gen = 9,
540
541     .urb_size = 4096,
542     .max_wm_threads = 64,       /* per PSD */
543     .is_broxton = 1,
544 };
545
546 const struct intel_device_info *
547 i965_get_device_info(int devid)
548 {
549     switch (devid) {
550 #undef CHIPSET
551 #define CHIPSET(id, family, dev, str) case id: return &dev##_device_info;
552 #include "i965_pciids.h"
553     default:
554         return NULL;
555     }
556 }
557
558 static void cpuid(unsigned int op,
559                          uint32_t *eax, uint32_t *ebx,
560                          uint32_t *ecx, uint32_t *edx)
561 {
562     __cpuid_count(op, 0, *eax, *ebx, *ecx, *edx);
563 }
564
565 /*
566  * This function doesn't check the length. And the caller should
567  * assure that the length of input string should be greater than 48.
568  */
569 static int intel_driver_detect_cpustring(char *model_id)
570 {
571     uint32_t *rdata;
572
573     if (model_id == NULL)
574         return -EINVAL;
575
576     rdata = (uint32_t *)model_id;
577
578     /* obtain the max supported extended CPUID info */
579     cpuid(0x80000000, &rdata[0], &rdata[1], &rdata[2], &rdata[3]);
580
581     /* If the max extended CPUID info is less than 0x80000004, fail */
582     if (rdata[0] < 0x80000004)
583         return -EINVAL;
584
585     /* obtain the CPUID string */
586     cpuid(0x80000002, &rdata[0], &rdata[1], &rdata[2], &rdata[3]);
587     cpuid(0x80000003, &rdata[4], &rdata[5], &rdata[6], &rdata[7]);
588     cpuid(0x80000004, &rdata[8], &rdata[9], &rdata[10], &rdata[11]);
589
590     *(model_id + 48) = '\0';
591     return 0;
592 }
593
594 /*
595  * the hook_list for HSW.
596  * It is captured by /proc/cpuinfo and the space character is stripped.
597  */
598 const static char *hsw_cpu_hook_list[] =  {
599 "Intel(R)Pentium(R)3556U",
600 "Intel(R)Pentium(R)3560Y",
601 "Intel(R)Pentium(R)3550M",
602 "Intel(R)Celeron(R)2980U",
603 "Intel(R)Celeron(R)2955U",
604 "Intel(R)Celeron(R)2950M",
605 };
606
607 static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
608 {
609     char model_string[64];
610     char *model_ptr, *tmp_ptr;
611     int i, model_len, list_len;
612     bool found;
613
614     memset(model_string, 0, sizeof(model_string));
615
616     /* If it can't detect cpu model_string, leave it alone */
617     if (intel_driver_detect_cpustring(model_string))
618         return;
619
620     /* strip the cpufreq info */
621     model_ptr = model_string;
622     tmp_ptr = strstr(model_ptr, "@");
623    
624     if (tmp_ptr)
625         *tmp_ptr = '\0';
626
627     /* strip the space character and convert to the lower case */
628     model_ptr = model_string;
629     model_len = strlen(model_string);
630     for (i = 0; i < model_len; i++) {
631          if (model_string[i] != ' ') {
632              *model_ptr = model_string[i];
633              model_ptr++;
634          }
635     }
636     *model_ptr = '\0';
637
638     found = false;
639     list_len = sizeof(hsw_cpu_hook_list) / sizeof(char *);
640     model_len = strlen(model_string);
641     for (i = 0; i < list_len; i++) {
642         model_ptr = (char *)hsw_cpu_hook_list[i];
643
644         if (strlen(model_ptr) != model_len)
645             continue;
646
647         if (strncasecmp(model_string, model_ptr, model_len) == 0) {
648             found = true;
649             break;
650         }
651     }
652
653     if (found) {
654         codec_info->has_h264_encoding = 0;
655         codec_info->has_h264_mvc_encoding = 0;
656         codec_info->has_mpeg2_encoding = 0;
657     }
658     return;
659 }
660
661 /*
662  * the hook_list for Sandybride.
663  * It is captured by /proc/cpuinfo and the space character is stripped.
664  */
665 const static char *gen6_cpu_hook_list[] =  {
666 "Intel(R)Celeron(R)CPU847",
667 "Intel(R)Celeron(R)CPU867",
668 };
669
670 static void gen6_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
671 {
672     char model_string[64];
673     char *model_ptr, *tmp_ptr;
674     int i, model_len, list_len;
675     bool found;
676
677     memset(model_string, 0, sizeof(model_string));
678
679     /* If it can't detect cpu model_string, leave it alone */
680     if (intel_driver_detect_cpustring(model_string))
681         return;
682
683     /* strip the cpufreq info */
684     model_ptr = model_string;
685     tmp_ptr = strstr(model_ptr, "@");
686
687     if (tmp_ptr)
688         *tmp_ptr = '\0';
689
690     /* strip the space character and convert to the lower case */
691     model_ptr = model_string;
692     model_len = strlen(model_string);
693     for (i = 0; i < model_len; i++) {
694          if (model_string[i] != ' ') {
695              *model_ptr = model_string[i];
696              model_ptr++;
697          }
698     }
699     *model_ptr = '\0';
700
701     found = false;
702     list_len = sizeof(gen6_cpu_hook_list) / sizeof(char *);
703     model_len = strlen(model_string);
704     for (i = 0; i < list_len; i++) {
705         model_ptr = (char *)gen6_cpu_hook_list[i];
706
707         if (strlen(model_ptr) != model_len)
708             continue;
709
710         if (strncasecmp(model_string, model_ptr, model_len) == 0) {
711             found = true;
712             break;
713         }
714     }
715
716     if (found) {
717         codec_info->has_h264_encoding = 0;
718     }
719     return;
720 }
721
722 /*
723  * the hook_list for Ivybridge.
724  * It is captured by /proc/cpuinfo and the space character is stripped.
725  */
726 const static char *gen7_cpu_hook_list[] =  {
727 "Intel(R)Celeron(R)CPU1007U",
728 };
729
730 static void gen7_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *codec_info)
731 {
732     char model_string[64];
733     char *model_ptr, *tmp_ptr;
734     int i, model_len, list_len;
735     bool found;
736
737     memset(model_string, 0, sizeof(model_string));
738
739     /* If it can't detect cpu model_string, leave it alone */
740     if (intel_driver_detect_cpustring(model_string))
741         return;
742
743     /* strip the cpufreq info */
744     model_ptr = model_string;
745     tmp_ptr = strstr(model_ptr, "@");
746
747     if (tmp_ptr)
748         *tmp_ptr = '\0';
749
750     /* strip the space character and convert to the lower case */
751     model_ptr = model_string;
752     model_len = strlen(model_string);
753     for (i = 0; i < model_len; i++) {
754          if (model_string[i] != ' ') {
755              *model_ptr = model_string[i];
756              model_ptr++;
757          }
758     }
759     *model_ptr = '\0';
760
761     found = false;
762     list_len = sizeof(gen7_cpu_hook_list) / sizeof(char *);
763     model_len = strlen(model_string);
764     for (i = 0; i < list_len; i++) {
765         model_ptr = (char *)gen7_cpu_hook_list[i];
766
767         if (strlen(model_ptr) != model_len)
768             continue;
769
770         if (strncasecmp(model_string, model_ptr, model_len) == 0) {
771             found = true;
772             break;
773         }
774     }
775
776     if (found) {
777         codec_info->has_h264_encoding = 0;
778         codec_info->has_mpeg2_encoding = 0;
779     }
780     return;
781 }