sync with en/mplayer.1 rev. 30611
[mplayer/glamo.git] / vidix / drivers.c
blobcc10c9bf589e3f2ee2aa94b5cf09c09b2c774aeb
1 /*
2 * VIDIX Drivers Registry Handler.
3 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org>
5 * This file is part of MPlayer.
7 * MPlayer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * MPlayer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <errno.h>
25 #include <string.h>
27 #include "config.h"
28 #include "vidix.h"
29 #include "drivers.h"
30 #include "libavutil/common.h"
31 #include "mpbswap.h"
32 #include "config.h"
34 VDXDriver *first_driver = NULL;
36 extern VDXDriver cyberblade_drv;
37 extern VDXDriver ivtv_drv;
38 extern VDXDriver mach64_drv;
39 extern VDXDriver mga_drv;
40 extern VDXDriver mga_crtc2_drv;
41 extern VDXDriver nvidia_drv;
42 extern VDXDriver pm2_drv;
43 extern VDXDriver pm3_drv;
44 extern VDXDriver radeon_drv;
45 extern VDXDriver rage128_drv;
46 extern VDXDriver s3_drv;
47 extern VDXDriver sh_veu_drv;
48 extern VDXDriver sis_drv;
49 extern VDXDriver unichrome_drv;
51 static void vidix_register_driver (VDXDriver *drv)
53 VDXDriver **d;
55 d = &first_driver;
56 while (*d != NULL)
57 d = &(*d)->next;
58 *d = drv;
59 drv->next = NULL;
62 void vidix_register_all_drivers (void)
64 #ifdef CONFIG_VIDIX_DRV_CYBERBLADE
65 vidix_register_driver (&cyberblade_drv);
66 #endif
67 #ifdef CONFIG_VIDIX_DRV_IVTV
68 vidix_register_driver (&ivtv_drv);
69 #endif
70 #ifdef CONFIG_VIDIX_DRV_MACH64
71 vidix_register_driver (&mach64_drv);
72 #endif
73 #ifdef CONFIG_VIDIX_DRV_MGA
74 vidix_register_driver (&mga_drv);
75 #endif
76 #ifdef CONFIG_VIDIX_DRV_MGA_CRTC2
77 vidix_register_driver (&mga_crtc2_drv);
78 #endif
79 #ifdef CONFIG_VIDIX_DRV_NVIDIA
80 vidix_register_driver (&nvidia_drv);
81 #endif
82 #ifdef CONFIG_VIDIX_DRV_PM2
83 vidix_register_driver (&pm2_drv);
84 #endif
85 #ifdef CONFIG_VIDIX_DRV_PM3
86 vidix_register_driver (&pm3_drv);
87 #endif
88 #ifdef CONFIG_VIDIX_DRV_RADEON
89 vidix_register_driver (&radeon_drv);
90 #endif
91 #ifdef CONFIG_VIDIX_DRV_RAGE128
92 vidix_register_driver (&rage128_drv);
93 #endif
94 #ifdef CONFIG_VIDIX_DRV_S3
95 vidix_register_driver (&s3_drv);
96 #endif
97 #ifdef CONFIG_VIDIX_DRV_SH_VEU
98 vidix_register_driver (&sh_veu_drv);
99 #endif
100 #ifdef CONFIG_VIDIX_DRV_SIS
101 vidix_register_driver (&sis_drv);
102 #endif
103 #ifdef CONFIG_VIDIX_DRV_UNICHROME
104 vidix_register_driver (&unichrome_drv);
105 #endif
108 static int vidix_probe_driver (VDXContext *ctx, VDXDriver *drv,
109 unsigned int cap, int verbose)
111 vidix_capability_t vid_cap;
113 if (verbose)
114 printf ("vidixlib: PROBING: %s\n", drv->name);
116 if (!drv->probe || drv->probe (verbose, PROBE_NORMAL) != 0)
117 return 0;
119 if (!drv->get_caps || drv->get_caps (&vid_cap) != 0)
120 return 0;
122 if ((vid_cap.type & cap) != cap)
124 if (verbose)
125 printf ("vidixlib: Found %s but has no required capability\n",
126 drv->name);
127 return 0;
130 if (verbose)
131 printf ("vidixlib: %s probed o'k\n", drv->name);
133 ctx->drv = drv;
134 return 1;
137 static void vidix_list_drivers (void)
139 VDXDriver *drv;
141 printf ("Available VIDIX drivers:\n");
143 drv = first_driver;
144 while (drv)
146 vidix_capability_t cap;
147 drv->get_caps (&cap);
148 printf (" * %s - %s\n", drv->name, cap.name);
149 drv = drv->next;
153 int vidix_find_driver (VDXContext *ctx, const char *name,
154 unsigned int cap, int verbose)
156 VDXDriver *drv;
158 if (name && !strcmp (name, "help"))
160 vidix_list_drivers ();
161 ctx->drv = NULL;
162 return 0;
165 drv = first_driver;
166 while (drv)
168 if (name) /* forced driver */
170 if (!strcmp (drv->name, name))
172 if (vidix_probe_driver (ctx, drv, cap, verbose))
173 return 1;
174 else
176 ctx->drv = NULL;
177 return 0;
181 else /* auto-probe */
183 if (vidix_probe_driver (ctx, drv, cap, verbose))
184 return 1;
186 drv = drv->next;
189 if (verbose)
190 printf ("vidixlib: No suitable driver can be found.\n");
191 ctx->drv = NULL;
192 return 0;