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
48 static void va_DisplayContextDestroy (
49 VADisplayContextP pDisplayContext
52 VADisplayContextP *ctx = &pDisplayContexts;
54 /* Throw away pDisplayContext */
57 if (*ctx == pDisplayContext)
59 *ctx = pDisplayContext->pNext;
60 pDisplayContext->pNext = NULL;
63 ctx = &((*ctx)->pNext);
65 free(pDisplayContext->pDriverContext);
66 free(pDisplayContext);
70 static VAStatus va_DisplayContextGetDriverName (
71 VADisplayContextP pDisplayContext,
75 char *driver_name_env;
77 unsigned int verndor_id;
78 unsigned int device_id;
81 { 0x8086, 0x4100, "android" },
87 *driver_name = strdup(devices[0].driver_name);
89 return VA_STATUS_SUCCESS;
93 VADisplay vaGetDisplay (
94 Display *native_dpy /* implementation specific */
98 VADisplayContextP pDisplayContext = pDisplayContexts;
103 while (pDisplayContext)
105 if (pDisplayContext->pDriverContext &&
106 pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy)
108 dpy = (VADisplay)pDisplayContext;
111 pDisplayContext = pDisplayContext->pNext;
116 /* create new entry */
117 VADriverContextP pDriverContext;
118 pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext));
119 pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
120 if (pDisplayContext && pDriverContext)
122 pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
124 pDriverContext->native_dpy = (void *)native_dpy;
125 pDisplayContext->pNext = pDisplayContexts;
126 pDisplayContext->pDriverContext = pDriverContext;
127 pDisplayContext->vaIsValid = va_DisplayContextIsValid;
128 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
129 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
130 pDisplayContexts = pDisplayContext;
131 dpy = (VADisplay)pDisplayContext;
136 free(pDisplayContext);
138 free(pDriverContext);
146 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
147 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
149 static int vaDisplayIsValid(VADisplay dpy)
151 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
152 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
155 VAStatus vaPutSurface (
158 Surface *draw, /* Android Surface/Window */
165 unsigned short destw,
166 unsigned short desth,
167 VARectangle *cliprects, /* client supplied clip list */
168 unsigned int number_cliprects, /* number of clip rects in the clip list */
169 unsigned int flags /* de-interlacing flags */
172 VADriverContextP ctx;
177 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
178 destx, desty, destw, desth,
179 cliprects, number_cliprects, flags );