vo_kva: Restore all the attributes after changing aspect ratio
[mplayer/glamo.git] / vidix / drivers.c
blob796815666263f301884a7459593b3d4211bc79b9
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 "drivers.h"
28 #include "config.h"
29 #include "vidix.h"
30 #include "drivers.h"
31 #include "libavutil/common.h"
32 #include "mpbswap.h"
33 #include "config.h"
35 VDXDriver *first_driver = NULL;
37 extern VDXDriver cyberblade_drv;
38 extern VDXDriver ivtv_drv;
39 extern VDXDriver mach64_drv;
40 extern VDXDriver mga_drv;
41 extern VDXDriver mga_crtc2_drv;
42 extern VDXDriver nvidia_drv;
43 extern VDXDriver pm2_drv;
44 extern VDXDriver pm3_drv;
45 extern VDXDriver radeon_drv;
46 extern VDXDriver rage128_drv;
47 extern VDXDriver s3_drv;
48 extern VDXDriver sh_veu_drv;
49 extern VDXDriver sis_drv;
50 extern VDXDriver unichrome_drv;
52 static void vidix_register_driver (VDXDriver *drv)
54 VDXDriver **d;
56 d = &first_driver;
57 while (*d != NULL)
58 d = &(*d)->next;
59 *d = drv;
60 drv->next = NULL;
63 void vidix_register_all_drivers (void)
65 #ifdef CONFIG_VIDIX_DRV_CYBERBLADE
66 vidix_register_driver (&cyberblade_drv);
67 #endif
68 #ifdef CONFIG_VIDIX_DRV_IVTV
69 vidix_register_driver (&ivtv_drv);
70 #endif
71 #ifdef CONFIG_VIDIX_DRV_MACH64
72 vidix_register_driver (&mach64_drv);
73 #endif
74 #ifdef CONFIG_VIDIX_DRV_MGA
75 vidix_register_driver (&mga_drv);
76 #endif
77 #ifdef CONFIG_VIDIX_DRV_MGA_CRTC2
78 vidix_register_driver (&mga_crtc2_drv);
79 #endif
80 #ifdef CONFIG_VIDIX_DRV_NVIDIA
81 vidix_register_driver (&nvidia_drv);
82 #endif
83 #ifdef CONFIG_VIDIX_DRV_PM2
84 vidix_register_driver (&pm2_drv);
85 #endif
86 #ifdef CONFIG_VIDIX_DRV_PM3
87 vidix_register_driver (&pm3_drv);
88 #endif
89 #ifdef CONFIG_VIDIX_DRV_RADEON
90 vidix_register_driver (&radeon_drv);
91 #endif
92 #ifdef CONFIG_VIDIX_DRV_RAGE128
93 vidix_register_driver (&rage128_drv);
94 #endif
95 #ifdef CONFIG_VIDIX_DRV_S3
96 vidix_register_driver (&s3_drv);
97 #endif
98 #ifdef CONFIG_VIDIX_DRV_SH_VEU
99 vidix_register_driver (&sh_veu_drv);
100 #endif
101 #ifdef CONFIG_VIDIX_DRV_SIS
102 vidix_register_driver (&sis_drv);
103 #endif
104 #ifdef CONFIG_VIDIX_DRV_UNICHROME
105 vidix_register_driver (&unichrome_drv);
106 #endif
109 static int vidix_probe_driver (VDXContext *ctx, VDXDriver *drv,
110 unsigned int cap, int verbose)
112 vidix_capability_t vid_cap;
114 if (verbose)
115 printf ("vidixlib: PROBING: %s\n", drv->name);
117 if (!drv->probe || drv->probe (verbose, PROBE_NORMAL) != 0)
118 return 0;
120 if (!drv->get_caps || drv->get_caps (&vid_cap) != 0)
121 return 0;
123 if ((vid_cap.type & cap) != cap)
125 if (verbose)
126 printf ("vidixlib: Found %s but has no required capability\n",
127 drv->name);
128 return 0;
131 if (verbose)
132 printf ("vidixlib: %s probed o'k\n", drv->name);
134 ctx->drv = drv;
135 return 1;
138 static void vidix_list_drivers (void)
140 VDXDriver *drv;
142 printf ("Available VIDIX drivers:\n");
144 drv = first_driver;
145 while (drv)
147 vidix_capability_t cap;
148 drv->get_caps (&cap);
149 printf (" * %s - %s\n", drv->name, cap.name);
150 drv = drv->next;
154 int vidix_find_driver (VDXContext *ctx, const char *name,
155 unsigned int cap, int verbose)
157 VDXDriver *drv;
159 if (name && !strcmp (name, "help"))
161 vidix_list_drivers ();
162 ctx->drv = NULL;
163 return 0;
166 drv = first_driver;
167 while (drv)
169 if (name) /* forced driver */
171 if (!strcmp (drv->name, name))
173 if (vidix_probe_driver (ctx, drv, cap, verbose))
174 return 1;
175 else
177 ctx->drv = NULL;
178 return 0;
182 else /* auto-probe */
184 if (vidix_probe_driver (ctx, drv, cap, verbose))
185 return 1;
187 drv = drv->next;
190 if (verbose)
191 printf ("vidixlib: No suitable driver can be found.\n");
192 ctx->drv = NULL;
193 return 0;