2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
27 #include "va_backend.h"
28 #include "va_android.h"
34 #include <sys/types.h>
39 static VADisplayContextP pDisplayContexts = NULL;
41 static int va_DisplayContextIsValid (
42 VADisplayContextP pDisplayContext
45 VADisplayContextP ctx = pDisplayContexts;
49 if (ctx == pDisplayContext && pDisplayContext->pDriverContext)
56 static void va_DisplayContextDestroy (
57 VADisplayContextP pDisplayContext
60 VADisplayContextP *ctx = &pDisplayContexts;
62 /* Throw away pDisplayContext */
65 if (*ctx == pDisplayContext)
67 *ctx = pDisplayContext->pNext;
68 pDisplayContext->pNext = NULL;
71 ctx = &((*ctx)->pNext);
73 free(pDisplayContext->pDriverContext);
74 free(pDisplayContext);
78 static VAStatus va_DisplayContextGetDriverName (
79 VADisplayContextP pDisplayContext,
83 char *driver_name_env;
85 unsigned int verndor_id;
86 unsigned int device_id;
89 { 0x8086, 0x4100, "pvr" },
95 *driver_name = strdup(devices[0].driver_name);
97 return VA_STATUS_SUCCESS;
101 VADisplay vaGetDisplay (
102 Display *native_dpy /* implementation specific */
105 VADisplay dpy = NULL;
106 VADisplayContextP pDisplayContext = pDisplayContexts;
111 while (pDisplayContext)
113 if (pDisplayContext->pDriverContext &&
114 pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy)
116 dpy = (VADisplay)pDisplayContext;
119 pDisplayContext = pDisplayContext->pNext;
124 /* create new entry */
125 VADriverContextP pDriverContext;
126 pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext));
127 pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
128 if (pDisplayContext && pDriverContext)
130 pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
132 pDriverContext->native_dpy = (void *)native_dpy;
133 pDisplayContext->pNext = pDisplayContexts;
134 pDisplayContext->pDriverContext = pDriverContext;
135 pDisplayContext->vaIsValid = va_DisplayContextIsValid;
136 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
137 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
138 pDisplayContexts = pDisplayContext;
139 dpy = (VADisplay)pDisplayContext;
144 free(pDisplayContext);
146 free(pDriverContext);
154 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
155 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
157 static int vaDisplayIsValid(VADisplay dpy)
159 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
160 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
163 VAStatus vaPutSurface (
166 Surface *draw, /* Android Surface/Window */
173 unsigned short destw,
174 unsigned short desth,
175 VARectangle *cliprects, /* client supplied clip list */
176 unsigned int number_cliprects, /* number of clip rects in the clip list */
177 unsigned int flags /* de-interlacing flags */
180 VADriverContextP ctx;
185 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
186 destx, desty, destw, desth,
187 cliprects, number_cliprects, flags );