MEDIA_OBJECT uses hardware scoreboard during VME prediction on Haswell
[profile/ivi/vaapi-intel-driver.git] / src / i965_gpe_utils.h
1 /*
2  * Copyright © 2012 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 "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  * Authors:
24  *    Xiang Haihao <haihao.xiang@intel.com>
25  */
26
27 #ifndef _I965_GPE_UTILS_H_
28 #define _I965_GPE_UTILS_H_
29
30 #include <i915_drm.h>
31 #include <intel_bufmgr.h>
32
33 #include "i965_defines.h"
34 #include "i965_drv_video.h"
35 #include "i965_structs.h"
36
37 #define MAX_GPE_KERNELS    32
38
39 struct i965_buffer_surface
40 {
41     dri_bo *bo;
42     unsigned int num_blocks;
43     unsigned int size_block;
44     unsigned int pitch;
45 };
46
47 struct i965_gpe_context
48 {
49     struct {
50         dri_bo *bo;
51         unsigned int length;            /* in bytes */
52     } surface_state_binding_table;
53
54     struct {
55         dri_bo *bo;
56         unsigned int max_entries;
57         unsigned int entry_size;        /* in bytes */
58     } idrt;
59
60     struct {
61         dri_bo *bo;
62         unsigned int length;            /* in bytes */
63     } curbe;
64
65     struct {
66         unsigned int gpgpu_mode : 1;
67         unsigned int pad0 : 7;
68         unsigned int max_num_threads : 16;
69         unsigned int num_urb_entries : 8;
70         unsigned int urb_entry_size : 16;
71         unsigned int curbe_allocation_size : 16;
72     } vfe_state;
73   
74     /* vfe_desc5/6/7 is used to determine whether the HW scoreboard is used.
75      * If scoreboard is not used, don't touch them
76      */ 
77     union { 
78         unsigned int dword;
79         struct {
80                 unsigned int mask:8;
81                 unsigned int pad:22;
82                 unsigned int type:1;
83                 unsigned int enable:1;
84         } scoreboard0; 
85     }vfe_desc5;
86
87     union {
88         unsigned int dword;
89         struct {
90                 int delta_x0:4;
91                 int delta_y0:4;
92                 int delta_x1:4;
93                 int delta_y1:4;
94                 int delta_x2:4;
95                 int delta_y2:4;
96                 int delta_x3:4;
97                 int delta_y3:4;
98         } scoreboard1;
99      } vfe_desc6;
100
101     union {
102         unsigned int dword;
103         struct {
104                 int delta_x4:4;
105                 int delta_y4:4;
106                 int delta_x5:4;
107                 int delta_y5:4;
108                 int delta_x6:4;
109                 int delta_y6:4;
110                 int delta_x7:4;
111                 int delta_y7:4;
112         } scoreboard2;
113      } vfe_desc7;
114
115     unsigned int num_kernels;
116     struct i965_kernel kernels[MAX_GPE_KERNELS];
117 };
118
119 void i965_gpe_context_destroy(struct i965_gpe_context *gpe_context);
120 void i965_gpe_context_init(VADriverContextP ctx,
121                            struct i965_gpe_context *gpe_context);
122 void i965_gpe_load_kernels(VADriverContextP ctx,
123                            struct i965_gpe_context *gpe_context,
124                            struct i965_kernel *kernel_list,
125                            unsigned int num_kernels);
126 void gen6_gpe_pipeline_setup(VADriverContextP ctx,
127                              struct i965_gpe_context *gpe_context,
128                              struct intel_batchbuffer *batch);
129 void i965_gpe_surface2_setup(VADriverContextP ctx,
130                              struct i965_gpe_context *gpe_context,
131                              struct object_surface *obj_surface,
132                              unsigned long binding_table_offset,
133                              unsigned long surface_state_offset);
134 void i965_gpe_media_rw_surface_setup(VADriverContextP ctx,
135                                      struct i965_gpe_context *gpe_context,
136                                      struct object_surface *obj_surface,
137                                      unsigned long binding_table_offset,
138                                      unsigned long surface_state_offset);
139 void i965_gpe_buffer_suface_setup(VADriverContextP ctx,
140                                   struct i965_gpe_context *gpe_context,
141                                   struct i965_buffer_surface *buffer_surface,
142                                   unsigned long binding_table_offset,
143                                   unsigned long surface_state_offset);
144 void gen7_gpe_surface2_setup(VADriverContextP ctx,
145                              struct i965_gpe_context *gpe_context,
146                              struct object_surface *obj_surface,
147                              unsigned long binding_table_offset,
148                              unsigned long surface_state_offset);
149 void gen7_gpe_media_rw_surface_setup(VADriverContextP ctx,
150                                      struct i965_gpe_context *gpe_context,
151                                      struct object_surface *obj_surface,
152                                      unsigned long binding_table_offset,
153                                      unsigned long surface_state_offset);
154 void gen7_gpe_buffer_suface_setup(VADriverContextP ctx,
155                                   struct i965_gpe_context *gpe_context,
156                                   struct i965_buffer_surface *buffer_surface,
157                                   unsigned long binding_table_offset,
158                                   unsigned long surface_state_offset);
159 void gen75_gpe_media_chroma_surface_setup(VADriverContextP ctx,
160                                      struct i965_gpe_context *gpe_context,
161                                      struct object_surface *obj_surface,
162                                      unsigned long binding_table_offset,
163                                      unsigned long surface_state_offset);
164 #endif /* _I965_GPE_UTILS_H_ */