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.
28 #include "va_backend.h"
33 #include "va_dricommon.h"
34 #include "va_nvctrl.h"
41 #include <sys/types.h>
46 static int va_DisplayContextIsValid (
47 VADisplayContextP pDisplayContext
50 return (pDisplayContext != NULL &&
51 pDisplayContext->pDriverContext != NULL);
54 static void va_DisplayContextDestroy (
55 VADisplayContextP pDisplayContext
59 struct dri_state *dri_state;
61 if (pDisplayContext == NULL)
64 ctx = pDisplayContext->pDriverContext;
65 dri_state = ctx->drm_state;
67 if (dri_state && dri_state->close)
68 dri_state->close(ctx);
70 free(pDisplayContext->pDriverContext->drm_state);
71 free(pDisplayContext->pDriverContext);
72 free(pDisplayContext);
76 static VAStatus va_DRI2GetDriverName (
77 VADisplayContextP pDisplayContext,
81 VADriverContextP ctx = pDisplayContext->pDriverContext;
83 if (!isDRI2Connected(ctx, driver_name))
84 return VA_STATUS_ERROR_UNKNOWN;
86 return VA_STATUS_SUCCESS;
89 static VAStatus va_NVCTRL_GetDriverName (
90 VADisplayContextP pDisplayContext,
94 VADriverContextP ctx = pDisplayContext->pDriverContext;
95 int direct_capable, driver_major, driver_minor, driver_patch;
98 result = VA_NVCTRLQueryDirectRenderingCapable(ctx->native_dpy, ctx->x11_screen,
100 if (!result || !direct_capable)
101 return VA_STATUS_ERROR_UNKNOWN;
103 result = VA_NVCTRLGetClientDriverName(ctx->native_dpy, ctx->x11_screen,
104 &driver_major, &driver_minor,
105 &driver_patch, driver_name);
107 return VA_STATUS_ERROR_UNKNOWN;
109 return VA_STATUS_SUCCESS;
112 static VAStatus va_FGLRX_GetDriverName (
113 VADisplayContextP pDisplayContext,
117 VADriverContextP ctx = pDisplayContext->pDriverContext;
118 int driver_major, driver_minor, driver_patch;
121 result = VA_FGLRXGetClientDriverName(ctx->native_dpy, ctx->x11_screen,
122 &driver_major, &driver_minor,
123 &driver_patch, driver_name);
125 return VA_STATUS_ERROR_UNKNOWN;
127 return VA_STATUS_SUCCESS;
130 static VAStatus va_DisplayContextGetDriverName (
131 VADisplayContextP pDisplayContext,
140 vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name);
141 if (vaStatus != VA_STATUS_SUCCESS)
142 vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name);
143 if (vaStatus != VA_STATUS_SUCCESS)
144 vaStatus = va_FGLRX_GetDriverName(pDisplayContext, driver_name);
149 VADisplay vaGetDisplay (
150 Display *native_dpy /* implementation specific */
153 VADisplay dpy = NULL;
154 VADisplayContextP pDisplayContext;
161 /* create new entry */
162 VADriverContextP pDriverContext;
163 struct dri_state *dri_state;
164 pDisplayContext = calloc(1, sizeof(*pDisplayContext));
165 pDriverContext = calloc(1, sizeof(*pDriverContext));
166 dri_state = calloc(1, sizeof(*dri_state));
167 if (pDisplayContext && pDriverContext && dri_state)
169 pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
171 pDriverContext->native_dpy = (void *)native_dpy;
172 pDriverContext->display_type = VA_DISPLAY_X11;
173 pDisplayContext->pDriverContext = pDriverContext;
174 pDisplayContext->vaIsValid = va_DisplayContextIsValid;
175 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
176 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
177 pDisplayContext->opaque = NULL;
178 pDriverContext->drm_state = dri_state;
179 dpy = (VADisplay)pDisplayContext;
184 free(pDisplayContext);
186 free(pDriverContext);
195 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
196 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
198 void va_TracePutSurface (
201 void *draw, /* the target Drawable */
208 unsigned short destw,
209 unsigned short desth,
210 VARectangle *cliprects, /* client supplied clip list */
211 unsigned int number_cliprects, /* number of clip rects in the clip list */
212 unsigned int flags /* de-interlacing flags */
216 VAStatus vaPutSurface (
219 Drawable draw, /* X Drawable */
226 unsigned short destw,
227 unsigned short desth,
228 VARectangle *cliprects, /* client supplied clip list */
229 unsigned int number_cliprects, /* number of clip rects in the clip list */
230 unsigned int flags /* de-interlacing flags */
233 VADriverContextP ctx;
236 return VA_STATUS_SUCCESS;
241 VA_TRACE_FUNC(va_TracePutSurface, dpy, surface, (void *)draw, srcx, srcy, srcw, srch,
242 destx, desty, destw, desth,
243 cliprects, number_cliprects, flags );
245 return ctx->vtable->vaPutSurface( ctx, surface, (void *)draw, srcx, srcy, srcw, srch,
246 destx, desty, destw, desth,
247 cliprects, number_cliprects, flags );