psb_output.h revision 5e116884381ae450b82c3d7e6c6372214e03ae29
1/*
2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
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 *    Shengquan Yuan  <shengquan.yuan@intel.com>
26 *    Zhaohan Ren  <zhaohan.ren@intel.com>
27 *    Jason Hu <jason.hu@intel.com>
28 *
29 */
30
31#ifndef _PSB_OUTPUT_H_
32#define _PSB_OUTPUT_H_
33#include <inttypes.h>
34#include "psb_drv_video.h"
35#include "psb_drm.h"
36#include "psb_surface.h"
37#include "hwdefs/img_types.h"
38#include <va/va.h>
39#include <linux/fb.h>
40#include <fcntl.h>
41
42#ifndef ANDROID
43#include <va/va_x11.h>
44#else
45#define Drawable unsigned int
46#define Bool int
47#define LOG_TAG "pvr_drv_video"
48#endif
49
50#define PSB_MAX_IMAGE_FORMATS      3 /* sizeof(psb__CreateImageFormat)/sizeof(VAImageFormat) */
51#define PSB_MAX_SUBPIC_FORMATS     3 /* sizeof(psb__SubpicFormat)/sizeof(VAImageFormat) */
52#define PSB_MAX_DISPLAY_ATTRIBUTES 18     /* sizeof(psb__DisplayAttribute)/sizeof(VADisplayAttribute) */
53
54#define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD       0x0004
55#define PSB_SUPPORTED_SUBPIC_FLAGS      VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD /* No alpha or chroma key support */
56
57
58#define CLAMP(_X) ( (_X)= ((_X)<0?0:((_X)>255?255:(_X)) ) )
59
60#define HUE_DEFAULT_VALUE    0
61#define HUE_MIN    -180
62#define HUE_MAX    180
63#define HUE_STEPSIZE 0.1
64
65#define BRIGHTNESS_DEFAULT_VALUE   0
66#define BRIGHTNESS_MIN -100
67#define BRIGHTNESS_MAX 100
68#define BRIGHTNESS_STEPSIZE 0.1
69
70#define CONTRAST_DEFAULT_VALUE 1
71#define CONTRAST_MIN 0
72#define CONTRAST_MAX 2
73#define CONTRAST_STEPSIZE 0.0001
74
75#define SATURATION_DEFAULT_VALUE 1
76#define SATURATION_MIN 0
77#define SATURATION_MAX 3
78#define SATURATION_STEPSIZE 0.0001
79
80#define VA_RENDER_MODE_MASK 0x0f
81#define VA_RENDER_DEVICE_MASK 0x03
82
83#define PSB_DRIDDX_VERSION_MAJOR 0
84#define PSB_DRIDDX_VERSION_MINOR 1
85#define PSB_DRIDDX_VERSION_PATCH 0
86
87#define psb__ImageNV12                          \
88{                                               \
89    VA_FOURCC_NV12,                             \
90    VA_LSB_FIRST,                               \
91    16,                                         \
92    0,                                          \
93    0,                                          \
94    0,                                          \
95    0,                                          \
96    0                                           \
97}
98
99#define psb__ImageAYUV                          \
100{                                               \
101    VA_FOURCC_AYUV,                             \
102    VA_LSB_FIRST,                               \
103    32,                                         \
104    0,                                          \
105    0,                                          \
106    0,                                          \
107    0,                                          \
108    0                                           \
109}
110
111#define psb__ImageAI44                          \
112{                                               \
113    VA_FOURCC_AI44,                             \
114    VA_LSB_FIRST,                               \
115    16,                                         \
116    0,                                          \
117    0,                                          \
118    0,                                          \
119    0,                                          \
120    0,                                          \
121}
122
123#define psb__ImageRGBA                          \
124{                                               \
125    VA_FOURCC_RGBA,                             \
126    VA_LSB_FIRST,                               \
127    32,                                         \
128    32,                                         \
129    0xff,                                       \
130    0xff00,                                     \
131    0xff0000,                                   \
132    0xff000000                                  \
133}
134
135#define psb__ImageYV16                          \
136{                                               \
137    VA_FOURCC_YV16,                             \
138    VA_LSB_FIRST,                               \
139    16,                                         \
140    0,                                          \
141    0,                                          \
142    0,                                          \
143    0,                                          \
144    0,                                          \
145}
146
147VAStatus psb__destroy_subpicture(psb_driver_data_p driver_data, object_subpic_p obj_subpic);
148VAStatus psb__destroy_image(psb_driver_data_p driver_data, object_image_p obj_image);
149
150/*
151 * VAImage call these buffer routines
152 */
153VAStatus psb__CreateBuffer(
154    psb_driver_data_p driver_data,
155    object_context_p obj_context,   /* in */
156    VABufferType type,      /* in */
157    unsigned int size,      /* in */
158    unsigned int num_elements, /* in */
159    unsigned char *data,             /* in */
160    VABufferID *buf_desc    /* out */
161);
162
163VAStatus psb_DestroyBuffer(
164    VADriverContextP ctx,
165    VABufferID buffer_id
166);
167
168VAStatus psb_initOutput(
169    VADriverContextP ctx
170);
171
172
173VAStatus psb_deinitOutput(
174    VADriverContextP ctx
175);
176
177VAStatus psb_PutSurfaceBuf(
178    VADriverContextP ctx,
179    VASurfaceID surface,
180    unsigned char* data,
181    int* data_len,
182    short srcx,
183    short srcy,
184    unsigned short srcw,
185    unsigned short srch,
186    short destx,
187    short desty,
188    unsigned short destw,
189    unsigned short desth,
190    VARectangle *cliprects, /* client supplied clip list */
191    unsigned int number_cliprects, /* number of clip rects in the clip list */
192    unsigned int flags /* de-interlacing flags */
193);
194
195VAStatus psb_PutSurface(
196    VADriverContextP ctx,
197    VASurfaceID surface,
198    void* draw, /* X Drawable */
199    short srcx,
200    short srcy,
201    unsigned short srcw,
202    unsigned short srch,
203    short destx,
204    short desty,
205    unsigned short destw,
206    unsigned short desth,
207    VARectangle *cliprects, /* client supplied clip list */
208    unsigned int number_cliprects, /* number of clip rects in the clip list */
209    unsigned int flags /* de-interlacing flags */
210);
211
212VAStatus psb_GetBufferID(
213    VADriverContextP ctx,
214    VASurfaceID surface,
215    uint32_t *devid,
216    uint32_t *bufid
217);
218
219VAStatus psb_QueryImageFormats(
220    VADriverContextP ctx,
221    VAImageFormat *format_list,        /* out */
222    int *num_formats           /* out */
223);
224
225VAStatus psb_CreateImage(
226    VADriverContextP ctx,
227    VAImageFormat *format,
228    int width,
229    int height,
230    VAImage *image     /* out */
231);
232
233VAStatus psb_DeriveImage(
234    VADriverContextP ctx,
235    VASurfaceID surface,
236    VAImage *image     /* out */
237);
238
239VAStatus psb_DestroyImage(
240    VADriverContextP ctx,
241    VAImageID image
242);
243
244VAStatus psb_SetImagePalette(
245    VADriverContextP ctx,
246    VAImageID image,
247    /*
248     * pointer to an array holding the palette data.  The size of the array is
249     * num_palette_entries * entry_bytes in size.  The order of the components
250     * in the palette is described by the component_order in VAImage struct
251     */
252    unsigned char *palette
253);
254
255VAStatus psb_GetImage(
256    VADriverContextP ctx,
257    VASurfaceID surface,
258    int x,     /* coordinates of the upper left source pixel */
259    int y,
260    unsigned int width, /* width and height of the region */
261    unsigned int height,
262    VAImageID image
263);
264
265VAStatus psb_PutImage(
266    VADriverContextP ctx,
267    VASurfaceID surface,
268    VAImageID image,
269    int src_x,
270    int src_y,
271    unsigned int src_width,
272    unsigned int src_height,
273    int dest_x,
274    int dest_y,
275    unsigned int dest_width,
276    unsigned int dest_height
277);
278
279VAStatus psb_QuerySubpictureFormats(
280    VADriverContextP ctx,
281    VAImageFormat *format_list,        /* out */
282    unsigned int *flags,       /* out */
283    unsigned int *num_formats  /* out */
284);
285
286VAStatus psb_CreateSubpicture(
287    VADriverContextP ctx,
288    VAImageID image,
289    VASubpictureID *subpicture   /* out */
290);
291
292VAStatus psb_DestroySubpicture(
293    VADriverContextP ctx,
294    VASubpictureID subpicture
295);
296
297VAStatus psb_SetSubpictureImage(
298    VADriverContextP ctx,
299    VASubpictureID subpicture,
300    VAImageID image
301);
302
303
304VAStatus psb_SetSubpictureChromakey(
305    VADriverContextP ctx,
306    VASubpictureID subpicture,
307    unsigned int chromakey_min,
308    unsigned int chromakey_max,
309    unsigned int chromakey_mask
310);
311
312VAStatus psb_SetSubpictureGlobalAlpha(
313    VADriverContextP ctx,
314    VASubpictureID subpicture,
315    float global_alpha
316);
317
318VAStatus psb_AssociateSubpicture(
319    VADriverContextP ctx,
320    VASubpictureID subpicture,
321    VASurfaceID *target_surfaces,
322    int num_surfaces,
323    short src_x, /* upper left offset in subpicture */
324    short src_y,
325    unsigned short src_width,
326    unsigned short src_height,
327    short dest_x, /* upper left offset in surface */
328    short dest_y,
329    unsigned short dest_width,
330    unsigned short dest_height,
331    /*
332     * whether to enable chroma-keying or global-alpha
333     * see VA_SUBPICTURE_XXX values
334     */
335    unsigned int flags
336);
337
338VAStatus psb_DeassociateSubpicture(
339    VADriverContextP ctx,
340    VASubpictureID subpicture,
341    VASurfaceID *target_surfaces,
342    int num_surfaces
343);
344
345void psb_SurfaceDeassociateSubpict(
346    psb_driver_data_p driver_data,
347    object_surface_p obj_surface
348);
349
350/*
351 * Query display attributes
352 * The caller must provide a "attr_list" array that can hold at
353 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
354 * returned in "attr_list" is returned in "num_attributes".
355 */
356VAStatus psb_QueryDisplayAttributes(
357    VADriverContextP ctx,
358    VADisplayAttribute *attr_list,      /* out */
359    int *num_attributes         /* out */
360);
361
362/*
363 * Get display attributes
364 * This function returns the current attribute values in "attr_list".
365 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
366 * from vaQueryDisplayAttributes() can have their values retrieved.
367 */
368VAStatus psb_GetDisplayAttributes(
369    VADriverContextP ctx,
370    VADisplayAttribute *attr_list,      /* in/out */
371    int num_attributes
372);
373
374/*
375 * Set display attributes
376 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
377 * from vaQueryDisplayAttributes() can be set.  If the attribute is not settable or
378 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
379 */
380VAStatus psb_SetDisplayAttributes(
381    VADriverContextP ctx,
382    VADisplayAttribute *attr_list,
383    int num_attributes
384);
385
386#endif /* _PSB_OUTPUT_H_ */
387