Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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