va_surface.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 <va/va.h> 29#include <va/va_backend.h> 30#include <util/u_debug.h> 31#include <util/u_memory.h> 32#include "va_private.h" 33 34boolean vlCreateHTAB(void); 35void vlDestroyHTAB(void); 36vlHandle vlAddDataHTAB(void *data); 37void* vlGetDataHTAB(vlHandle handle); 38 39static enum pipe_video_chroma_format VaRTFormatToPipe(unsigned int va_type) 40{ 41 switch (va_type) { 42 case VA_RT_FORMAT_YUV420: 43 return PIPE_VIDEO_CHROMA_FORMAT_420; 44 case VA_RT_FORMAT_YUV422: 45 return PIPE_VIDEO_CHROMA_FORMAT_422; 46 case VA_RT_FORMAT_YUV444: 47 return PIPE_VIDEO_CHROMA_FORMAT_444; 48 default: 49 assert(0); 50 } 51 52 return -1; 53} 54 55VAStatus vlVaCreateSurfaces( VADriverContextP ctx, 56 int width, 57 int height, 58 int format, 59 int num_surfaces, 60 VASurfaceID *surfaces) 61{ 62 if (!ctx) 63 return VA_STATUS_ERROR_INVALID_CONTEXT; 64 65 /* We only support one format */ 66 if (VA_RT_FORMAT_YUV420 != format) 67 return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; 68 69 if (!(width && height)) 70 return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; 71 72 if (!vlCreateHTAB()) 73 return VA_STATUS_ERROR_UNKNOWN; 74 75 vlVaSurfacePriv *va_surface = (vlVaSurfacePriv *)CALLOC(num_surfaces,sizeof(vlVaSurfacePriv)); 76 if (!va_surface) 77 return VA_STATUS_ERROR_ALLOCATION_FAILED; 78 79 int n = 0; 80 for (n = 0; n < num_surfaces; n++) 81 { 82 va_surface[n].width = width; 83 va_surface[n].height = height; 84 va_surface[n].format = VaRTFormatToPipe(format); 85 va_surface[n].ctx = ctx; 86 surfaces[n] = (VASurfaceID *)vlAddDataHTAB((void *)(va_surface + n)); 87 } 88 89 return VA_STATUS_SUCCESS; 90} 91 92VAStatus vlVaDestroySurfaces( VADriverContextP ctx, 93 VASurfaceID *surface_list, 94 int num_surfaces) 95{ 96 if (!ctx) 97 return VA_STATUS_ERROR_INVALID_CONTEXT; 98 99 return VA_STATUS_ERROR_UNIMPLEMENTED; 100} 101 102VAStatus vlVaSyncSurface( VADriverContextP ctx, 103 VASurfaceID render_target) 104{ 105 if (!ctx) 106 return VA_STATUS_ERROR_INVALID_CONTEXT; 107 108 return VA_STATUS_ERROR_UNIMPLEMENTED; 109} 110 111VAStatus vlVaQuerySurfaceStatus( VADriverContextP ctx, 112 VASurfaceID render_target, 113 VASurfaceStatus *status) 114{ 115 if (!ctx) 116 return VA_STATUS_ERROR_INVALID_CONTEXT; 117 118 return VA_STATUS_ERROR_UNIMPLEMENTED; 119} 120 121VAStatus vlVaPutSurface( VADriverContextP ctx, 122 VASurfaceID surface, 123 void* draw, 124 short srcx, 125 short srcy, 126 unsigned short srcw, 127 unsigned short srch, 128 short destx, 129 short desty, 130 unsigned short destw, 131 unsigned short desth, 132 VARectangle *cliprects, 133 unsigned int number_cliprects, 134 unsigned int flags) 135{ 136 if (!ctx) 137 return VA_STATUS_ERROR_INVALID_CONTEXT; 138 139 return VA_STATUS_ERROR_UNIMPLEMENTED; 140} 141 142VAStatus vlVaLockSurface( VADriverContextP ctx, 143 VASurfaceID surface, 144 unsigned int *fourcc, 145 unsigned int *luma_stride, 146 unsigned int *chroma_u_stride, 147 unsigned int *chroma_v_stride, 148 unsigned int *luma_offset, 149 unsigned int *chroma_u_offset, 150 unsigned int *chroma_v_offset, 151 unsigned int *buffer_name, 152 void **buffer) 153{ 154 if (!ctx) 155 return VA_STATUS_ERROR_INVALID_CONTEXT; 156 157 return VA_STATUS_ERROR_UNIMPLEMENTED; 158} 159 160VAStatus vlVaUnlockSurface( VADriverContextP ctx, 161 VASurfaceID surface) 162{ 163 if (!ctx) 164 return VA_STATUS_ERROR_INVALID_CONTEXT; 165 166 return VA_STATUS_ERROR_UNIMPLEMENTED; 167} 168