4646#include <fcntl.h>
4747#include <errno.h>
4848
49- struct driver_name_map {
50- const char * key ;
51- const char * name ;
52- };
53-
54- static const struct driver_name_map g_dri2_driver_name_map [] = {
55- { "i965" , "iHD" }, // Intel iHD VAAPI driver with i965 DRI driver
56- { "i965" , "i965" }, // Intel i965 VAAPI driver with i965 DRI driver
57- { "iris" , "iHD" }, // Intel iHD VAAPI driver with iris DRI driver
58- { "iris" , "i965" }, // Intel i965 VAAPI driver with iris DRI driver
59- { "crocus" , "i965" }, // Intel i965 VAAPI driver with crocus DRI driver
60- { NULL , NULL }
61- };
62-
6349static void va_DisplayContextDestroy (
6450 VADisplayContextP pDisplayContext
6551)
@@ -84,128 +70,6 @@ static void va_DisplayContextDestroy(
8470 free (pDisplayContext );
8571}
8672
87- static VAStatus va_DRI2_GetNumCandidates (
88- VADisplayContextP pDisplayContext ,
89- int * num_candidates
90- )
91- {
92- char * driver_name = NULL ;
93- const struct driver_name_map * m = NULL ;
94- VADriverContextP ctx = pDisplayContext -> pDriverContext ;
95-
96- * num_candidates = 0 ;
97-
98- if (!(va_isDRI2Connected (ctx , & driver_name ) && driver_name ))
99- return VA_STATUS_ERROR_UNKNOWN ;
100-
101- for (m = g_dri2_driver_name_map ; m -> key != NULL ; m ++ ) {
102- if (strcmp (m -> key , driver_name ) == 0 ) {
103- (* num_candidates )++ ;
104- }
105- }
106-
107- free (driver_name );
108-
109- /*
110- * If the dri2 driver name does not have a mapped vaapi driver name, then
111- * assume they have the same name.
112- */
113- if (* num_candidates == 0 )
114- * num_candidates = 1 ;
115-
116- return VA_STATUS_SUCCESS ;
117- }
118-
119- static VAStatus va_DRI2_GetDriverName (
120- VADisplayContextP pDisplayContext ,
121- char * * driver_name_ptr ,
122- int candidate_index
123- )
124- {
125- const struct driver_name_map * m = NULL ;
126- int current_index = 0 ;
127- VADriverContextP ctx = pDisplayContext -> pDriverContext ;
128-
129- * driver_name_ptr = NULL ;
130-
131- if (!(va_isDRI2Connected (ctx , driver_name_ptr ) && * driver_name_ptr ))
132- return VA_STATUS_ERROR_UNKNOWN ;
133-
134- for (m = g_dri2_driver_name_map ; m -> key != NULL ; m ++ ) {
135- if (strcmp (m -> key , * driver_name_ptr ) == 0 ) {
136- if (current_index == candidate_index ) {
137- break ;
138- }
139- current_index ++ ;
140- }
141- }
142-
143- /*
144- * If the dri2 driver name does not have a mapped vaapi driver name, then
145- * assume they have the same name.
146- */
147- if (!m -> name )
148- return VA_STATUS_SUCCESS ;
149-
150- /* Use the mapped vaapi driver name */
151- free (* driver_name_ptr );
152- * driver_name_ptr = strdup (m -> name );
153- if (!* driver_name_ptr )
154- return VA_STATUS_ERROR_ALLOCATION_FAILED ;
155-
156- return VA_STATUS_SUCCESS ;
157- }
158-
159- static VAStatus va_DisplayContextGetDriverName (
160- VADisplayContextP pDisplayContext ,
161- char * * driver_name , int candidate_index
162- )
163- {
164- VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN ;
165-
166- if (driver_name )
167- * driver_name = NULL ;
168- else
169- return VA_STATUS_ERROR_UNKNOWN ;
170-
171- if (!getenv ("LIBVA_DRI3_DISABLE" ))
172- vaStatus = va_DRI3_GetDriverName (pDisplayContext , driver_name , candidate_index );
173- if (vaStatus != VA_STATUS_SUCCESS )
174- vaStatus = va_DRI2_GetDriverName (pDisplayContext , driver_name , candidate_index );
175- #ifdef HAVE_NVCTRL
176- if (vaStatus != VA_STATUS_SUCCESS )
177- vaStatus = va_NVCTRL_GetDriverName (pDisplayContext , driver_name , candidate_index );
178- #endif
179- #ifdef HAVE_FGLRX
180- if (vaStatus != VA_STATUS_SUCCESS )
181- vaStatus = va_FGLRX_GetDriverName (pDisplayContext , driver_name , candidate_index );
182- #endif
183-
184- return vaStatus ;
185- }
186-
187- static VAStatus va_DisplayContextGetNumCandidates (
188- VADisplayContextP pDisplayContext ,
189- int * num_candidates
190- )
191- {
192- VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN ;
193-
194- if (!getenv ("LIBVA_DRI3_DISABLE" ))
195- vaStatus = va_DRI3_GetNumCandidates (pDisplayContext , num_candidates );
196- if (vaStatus != VA_STATUS_SUCCESS )
197- vaStatus = va_DRI2_GetNumCandidates (pDisplayContext , num_candidates );
198-
199- /* A call to va_DisplayContextGetDriverName will fallback to other
200- * methods (i.e. NVCTRL, FGLRX) when DRI2 is unsuccessful. All of those
201- * fallbacks only have 1 candidate driver.
202- */
203- if (vaStatus != VA_STATUS_SUCCESS )
204- * num_candidates = 1 ;
205-
206- return VA_STATUS_SUCCESS ;
207- }
208-
20973static VAStatus va_DisplayContextGetDriverNames (
21074 VADisplayContextP pDisplayContext ,
21175 char * * drivers , unsigned * num_drivers
@@ -245,8 +109,6 @@ VADisplay vaGetDisplay(
245109 return NULL ;
246110
247111 pDisplayContext -> vaDestroy = va_DisplayContextDestroy ;
248- pDisplayContext -> vaGetNumCandidates = va_DisplayContextGetNumCandidates ;
249- pDisplayContext -> vaGetDriverNameByIndex = va_DisplayContextGetDriverName ;
250112 pDisplayContext -> vaGetDriverNames = va_DisplayContextGetDriverNames ;
251113
252114 pDriverContext = va_newDriverContext (pDisplayContext );
0 commit comments