1 /**************************************************************************
3 * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include <va/va_backend.h>
31 #include "pipe/p_format.h"
33 #include "util/u_memory.h"
34 #include "util/u_format.h"
35 #include "util/u_debug.h"
37 #include "va_private.h"
40 enum pipe_format pipe_format
;
41 VAImageFormat va_format
;
42 } va_image_formats_supported_t
;
44 static const va_image_formats_supported_t va_image_formats_supported
[VA_MAX_IMAGE_FORMATS_SUPPORTED
] =
46 { PIPE_FORMAT_B8G8R8A8_UNORM
,
47 { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST
, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }},
48 { PIPE_FORMAT_R8G8B8A8_UNORM
,
49 { VA_FOURCC_RGBA
, VA_LSB_FIRST
, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }}
53 vlVaQueryImageFormats(VADriverContextP ctx
, VAImageFormat
*format_list
, int *num_formats
)
56 return VA_STATUS_ERROR_INVALID_CONTEXT
;
58 if (!(format_list
&& num_formats
))
59 return VA_STATUS_ERROR_UNKNOWN
;
63 num_formats
[0] = VA_MAX_IMAGE_FORMATS_SUPPORTED
;
65 /* Query supported formats */
66 for (n
= 0; n
< VA_MAX_IMAGE_FORMATS_SUPPORTED
; n
++) {
67 format_list
[n
] = va_image_formats_supported
[n
].va_format
;
70 return VA_STATUS_SUCCESS
;
74 vlVaCreateImage(VADriverContextP ctx
, VAImageFormat
*format
, int width
, int height
, VAImage
*image
)
77 return VA_STATUS_ERROR_INVALID_CONTEXT
;
80 return VA_STATUS_ERROR_UNKNOWN
;
82 if (!(width
&& height
))
83 return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT
;
86 return VA_STATUS_ERROR_UNKNOWN
;
88 switch (format
->fourcc
) {
89 case VA_FOURCC('B','G','R','A'):
90 VA_INFO("Creating BGRA image of size %dx%d\n",width
,height
);
93 VA_INFO("Creating RGBA image of size %dx%d\n",width
,height
);
96 VA_ERROR("Couldn't create image of type %0x08\n",format
->fourcc
);
97 return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT
;
100 VA_INFO("Image %p created successfully\n",format
);
102 return VA_STATUS_SUCCESS
;
106 vlVaDeriveImage(VADriverContextP ctx
, VASurfaceID surface
, VAImage
*image
)
109 return VA_STATUS_ERROR_INVALID_CONTEXT
;
111 return VA_STATUS_ERROR_UNIMPLEMENTED
;
115 vlVaDestroyImage(VADriverContextP ctx
, VAImageID image
)
118 return VA_STATUS_ERROR_INVALID_CONTEXT
;
120 return VA_STATUS_ERROR_UNIMPLEMENTED
;
124 vlVaSetImagePalette(VADriverContextP ctx
, VAImageID image
, unsigned char *palette
)
127 return VA_STATUS_ERROR_INVALID_CONTEXT
;
129 return VA_STATUS_ERROR_UNIMPLEMENTED
;
133 vlVaGetImage(VADriverContextP ctx
, VASurfaceID surface
, int x
, int y
,
134 unsigned int width
, unsigned int height
, VAImageID image
)
137 return VA_STATUS_ERROR_INVALID_CONTEXT
;
139 return VA_STATUS_ERROR_UNIMPLEMENTED
;
143 vlVaPutImage(VADriverContextP ctx
, VASurfaceID surface
, VAImageID image
,
144 int src_x
, int src_y
, unsigned int src_width
, unsigned int src_height
,
145 int dest_x
, int dest_y
, unsigned int dest_width
, unsigned int dest_height
)
148 return VA_STATUS_ERROR_INVALID_CONTEXT
;
150 return VA_STATUS_ERROR_UNIMPLEMENTED
;