Consistently use tabs in svn:externals
[mplayer/glamo.git] / vidix / drivers.c
blob2311d948005422f2dd297aaf199f3badc2c85396
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 "libavutil/common.h"
30 #include "mpbswap.h"
31 #include "config.h"
33 VDXDriver *first_driver = NULL;
35 extern VDXDriver cyberblade_drv;
36 extern VDXDriver ivtv_drv;
37 extern VDXDriver mach64_drv;
38 extern VDXDriver mga_drv;
39 extern VDXDriver mga_crtc2_drv;
40 extern VDXDriver nvidia_drv;
41 extern VDXDriver pm2_drv;
42 extern VDXDriver pm3_drv;
43 extern VDXDriver radeon_drv;
44 extern VDXDriver rage128_drv;
45 extern VDXDriver s3_drv;
46 extern VDXDriver sh_veu_drv;
47 extern VDXDriver sis_drv;
48 extern VDXDriver unichrome_drv;
50 static void vidix_register_driver (VDXDriver *drv)
52 VDXDriver **d;
54 d = &first_driver;
55 while (*d != NULL)
56 d = &(*d)->next;
57 *d = drv;
58 drv->next = NULL;
61 void vidix_register_all_drivers (void)
63 #ifdef CONFIG_VIDIX_DRV_CYBERBLADE
64 vidix_register_driver (&cyberblade_drv);
65 #endif
66 #ifdef CONFIG_VIDIX_DRV_IVTV
67 vidix_register_driver (&ivtv_drv);
68 #endif
69 #ifdef CONFIG_VIDIX_DRV_MACH64
70 vidix_register_driver (&mach64_drv);
71 #endif
72 #ifdef CONFIG_VIDIX_DRV_MGA
73 vidix_register_driver (&mga_drv);
74 #endif
75 #ifdef CONFIG_VIDIX_DRV_MGA_CRTC2
76 vidix_register_driver (&mga_crtc2_drv);
77 #endif
78 #ifdef CONFIG_VIDIX_DRV_NVIDIA
79 vidix_register_driver (&nvidia_drv);
80 #endif
81 #ifdef CONFIG_VIDIX_DRV_PM2
82 vidix_register_driver (&pm2_drv);
83 #endif
84 #ifdef CONFIG_VIDIX_DRV_PM3
85 vidix_register_driver (&pm3_drv);
86 #endif
87 #ifdef CONFIG_VIDIX_DRV_RADEON
88 vidix_register_driver (&radeon_drv);
89 #endif
90 #ifdef CONFIG_VIDIX_DRV_RAGE128
91 vidix_register_driver (&rage128_drv);
92 #endif
93 #ifdef CONFIG_VIDIX_DRV_S3
94 vidix_register_driver (&s3_drv);
95 #endif
96 #ifdef CONFIG_VIDIX_DRV_SH_VEU
97 vidix_register_driver (&sh_veu_drv);
98 #endif
99 #ifdef CONFIG_VIDIX_DRV_SIS
100 vidix_register_driver (&sis_drv);
101 #endif
102 #ifdef CONFIG_VIDIX_DRV_UNICHROME
103 vidix_register_driver (&unichrome_drv);
104 #endif
107 static int vidix_probe_driver (VDXContext *ctx, VDXDriver *drv,
108 unsigned int cap, int verbose)
110 vidix_capability_t vid_cap;
112 if (verbose)
113 printf ("vidixlib: PROBING: %s\n", drv->name);
115 if (!drv->probe || drv->probe (verbose, PROBE_NORMAL) != 0)
116 return 0;
118 if (!drv->get_caps || drv->get_caps (&vid_cap) != 0)
119 return 0;
121 if ((vid_cap.type & cap) != cap)
123 if (verbose)
124 printf ("vidixlib: Found %s but has no required capability\n",
125 drv->name);
126 return 0;
129 if (verbose)
130 printf ("vidixlib: %s probed o'k\n", drv->name);
132 ctx->drv = drv;
133 return 1;
136 static void vidix_list_drivers (void)
138 VDXDriver *drv;
140 printf ("Available VIDIX drivers:\n");
142 drv = first_driver;
143 while (drv)
145 vidix_capability_t cap;
146 drv->get_caps (&cap);
147 printf (" * %s - %s\n", drv->name, cap.name);
148 drv = drv->next;
152 int vidix_find_driver (VDXContext *ctx, const char *name,
153 unsigned int cap, int verbose)
155 VDXDriver *drv;
157 if (name && !strcmp (name, "help"))
159 vidix_list_drivers ();
160 ctx->drv = NULL;
161 return 0;
164 drv = first_driver;
165 while (drv)
167 if (name) /* forced driver */
169 if (!strcmp (drv->name, name))
171 if (vidix_probe_driver (ctx, drv, cap, verbose))
172 return 1;
173 else
175 ctx->drv = NULL;
176 return 0;
180 else /* auto-probe */
182 if (vidix_probe_driver (ctx, drv, cap, verbose))
183 return 1;
185 drv = drv->next;
188 if (verbose)
189 printf ("vidixlib: No suitable driver can be found.\n");
190 ctx->drv = NULL;
191 return 0;