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"
29 #include "va_internal.h"
34 #include "va_dricommon.h"
35 #include "va_nvctrl.h"
42 #include <sys/types.h>
47 static int va_DisplayContextIsValid (
48 VADisplayContextP pDisplayContext
51 return (pDisplayContext != NULL &&
52 pDisplayContext->pDriverContext != NULL);
55 static void va_DisplayContextDestroy (
56 VADisplayContextP pDisplayContext
60 struct dri_state *dri_state;
62 if (pDisplayContext == NULL)
65 ctx = pDisplayContext->pDriverContext;
66 dri_state = ctx->drm_state;
68 if (dri_state && dri_state->close)
69 dri_state->close(ctx);
71 free(pDisplayContext->pDriverContext->drm_state);
72 free(pDisplayContext->pDriverContext);
73 free(pDisplayContext);
77 static VAStatus va_DRI2GetDriverName (
78 VADisplayContextP pDisplayContext,
82 VADriverContextP ctx = pDisplayContext->pDriverContext;
84 if (!va_isDRI2Connected(ctx, driver_name))
85 return VA_STATUS_ERROR_UNKNOWN;
87 return VA_STATUS_SUCCESS;
90 static VAStatus va_NVCTRL_GetDriverName (
91 VADisplayContextP pDisplayContext,
95 VADriverContextP ctx = pDisplayContext->pDriverContext;
96 int direct_capable, driver_major, driver_minor, driver_patch;
99 result = VA_NVCTRLQueryDirectRenderingCapable(ctx->native_dpy, ctx->x11_screen,
101 if (!result || !direct_capable)
102 return VA_STATUS_ERROR_UNKNOWN;
104 result = VA_NVCTRLGetClientDriverName(ctx->native_dpy, ctx->x11_screen,
105 &driver_major, &driver_minor,
106 &driver_patch, driver_name);
108 return VA_STATUS_ERROR_UNKNOWN;
110 return VA_STATUS_SUCCESS;
113 static VAStatus va_FGLRX_GetDriverName (
114 VADisplayContextP pDisplayContext,
118 VADriverContextP ctx = pDisplayContext->pDriverContext;
119 int driver_major, driver_minor, driver_patch;
122 result = VA_FGLRXGetClientDriverName(ctx->native_dpy, ctx->x11_screen,
123 &driver_major, &driver_minor,
124 &driver_patch, driver_name);
126 return VA_STATUS_ERROR_UNKNOWN;
128 return VA_STATUS_SUCCESS;
131 static VAStatus va_DisplayContextGetDriverName (
132 VADisplayContextP pDisplayContext,
141 return VA_STATUS_ERROR_UNKNOWN;
143 vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name);
144 if (vaStatus != VA_STATUS_SUCCESS)
145 vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name);
146 if (vaStatus != VA_STATUS_SUCCESS)
147 vaStatus = va_FGLRX_GetDriverName(pDisplayContext, driver_name);
152 VADisplay vaGetDisplay (
153 Display *native_dpy /* implementation specific */
156 VADisplayContextP pDisplayContext;
157 VADriverContextP pDriverContext;
158 struct dri_state *dri_state;
163 pDisplayContext = va_newDisplayContext();
164 if (!pDisplayContext)
167 pDisplayContext->vaIsValid = va_DisplayContextIsValid;
168 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
169 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
171 pDriverContext = va_newDriverContext(pDisplayContext);
172 if (!pDriverContext) {
173 free(pDisplayContext);
177 pDriverContext->native_dpy = (void *)native_dpy;
178 pDriverContext->x11_screen = XDefaultScreen(native_dpy);
179 pDriverContext->display_type = VA_DISPLAY_X11;
181 dri_state = calloc(1, sizeof(*dri_state));
183 free(pDisplayContext);
184 free(pDriverContext);
188 pDriverContext->drm_state = dri_state;
190 return (VADisplay)pDisplayContext;
194 void va_TracePutSurface (
197 void *draw, /* the target Drawable */
204 unsigned short destw,
205 unsigned short desth,
206 VARectangle *cliprects, /* client supplied clip list */
207 unsigned int number_cliprects, /* number of clip rects in the clip list */
208 unsigned int flags /* de-interlacing flags */
212 VAStatus vaPutSurface (
215 Drawable draw, /* X Drawable */
222 unsigned short destw,
223 unsigned short desth,
224 VARectangle *cliprects, /* client supplied clip list */
225 unsigned int number_cliprects, /* number of clip rects in the clip list */
226 unsigned int flags /* de-interlacing flags */
229 VADriverContextP ctx;
232 return VA_STATUS_SUCCESS;
237 VA_TRACE_LOG(va_TracePutSurface, dpy, surface, (void *)draw, srcx, srcy, srcw, srch,
238 destx, desty, destw, desth,
239 cliprects, number_cliprects, flags );
241 return ctx->vtable->vaPutSurface( ctx, surface, (void *)draw, srcx, srcy, srcw, srch,
242 destx, desty, destw, desth,
243 cliprects, number_cliprects, flags );