+#define ENCODER_QUALITY_RANGE 2
+#define ENCODER_QUALITY_RANGE_AVC 7
+#define ENCODER_QUALITY_RANGE_HEVC 7
+#define ENCODER_QUALITY_RANGE_VP9 7
+#define ENCODER_DEFAULT_QUALITY 1
+#define ENCODER_DEFAULT_QUALITY_AVC 4
+#define ENCODER_DEFAULT_QUALITY_HEVC 4
+#define ENCODER_DEFAULT_QUALITY_VP9 4
+#define ENCODER_HIGH_QUALITY ENCODER_DEFAULT_QUALITY
+#define ENCODER_LOW_QUALITY 2
+
+#define I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT 32
+#define I965_MAX_NUM_ROI_REGIONS 8
+#define I965_MAX_NUM_SLICE 32
+
+#define ENCODER_LP_QUALITY_RANGE 8
+
+#define STATS_MAX_NUM_PAST_REFS 1
+#define STATS_MAX_NUM_FUTURE_REFS 1
+#define STATS_MAX_NUM_OUTPUTS 2
+#define STATS_INTERLACED_SUPPORT 0
+
+#define HAS_MPEG2_DECODING(ctx) ((ctx)->codec_info->has_mpeg2_decoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_MPEG2_ENCODING(ctx) ((ctx)->codec_info->has_mpeg2_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_H264_DECODING(ctx) ((ctx)->codec_info->has_h264_decoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_H264_ENCODING(ctx) ((ctx)->codec_info->has_h264_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_LP_H264_ENCODING(ctx) ((ctx)->codec_info->has_lp_h264_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_FEI_H264_ENCODING(ctx) ((ctx)->codec_info->has_fei_h264_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_H264_PREENC(ctx) ((ctx)->codec_info->has_h264_preenc)
+
+#define HAS_VC1_DECODING(ctx) ((ctx)->codec_info->has_vc1_decoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_JPEG_DECODING(ctx) ((ctx)->codec_info->has_jpeg_decoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_JPEG_ENCODING(ctx) ((ctx)->codec_info->has_jpeg_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_VPP(ctx) ((ctx)->codec_info->has_vpp)
+
+#define HAS_ACCELERATED_GETIMAGE(ctx) ((ctx)->codec_info->has_accelerated_getimage)
+
+#define HAS_ACCELERATED_PUTIMAGE(ctx) ((ctx)->codec_info->has_accelerated_putimage)
+
+#define HAS_TILED_SURFACE(ctx) ((ctx)->codec_info->has_tiled_surface)
+
+#define HAS_VP8_DECODING(ctx) ((ctx)->codec_info->has_vp8_decoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_VP8_ENCODING(ctx) ((ctx)->codec_info->has_vp8_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_H264_MVC_DECODING(ctx) \
+ (HAS_H264_DECODING(ctx) && (ctx)->codec_info->h264_mvc_dec_profiles)
+
+#define HAS_H264_MVC_DECODING_PROFILE(ctx, profile) \
+ (HAS_H264_MVC_DECODING(ctx) && \
+ ((ctx)->codec_info->h264_mvc_dec_profiles & (1U << profile)))
+
+#define HAS_H264_MVC_ENCODING(ctx) ((ctx)->codec_info->has_h264_mvc_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_HEVC_DECODING(ctx) ((ctx)->codec_info->has_hevc_decoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_HEVC_ENCODING(ctx) ((ctx)->codec_info->has_hevc_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_VP9_DECODING(ctx) ((ctx)->codec_info->has_vp9_decoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_VP9_DECODING_PROFILE(ctx, profile) \
+ (HAS_VP9_DECODING(ctx) && \
+ ((ctx)->codec_info->vp9_dec_profiles & (1U << (profile - VAProfileVP9Profile0))))
+
+#define HAS_HEVC10_DECODING(ctx) ((ctx)->codec_info->has_hevc10_decoding && \
+ (ctx)->intel.has_bsd)
+#define HAS_HEVC10_ENCODING(ctx) ((ctx)->codec_info->has_hevc10_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_VP9_ENCODING(ctx) ((ctx)->codec_info->has_vp9_encoding && \
+ (ctx)->intel.has_bsd)
+
+#define HAS_LP_VP9_ENCODING(ctx) ((ctx)->codec_info->has_lp_vp9_encoding && \
+ (ctx)->intel.has_huc)
+
+#define HAS_VP9_ENCODING_PROFILE(ctx, profile) \
+ (HAS_VP9_ENCODING(ctx) && \
+ ((ctx)->codec_info->vp9_enc_profiles & (1U << (profile - VAProfileVP9Profile0))))
+
+struct i965_surface {