OSDN Git Service

VPP: Modify the definition for PP module number
[android-x86/hardware-intel-common-vaapi.git] / src / i965_post_processing.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  *    Xiang Haihao <haihao.xiang@intel.com>
26  *
27  */
28
29 #ifndef __I965_POST_PROCESSING_H__
30 #define __I965_POST_PROCESSING_H__
31
32 #define MAX_PP_SURFACES 32
33
34 #define I965_PP_FLAG_TOP_FIELD         0x00000001
35 #define I965_PP_FLAG_BOTTOM_FIELD      0x00000002
36
37 #define I965_PP_FLAG_SCALING           0x00000010
38 #define I965_PP_FLAG_AVS               0x00000020
39 #define I965_PP_FLAG_DEINTERLACING     0x00000100 /* XXX: don't support MCDI yet */
40 #define I965_PP_FLAG_DENOISE           0x00000200
41
42 enum
43 {
44     PP_NULL = 0,
45     PP_NV12_LOAD_SAVE,
46     PP_NV12_SCALING,
47     PP_NV12_AVS,
48     PP_NV12_DNDI,
49     NUM_PP_MODULES,
50 };
51
52 struct pp_load_save_context
53 {
54     int dest_w;
55     int dest_h;
56 };
57
58 struct pp_scaling_context
59 {
60     int dest_x; /* in pixel */
61     int dest_y; /* in pixel */
62     int dest_w;
63     int dest_h;
64     int src_normalized_x;
65     int src_normalized_y;
66 };
67
68 struct pp_avs_context
69 {
70     int dest_x; /* in pixel */
71     int dest_y; /* in pixel */
72     int dest_w;
73     int dest_h;
74     int src_normalized_x;
75     int src_normalized_y;
76     int src_w;
77     int src_h;
78 };
79
80 struct pp_dndi_context
81 {
82     int dest_w;
83     int dest_h;
84 };
85
86 struct pp_module
87 {
88     struct i965_kernel kernel;
89     
90     /* others */
91     void (*initialize)(VADriverContextP ctx, 
92                        VASurfaceID in_surface_id, VASurfaceID out_surface_id,
93                        const VARectangle *src_rect, const VARectangle *dst_rect);
94 };
95
96 struct pp_static_parameter
97 {
98     struct {
99         /* Procamp r1.0 */
100         float procamp_constant_c0;
101         
102         /* Load and Same r1.1 */
103         unsigned int source_packed_y_offset:8;
104         unsigned int source_packed_u_offset:8;
105         unsigned int source_packed_v_offset:8;
106         unsigned int pad0:8;
107
108         union {
109             /* Load and Save r1.2 */
110             struct {
111                 unsigned int destination_packed_y_offset:8;
112                 unsigned int destination_packed_u_offset:8;
113                 unsigned int destination_packed_v_offset:8;
114                 unsigned int pad0:8;
115             } load_and_save;
116
117             /* CSC r1.2 */
118             struct {
119                 unsigned int destination_rgb_format:8;
120                 unsigned int pad0:24;
121             } csc;
122         } r1_2;
123         
124         /* Procamp r1.3 */
125         float procamp_constant_c1;
126
127         /* Procamp r1.4 */
128         float procamp_constant_c2;
129
130         /* DI r1.5 */
131         unsigned int statistics_surface_picth:16;  /* Devided by 2 */
132         unsigned int pad1:16;
133
134         union {
135             /* DI r1.6 */
136             struct {
137                 unsigned int pad0:24;
138                 unsigned int top_field_first:8;
139             } di;
140
141             /* AVS/Scaling r1.6 */
142             float normalized_video_y_scaling_step;
143         } r1_6;
144
145         /* Procamp r1.7 */
146         float procamp_constant_c5;
147     } grf1;
148     
149     struct {
150         /* Procamp r2.0 */
151         float procamp_constant_c3;
152
153         /* MBZ r2.1*/
154         unsigned int pad0;
155
156         /* WG+CSC r2.2 */
157         float wg_csc_constant_c4;
158
159         /* WG+CSC r2.3 */
160         float wg_csc_constant_c8;
161
162         /* Procamp r2.4 */
163         float procamp_constant_c4;
164
165         /* MBZ r2.5 */
166         unsigned int pad1;
167
168         /* MBZ r2.6 */
169         unsigned int pad2;
170
171         /* WG+CSC r2.7 */
172         float wg_csc_constant_c9;
173     } grf2;
174
175     struct {
176         /* WG+CSC r3.0 */
177         float wg_csc_constant_c0;
178
179         /* Blending r3.1 */
180         float scaling_step_ratio;
181
182         /* Blending r3.2 */
183         float normalized_alpha_y_scaling;
184         
185         /* WG+CSC r3.3 */
186         float wg_csc_constant_c4;
187
188         /* WG+CSC r3.4 */
189         float wg_csc_constant_c1;
190
191         /* ALL r3.5 */
192         int horizontal_origin_offset:16;
193         int vertical_origin_offset:16;
194
195         /* Shared r3.6*/
196         union {
197             /* Color filll */
198             unsigned int color_pixel;
199
200             /* WG+CSC */
201             float wg_csc_constant_c2;
202         } r3_6;
203
204         /* WG+CSC r3.7 */
205         float wg_csc_constant_c3;
206     } grf3;
207
208     struct {
209         /* WG+CSC r4.0 */
210         float wg_csc_constant_c6;
211
212         /* ALL r4.1 MBZ ???*/
213         unsigned int pad0;
214
215         /* Shared r4.2 */
216         union {
217             /* AVS */
218             struct {
219                 unsigned int pad1:15;
220                 unsigned int nlas:1;
221                 unsigned int pad2:16;
222             } avs;
223
224             /* DI */
225             struct {
226                 unsigned int motion_history_coefficient_m2:8;
227                 unsigned int motion_history_coefficient_m1:8;
228                 unsigned int pad0:16;
229             } di;
230         } r4_2;
231
232         /* WG+CSC r4.3 */
233         float wg_csc_constant_c7;
234
235         /* WG+CSC r4.4 */
236         float wg_csc_constant_c10;
237
238         /* AVS r4.5 */
239         float source_video_frame_normalized_horizontal_origin;
240
241         /* MBZ r4.6 */
242         unsigned int pad1;
243
244         /* WG+CSC r4.7 */
245         float wg_csc_constant_c11;
246     } grf4;
247 };
248
249 struct pp_inline_parameter
250 {
251     struct {
252         /* ALL r5.0 */
253         int destination_block_horizontal_origin:16;
254         int destination_block_vertical_origin:16;
255
256         /* Shared r5.1 */
257         union {
258             /* AVS/Scaling */
259             float source_surface_block_normalized_horizontal_origin;
260
261             /* FMD */
262             struct {
263                 unsigned int variance_surface_vertical_origin:16;
264                 unsigned int pad0:16;
265             } fmd;
266         } r5_1; 
267
268         /* AVS/Scaling r5.2 */
269         float source_surface_block_normalized_vertical_origin;
270
271         /* Alpha r5.3 */
272         float alpha_surface_block_normalized_horizontal_origin;
273
274         /* Alpha r5.4 */
275         float alpha_surface_block_normalized_vertical_origin;
276
277         /* Alpha r5.5 */
278         unsigned int alpha_mask_x:16;
279         unsigned int alpha_mask_y:8;
280         unsigned int block_count_x:8;
281
282         /* r5.6 */
283         unsigned int block_horizontal_mask:16;
284         unsigned int block_vertical_mask:8;
285         unsigned int number_blocks:8;
286
287         /* AVS/Scaling r5.7 */
288         float normalized_video_x_scaling_step;
289     } grf5;
290
291     struct {
292         /* AVS r6.0 */
293         float video_step_delta;
294
295         /* r6.1-r6.7 */
296         unsigned int padx[7];
297     } grf6;
298 };
299
300 struct i965_post_processing_context
301 {
302     int current_pp;
303     struct pp_module pp_modules[NUM_PP_MODULES];
304     struct pp_static_parameter pp_static_parameter;
305     struct pp_inline_parameter pp_inline_parameter;
306
307     struct {
308         dri_bo *bo;
309     } curbe;
310
311     struct {
312         dri_bo *ss_bo;
313         dri_bo *s_bo;
314     } surfaces[MAX_PP_SURFACES];
315
316     struct {
317         dri_bo *bo;
318     } binding_table;
319
320     struct {
321         dri_bo *bo;
322         int num_interface_descriptors;
323     } idrt;
324
325     struct {
326         dri_bo *bo;
327     } vfe_state;
328
329     struct {
330         dri_bo *bo;
331         dri_bo *bo_8x8;
332         dri_bo *bo_8x8_uv;
333     } sampler_state_table;
334
335     struct {
336         unsigned int size;
337
338         unsigned int vfe_start;
339         unsigned int cs_start;
340
341         unsigned int num_vfe_entries;
342         unsigned int num_cs_entries;
343
344         unsigned int size_vfe_entry;
345         unsigned int size_cs_entry;
346     } urb;
347
348     struct {
349         dri_bo *bo;
350     } stmm;
351
352     union {
353         struct pp_load_save_context pp_load_save_context;
354         struct pp_scaling_context pp_scaling_context;
355         struct pp_avs_context pp_avs_context;
356         struct pp_dndi_context pp_dndi_context;
357     } private_context;
358
359     int (*pp_x_steps)(void *private_context);
360     int (*pp_y_steps)(void *private_context);
361     int (*pp_set_block_parameter)(struct i965_post_processing_context *pp_context, int x, int y);
362  
363     /* video process based on hsw vebox */ 
364     struct intel_vebox_context *pp_vebox_context;
365 };
366
367 VASurfaceID
368 i965_post_processing(
369     VADriverContextP   ctx,
370     VASurfaceID        surface,
371     const VARectangle *src_rect,
372     const VARectangle *dst_rect,
373     unsigned int       flags,
374     int                *has_done_scaling 
375 );
376
377 Bool
378 i965_post_processing_terminate(VADriverContextP ctx);
379 Bool
380 i965_post_processing_init(VADriverContextP ctx);
381
382 #endif /* __I965_POST_PROCESSING_H__ */