Comment out the correct #endif directive.
[mplayer/greg.git] / vidix / drivers.c
blob65a09a65ac5673f7e3884fdee412b5d22050fadf
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
18 * along with MPlayer; if not, write to the Free Software
19 * Foundation, Inc., 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 "vidixlib.h"
28 #include "config.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 savage_drv;
46 extern VDXDriver sis_drv;
47 extern VDXDriver unichrome_drv;
49 static void vidix_register_driver (VDXDriver *drv)
51 VDXDriver **d;
53 d = &first_driver;
54 while (*d != NULL)
55 d = &(*d)->next;
56 *d = drv;
57 drv->next = NULL;
60 void vidix_register_all_drivers (void)
62 #ifdef CONFIG_VIDIX_DRV_CYBERBLADE
63 vidix_register_driver (&cyberblade_drv);
64 #endif
65 #ifdef CONFIG_VIDIX_DRV_IVTV
66 vidix_register_driver (&ivtv_drv);
67 #endif
68 #ifdef CONFIG_VIDIX_DRV_MACH64
69 vidix_register_driver (&mach64_drv);
70 #endif
71 #ifdef CONFIG_VIDIX_DRV_MGA
72 vidix_register_driver (&mga_drv);
73 #endif
74 #ifdef CONFIG_VIDIX_DRV_MGA_CRTC2
75 vidix_register_driver (&mga_crtc2_drv);
76 #endif
77 #ifdef CONFIG_VIDIX_DRV_NVIDIA
78 vidix_register_driver (&nvidia_drv);
79 #endif
80 #ifdef CONFIG_VIDIX_DRV_PM2
81 vidix_register_driver (&pm2_drv);
82 #endif
83 #ifdef CONFIG_VIDIX_DRV_PM3
84 vidix_register_driver (&pm3_drv);
85 #endif
86 #ifdef CONFIG_VIDIX_DRV_RADEON
87 vidix_register_driver (&radeon_drv);
88 #endif
89 #ifdef CONFIG_VIDIX_DRV_RAGE128
90 vidix_register_driver (&rage128_drv);
91 #endif
92 #ifdef CONFIG_VIDIX_DRV_SAVAGE
93 vidix_register_driver (&savage_drv);
94 #endif
95 #ifdef CONFIG_VIDIX_DRV_SIS
96 vidix_register_driver (&sis_drv);
97 #endif
98 #ifdef CONFIG_VIDIX_DRV_UNICHROME
99 vidix_register_driver (&unichrome_drv);
100 #endif
103 static int vidix_probe_driver (VDXContext *ctx, VDXDriver *drv,
104 unsigned int cap, int verbose)
106 vidix_capability_t vid_cap;
108 if (verbose)
109 printf ("vidixlib: PROBING: %s\n", drv->name);
111 if (!drv->probe || drv->probe (verbose, PROBE_NORMAL) != 0)
112 return 0;
114 if (!drv->get_caps || drv->get_caps (&vid_cap) != 0)
115 return 0;
117 if ((vid_cap.type & cap) != cap)
119 if (verbose)
120 printf ("vidixlib: Found %s but has no required capability\n",
121 drv->name);
122 return 0;
125 if (verbose)
126 printf ("vidixlib: %s probed o'k\n", drv->name);
128 ctx->drv = drv;
129 return 1;
132 static void vidix_list_drivers (void)
134 VDXDriver *drv;
136 printf ("Available VIDIX drivers:\n");
138 drv = first_driver;
139 while (drv)
141 vidix_capability_t cap;
142 drv->get_caps (&cap);
143 printf (" * %s - %s\n", drv->name, cap.name);
144 drv = drv->next;
148 int vidix_find_driver (VDXContext *ctx, const char *name,
149 unsigned int cap, int verbose)
151 VDXDriver *drv;
153 if (name && !strcmp (name, "help"))
155 vidix_list_drivers ();
156 ctx->drv = NULL;
157 return 0;
160 drv = first_driver;
161 while (drv)
163 if (name) /* forced driver */
165 if (!strcmp (drv->name, name))
167 if (vidix_probe_driver (ctx, drv, cap, verbose))
168 return 1;
169 else
171 ctx->drv = NULL;
172 return 0;
176 else /* auto-probe */
178 if (vidix_probe_driver (ctx, drv, cap, verbose))
179 return 1;
181 drv = drv->next;
184 if (verbose)
185 printf ("vidixlib: No suitable driver can be found.\n");
186 ctx->drv = NULL;
187 return 0;