MPEG-2 encoding path
[profile/ivi/vaapi-intel-driver.git] / src / gen75_vpp_vebox.h
1 /*
2  * Copyright © 2010 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  * Authors:
25  *    Li Xiaowei <xiaowei.a.li@intel.com>
26  *
27  */
28
29 #ifndef _GEN75_VPP_VEBOX_H
30 #define _GEN75_VPP_VEBOX_H
31
32 #include <xf86drm.h>
33 #include <drm.h>
34 #include <i915_drm.h>
35 #include <intel_bufmgr.h>
36 #include <va/va_vpp.h>
37 #include "i965_drv_video.h"
38
39 #include "i965_post_processing.h"
40
41 #define INPUT_SURFACE  0
42 #define OUTPUT_SURFACE 1
43
44 #define VPP_DNDI_DN        0x00000001
45 #define VPP_DNDI_DI        0x00000002
46 #define VPP_IECP_STD_STE   0x00000100
47 #define VPP_IECP_ACE       0x00000200
48 #define VPP_IECP_TCC       0x00000400
49 #define VPP_IECP_PRO_AMP   0x00000800
50 #define VPP_IECP_CSC       0x00001000
51 #define VPP_IECP_AOI       0x00002000
52 #define MAX_FILTER_SUM     8
53
54 #define PRE_FORMAT_CONVERT      0x01
55 #define POST_FORMAT_CONVERT     0x02
56 #define POST_SCALING_CONVERT    0x04
57
58 enum {
59     FRAME_IN_CURRENT = 0,
60     FRAME_IN_PREVIOUS,
61     FRAME_IN_STMM,
62     FRAME_OUT_STMM,
63     FRAME_OUT_CURRENT_DN,
64     FRAME_OUT_CURRENT,
65     FRAME_OUT_PREVIOUS,
66     FRAME_OUT_STATISTIC,
67     FRAME_STORE_SUM,
68 };
69
70 enum SURFACE_FORMAT{
71     YCRCB_NORMAL = 0,
72     YCRCB_SWAPUVY,
73     YCRCB_SWAPUV,
74     YCRCB_SWAPY,
75     PLANAR_420_8,  //NV12
76     PACKED_444A_8,
77     PACKED_422_16,
78     R10G10B10A2_UNORM_SRGB,
79     R8G8B8A8_UNORM_SRGB,
80     PACKED_444_16,
81     PLANAR_422_16,
82     Y8_UNORM,
83     PLANAR_420_16,
84     R16G16B16A16,
85     SURFACE_FORMAT_SUM
86 };
87
88 typedef struct veb_frame_store {
89     VASurfaceID surface_id;
90     dri_bo  *bo;
91     unsigned char  valid;
92     unsigned int is_internal_surface;
93 } VEBFrameStore;
94
95 typedef struct veb_buffer {
96     dri_bo  *bo;
97     void *  ptr;
98     unsigned char  valid;
99 } VEBBuffer;
100
101 struct intel_vebox_context
102 {
103     struct intel_batchbuffer *batch;
104
105     VASurfaceID surface_input;
106     VASurfaceID surface_input_vebox;
107     VASurfaceID surface_output;
108     VASurfaceID surface_output_vebox;
109     VASurfaceID surface_output_scaled;
110
111     unsigned int fourcc_input;
112     unsigned int fourcc_output;
113
114     int width_input;
115     int height_input;
116     int width_output;
117     int height_output;
118
119     VEBFrameStore frame_store[FRAME_STORE_SUM];
120
121     VEBBuffer dndi_state_table;
122     VEBBuffer iecp_state_table;
123     VEBBuffer gamut_state_table;
124     VEBBuffer vertex_state_table;
125
126     unsigned int  filters_mask;
127     unsigned char is_first_frame;
128
129     VAProcPipelineParameterBuffer * pipeline_param;
130     void * filter_dn;
131     void * filter_di;
132     void * filter_iecp_std;
133     void * filter_iecp_ace;
134     void * filter_iecp_tcc;
135     void * filter_iecp_amp;
136     void * filter_iecp_csc;
137
138     unsigned char format_convert_flags;
139
140 };
141
142 VAStatus gen75_vebox_process_picture(VADriverContextP ctx,
143                          struct intel_vebox_context *proc_ctx);
144
145 void gen75_vebox_context_destroy(VADriverContextP ctx, 
146                           struct intel_vebox_context *proc_ctx);
147
148 struct intel_vebox_context * gen75_vebox_context_init(VADriverContextP ctx);
149
150 #endif