OSDN Git Service

i965_drv_video: move pp_context to i965_driver_data and make it a pointer.
[android-x86/hardware-intel-common-libva.git] / i965_drv_video / i965_drv_video.h
1 /*
2  * Copyright © 2009 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  *    Zou Nan hai <nanhai.zou@intel.com>
27  *
28  */
29
30 #ifndef _I965_DRV_VIDEO_H_
31 #define _I965_DRV_VIDEO_H_
32
33 #include <va/va.h>
34 #include <va/va_backend.h>
35
36 #include "object_heap.h"
37
38 #include "intel_driver.h"
39
40 #include "i965_media.h"
41 #include "i965_render.h"
42
43 #define I965_MAX_PROFILES                       11
44 #define I965_MAX_ENTRYPOINTS                    5
45 #define I965_MAX_CONFIG_ATTRIBUTES              10
46 #define I965_MAX_IMAGE_FORMATS                  3
47 #define I965_MAX_SUBPIC_FORMATS                 4
48 #define I965_MAX_DISPLAY_ATTRIBUTES             4
49 #define I965_STR_VENDOR                         "i965 Driver 0.1"
50
51 struct buffer_store
52 {
53     unsigned char *buffer;
54     dri_bo *bo;
55     int ref_count;
56     int num_elements;
57 };
58     
59 struct object_config 
60 {
61     struct object_base base;
62     VAProfile profile;
63     VAEntrypoint entrypoint;
64     VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES];
65     int num_attribs;
66 };
67
68 #define NUM_SLICES     10
69
70 struct decode_state
71 {
72     struct buffer_store *pic_param;
73     struct buffer_store **slice_params;
74     struct buffer_store *iq_matrix;
75     struct buffer_store *bit_plane;
76     struct buffer_store **slice_datas;
77     VASurfaceID current_render_target;
78     int max_slice_params;
79     int max_slice_datas;
80     int num_slice_params;
81     int num_slice_datas;
82 };
83
84 struct object_context 
85 {
86     struct object_base base;
87     VAContextID context_id;
88     VAConfigID config_id;
89     VASurfaceID *render_targets;
90     int num_render_targets;
91     int picture_width;
92     int picture_height;
93     int flags;
94     struct decode_state decode_state;
95 };
96
97 #define SURFACE_REFERENCED      (1 << 0)
98 #define SURFACE_DISPLAYED       (1 << 1)
99 #define SURFACE_DERIVED         (1 << 2)
100 #define SURFACE_REF_DIS_MASK    ((SURFACE_REFERENCED) | \
101                                  (SURFACE_DISPLAYED))
102 #define SURFACE_ALL_MASK        ((SURFACE_REFERENCED) | \
103                                  (SURFACE_DISPLAYED) |  \
104                                  (SURFACE_DERIVED))
105
106 struct object_surface 
107 {
108     struct object_base base;
109     VASurfaceStatus status;
110     VASubpictureID subpic;
111     int width;
112     int height;
113     int size;
114     int orig_width;
115     int orig_height;
116     int flags;
117     dri_bo *bo;
118     int pp_out_width;
119     int pp_out_height;
120     int orig_pp_out_width;
121     int orig_pp_out_height;
122     dri_bo *pp_out_bo;
123     void (*free_private_data)(void **data);
124     void *private_data;
125 };
126
127 struct object_buffer 
128 {
129     struct object_base base;
130     struct buffer_store *buffer_store;
131     int max_num_elements;
132     int num_elements;
133     int size_element;
134     VABufferType type;
135 };
136
137 struct object_image 
138 {
139     struct object_base base;
140     VAImage image;
141     dri_bo *bo;
142     unsigned int *palette;
143     VASurfaceID derived_surface;
144 };
145
146 struct object_subpic 
147 {
148     struct object_base base;
149     VAImageID image;
150     VARectangle src_rect;
151     VARectangle dst_rect;
152     unsigned int format;
153     int width;
154     int height;
155     int pitch;
156     dri_bo *bo;
157 };
158
159 struct i965_driver_data 
160 {
161     struct intel_driver_data intel;
162     struct object_heap config_heap;
163     struct object_heap context_heap;
164     struct object_heap surface_heap;
165     struct object_heap buffer_heap;
166     struct object_heap image_heap;
167     struct object_heap subpic_heap;
168     struct i965_media_state media_state;
169     struct i965_render_state render_state;
170     void *pp_context;
171 };
172
173 #define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap);
174 #define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap);
175 #define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap);
176 #define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap);
177 #define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap);
178 #define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap);
179
180 #define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id))
181 #define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id))
182 #define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id))
183 #define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id))
184 #define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id))
185 #define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id))
186
187 #define FOURCC_IA44 0x34344149
188 #define FOURCC_AI44 0x34344941
189
190 #define STRIDE(w)               (((w) + 0xf) & ~0xf)
191 #define SIZE_YUV420(w, h)       (h * (STRIDE(w) + STRIDE(w >> 1)))
192
193 static INLINE struct i965_driver_data *
194 i965_driver_data(VADriverContextP ctx)
195 {
196     return (struct i965_driver_data *)(ctx->pDriverData);
197 }
198
199 #endif /* _I965_DRV_VIDEO_H_ */