hardware/intel/libva
修订版 | 997d59cf2092a29979c19a62fbe43d7f8d4dfa29 (tree) |
---|---|
时间 | 2009-04-23 01:38:56 |
作者 | root <root@loca...> |
Commiter | root |
Merge branch 'DRI2' of ssh://git@moblin-mdi.jf.intel.com/umg-moorestown-libva into DRI2
@@ -89,13 +89,51 @@ static void va_DisplayContextDestroy ( | ||
89 | 89 | free(pDisplayContext); |
90 | 90 | } |
91 | 91 | |
92 | -static VAStatus va_DisplayContextGetDriverName ( | |
92 | + | |
93 | +static VAStatus va_DRI2GetDriverName ( | |
94 | + VADisplayContextP pDisplayContext, | |
95 | + char **driver_name | |
96 | +) | |
97 | +{ | |
98 | + VADriverContextP ctx = pDisplayContext->pDriverContext; | |
99 | + VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; | |
100 | + char *driverName, *deviceName; | |
101 | + int driver_major; | |
102 | + int driver_minor; | |
103 | + int driver_patch; | |
104 | + Bool result = True; | |
105 | + | |
106 | + if (!VA_DRI2QueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) { | |
107 | + va_infoMessage("DRI2 extension isn't present\n"); | |
108 | + return VA_STATUS_ERROR_UNKNOWN; | |
109 | + } | |
110 | + | |
111 | + if (!VA_DRI2QueryVersion(ctx->x11_dpy, &driver_major, &driver_minor)) { | |
112 | + va_errorMessage("VA_DRI2QueryVersion failed\n"); | |
113 | + return VA_STATUS_ERROR_UNKNOWN; | |
114 | + } | |
115 | + | |
116 | + if (!VA_DRI2Connect(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen), | |
117 | + &driver_name, &device_name)) { | |
118 | + va_infoMessage("DRI2 isn't enabled, fallback to DRI1\n"); | |
119 | + return VA_STATUS_ERROR_UNKNOWN; | |
120 | + } | |
121 | + | |
122 | + va_infoMessage("VA_DRI2Connect: %d.%d.%d %s (screen %d)\n", | |
123 | + driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen); | |
124 | + ctx->dri2 = 1; | |
125 | + | |
126 | + return VA_STATUS_SUCCESS; | |
127 | +} | |
128 | + | |
129 | +static VAStatus va_DRIGetDriverName ( | |
93 | 130 | VADisplayContextP pDisplayContext, |
94 | 131 | char **driver_name |
95 | 132 | ) |
96 | 133 | { |
97 | 134 | VADriverContextP ctx = pDisplayContext->pDriverContext; |
98 | 135 | VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; |
136 | + int eventBase, errorBase; | |
99 | 137 | int direct_capable; |
100 | 138 | int driver_major; |
101 | 139 | int driver_minor; |
@@ -103,18 +141,11 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
103 | 141 | Bool result = True; |
104 | 142 | char *x_driver_name = NULL; |
105 | 143 | |
106 | - if (driver_name) | |
107 | - *driver_name = NULL; | |
108 | - if (geteuid() == getuid()) | |
109 | - { | |
110 | - /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ | |
111 | - if (getenv("LIBVA_DRIVER_NAME")) | |
112 | - { | |
113 | - /* For easier debugging */ | |
114 | - *driver_name = strdup(getenv("LIBVA_DRIVER_NAME")); | |
115 | - return VA_STATUS_SUCCESS; | |
116 | - } | |
144 | + if (!VA_DRIQueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) { | |
145 | + va_errorMessage("VA_DRIQueryExtension failed\n"); | |
146 | + return VA_STATUS_ERROR_UNKNOWN; | |
117 | 147 | } |
148 | + | |
118 | 149 | if (result) |
119 | 150 | { |
120 | 151 | result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable); |
@@ -154,6 +185,45 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
154 | 185 | return vaStatus; |
155 | 186 | } |
156 | 187 | |
188 | +static VAStatus va_DisplayContextGetDriverName ( | |
189 | + VADisplayContextP pDisplayContext, | |
190 | + char **driver_name | |
191 | +) | |
192 | +{ | |
193 | + VADriverContextP ctx = pDisplayContext->pDriverContext; | |
194 | + VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; | |
195 | + int direct_capable; | |
196 | + int driver_major; | |
197 | + int driver_minor; | |
198 | + int driver_patch; | |
199 | + Bool result = True; | |
200 | + char *x_driver_name = NULL; | |
201 | + | |
202 | + if (driver_name) | |
203 | + *driver_name = NULL; | |
204 | + | |
205 | + vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); | |
206 | + if (vaStatus != VA_STATUS_SUCCESS) | |
207 | + vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name); | |
208 | + | |
209 | + if ((vaStatus == VA_STATUS_SUCCESS) | |
210 | + && geteuid() == getuid()) | |
211 | + { | |
212 | + /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ | |
213 | + if (getenv("LIBVA_DRIVER_NAME")) | |
214 | + { | |
215 | + /* For easier debugging */ | |
216 | + if (*driver_name) | |
217 | + Xfree(*driver_name); | |
218 | + | |
219 | + *driver_name = strdup(getenv("LIBVA_DRIVER_NAME")); | |
220 | + return VA_STATUS_SUCCESS; | |
221 | + } | |
222 | + } | |
223 | + | |
224 | + return vaStatus; | |
225 | +} | |
226 | + | |
157 | 227 | int vaDisplayIsValid(VADisplay dpy) |
158 | 228 | { |
159 | 229 | VADisplayContextP tmp=NULL; |
@@ -423,7 +423,7 @@ struct VADriverContext | ||
423 | 423 | |
424 | 424 | Display *x11_dpy; |
425 | 425 | int x11_screen; |
426 | - | |
426 | + int dri2; | |
427 | 427 | int version_major; |
428 | 428 | int version_minor; |
429 | 429 | int max_profiles; |