va_image.c revision 2b296ec77c2b95e7632b45100de5a0878ac2a294
1/************************************************************************** 2 * 3 * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian. 4 * All Rights Reserved. 5 * 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: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 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. 25 * 26 **************************************************************************/ 27 28#include <util/u_memory.h> 29#include <util/u_format.h> 30#include <util/u_debug.h> 31#include <pipe/p_format.h> 32#include <va/va.h> 33#include <va/va_backend.h> 34#include "va_private.h" 35 36typedef struct { 37 enum pipe_format pipe_format; 38 VAImageFormat va_format; 39} va_image_formats_supported_t; 40 41static const va_image_formats_supported_t va_image_formats_supported[VA_MAX_IMAGE_FORMATS_SUPPORTED] = 42{ 43 { PIPE_FORMAT_B8G8R8A8_UNORM, 44 { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }}, 45 { PIPE_FORMAT_R8G8B8A8_UNORM, 46 { VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }} 47}; 48 49boolean vlCreateHTAB(void); 50void vlDestroyHTAB(void); 51vlHandle vlAddDataHTAB(void *data); 52void* vlGetDataHTAB(vlHandle handle); 53 54VAStatus 55vlVaQueryImageFormats ( VADriverContextP ctx, 56 VAImageFormat *format_list, 57 int *num_formats) 58{ 59 if (!ctx) 60 return VA_STATUS_ERROR_INVALID_CONTEXT; 61 62 if (!(format_list && num_formats)) 63 return VA_STATUS_ERROR_UNKNOWN; 64 65 int n = 0; 66 67 num_formats[0] = VA_MAX_IMAGE_FORMATS_SUPPORTED; 68 69 /* Query supported formats */ 70 for (n = 0; n < VA_MAX_IMAGE_FORMATS_SUPPORTED; n++) 71 { 72 format_list[n] = va_image_formats_supported[n].va_format; 73 } 74 75 return VA_STATUS_SUCCESS; 76} 77 78VAStatus vlVaCreateImage( VADriverContextP ctx, 79 VAImageFormat *format, 80 int width, 81 int height, 82 VAImage *image) 83{ 84 if (!ctx) 85 return VA_STATUS_ERROR_INVALID_CONTEXT; 86 87 if(!format) 88 return VA_STATUS_ERROR_UNKNOWN; 89 90 if (!(width && height)) 91 return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; 92 93 if (!vlCreateHTAB()) 94 return VA_STATUS_ERROR_UNKNOWN; 95 96 switch (format->fourcc) { 97 case VA_FOURCC('B','G','R','A'): 98 VA_INFO("Creating BGRA image of size %dx%d\n",width,height); 99 break; 100 case VA_FOURCC_RGBA: 101 VA_INFO("Creating RGBA image of size %dx%d\n",width,height); 102 break; 103 default: 104 VA_ERROR("Couldn't create image of type %0x08\n",format->fourcc); 105 return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; 106 break; 107 } 108 109 VA_INFO("Image %p created successfully\n",format); 110 111 return VA_STATUS_SUCCESS; 112} 113 114VAStatus vlVaDeriveImage( VADriverContextP ctx, 115 VASurfaceID surface, 116 VAImage *image) 117{ 118 if (!ctx) 119 return VA_STATUS_ERROR_INVALID_CONTEXT; 120 121 122 return VA_STATUS_ERROR_UNIMPLEMENTED; 123} 124 125VAStatus vlVaDestroyImage( VADriverContextP ctx, 126 VAImageID image) 127{ 128 if (!ctx) 129 return VA_STATUS_ERROR_INVALID_CONTEXT; 130 131 132 return VA_STATUS_ERROR_UNIMPLEMENTED; 133} 134 135VAStatus vlVaSetImagePalette( VADriverContextP ctx, 136 VAImageID image, 137 unsigned char *palette) 138{ 139 if (!ctx) 140 return VA_STATUS_ERROR_INVALID_CONTEXT; 141 142 143 return VA_STATUS_ERROR_UNIMPLEMENTED; 144} 145 146VAStatus vlVaGetImage( VADriverContextP ctx, 147 VASurfaceID surface, 148 int x, 149 int y, 150 unsigned int width, 151 unsigned int height, 152 VAImageID image) 153{ 154 if (!ctx) 155 return VA_STATUS_ERROR_INVALID_CONTEXT; 156 157 158 return VA_STATUS_ERROR_UNIMPLEMENTED; 159} 160 161VAStatus vlVaPutImage( VADriverContextP ctx, 162 VASurfaceID surface, 163 VAImageID image, 164 int src_x, 165 int src_y, 166 unsigned int src_width, 167 unsigned int src_height, 168 int dest_x, 169 int dest_y, 170 unsigned int dest_width, 171 unsigned int dest_height) 172{ 173 if (!ctx) 174 return VA_STATUS_ERROR_INVALID_CONTEXT; 175 176 177 return VA_STATUS_ERROR_UNIMPLEMENTED; 178} 179