Mercurial > mplayer.hg
diff vidix/drivers.c @ 22857:77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
author | ben |
---|---|
date | Sun, 01 Apr 2007 11:06:06 +0000 |
parents | |
children | 6c57087c5a2d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vidix/drivers.c Sun Apr 01 11:06:06 2007 +0000 @@ -0,0 +1,123 @@ +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> + +#include "vidixlib.h" +#include "../config.h" +#include "../libavutil/common.h" +#include "../mpbswap.h" + +VDXDriver *first_driver = NULL; + +extern VDXDriver cyberblade_drv; +extern VDXDriver mach64_drv; +extern VDXDriver mga_drv; +extern VDXDriver mga_crtc2_drv; +extern VDXDriver nvidia_drv; +extern VDXDriver pm3_drv; +extern VDXDriver radeon_drv; +extern VDXDriver rage128_drv; +extern VDXDriver savage_drv; +extern VDXDriver sis_drv; +extern VDXDriver unichrome_drv; + +static void vidix_register_driver (VDXDriver *drv) +{ + VDXDriver **d; + + d = &first_driver; + while (*d != NULL) + d = &(*d)->next; + *d = drv; + drv->next = NULL; +} + +void vidix_register_all_drivers (void) +{ + vidix_register_driver (&cyberblade_drv); + vidix_register_driver (&mach64_drv); + vidix_register_driver (&mga_drv); + vidix_register_driver (&mga_crtc2_drv); + vidix_register_driver (&nvidia_drv); + vidix_register_driver (&pm3_drv); + vidix_register_driver (&radeon_drv); + vidix_register_driver (&rage128_drv); + vidix_register_driver (&savage_drv); + vidix_register_driver (&sis_drv); + vidix_register_driver (&unichrome_drv); +} + +static int vidix_probe_driver (VDXContext *ctx, VDXDriver *drv, + unsigned int cap, int verbose) +{ + vidix_capability_t vid_cap; + + if (verbose) + printf ("vidixlib: PROBING: %s\n", drv->name); + + if (!drv->get_version) + return 0; + + if (drv->get_version () != VIDIX_VERSION) + { + if (verbose) + printf ("vidixlib: %s has wrong version\n", drv->name); + return 0; + } + + if (!drv->probe || drv->probe (verbose, PROBE_NORMAL) != 0) + return 0; + + if (!drv->get_caps || drv->get_caps (&vid_cap) != 0) + return 0; + + if ((vid_cap.type & cap) != cap) + { + if (verbose) + printf ("vidixlib: Found %s but has no required capability\n", + drv->name); + return 0; + } + + if (verbose) + printf ("vidixlib: %s probed o'k\n", drv->name); + + ctx->drv = drv; + return 1; +} + +int vidix_find_driver (VDXContext *ctx, const char *name, + unsigned int cap, int verbose) +{ + VDXDriver *drv; + + drv = first_driver; + while (drv) + { + if (name) /* forced driver */ + { + if (!strcmp (drv->name, name)) + { + if (vidix_probe_driver (ctx, drv, cap, verbose)) + return 1; + else + { + ctx->drv = NULL; + return 0; + } + } + } + else /* auto-probe */ + { + if (vidix_probe_driver (ctx, drv, cap, verbose)) + return 1; + } + drv = drv->next; + } + + if (verbose) + printf ("vidixlib: No suitable driver can be found.\n"); + ctx->drv = NULL; + return 0; +}