2007-04-06 15:30:39 +00:00
|
|
|
/*
|
2007-04-22 14:05:41 +00:00
|
|
|
* VIDIX Drivers Registry Handler.
|
|
|
|
* Copyright (C) 2007 Benjamin Zores <ben@geexbox.org>
|
2007-04-06 15:30:39 +00:00
|
|
|
*
|
2007-04-22 14:05:41 +00:00
|
|
|
* This file is part of MPlayer.
|
2007-04-06 15:30:39 +00:00
|
|
|
*
|
2007-04-22 14:05:41 +00:00
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2007-04-06 15:30:39 +00:00
|
|
|
*
|
2007-04-22 14:05:41 +00:00
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2008-05-12 17:39:36 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2007-04-06 15:30:39 +00:00
|
|
|
*/
|
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2007-04-06 20:37:43 +00:00
|
|
|
#include "config.h"
|
2008-06-20 20:16:34 +00:00
|
|
|
#include "vidix.h"
|
2007-04-06 20:37:43 +00:00
|
|
|
#include "libavutil/common.h"
|
|
|
|
#include "mpbswap.h"
|
2007-04-14 10:39:17 +00:00
|
|
|
#include "config.h"
|
2007-04-01 11:06:06 +00:00
|
|
|
|
|
|
|
VDXDriver *first_driver = NULL;
|
|
|
|
|
|
|
|
extern VDXDriver cyberblade_drv;
|
2007-05-10 18:47:27 +00:00
|
|
|
extern VDXDriver ivtv_drv;
|
2007-04-01 11:06:06 +00:00
|
|
|
extern VDXDriver mach64_drv;
|
|
|
|
extern VDXDriver mga_drv;
|
|
|
|
extern VDXDriver mga_crtc2_drv;
|
|
|
|
extern VDXDriver nvidia_drv;
|
2007-04-14 10:52:40 +00:00
|
|
|
extern VDXDriver pm2_drv;
|
2007-04-01 11:06:06 +00:00
|
|
|
extern VDXDriver pm3_drv;
|
|
|
|
extern VDXDriver radeon_drv;
|
|
|
|
extern VDXDriver rage128_drv;
|
2008-02-29 20:01:28 +00:00
|
|
|
extern VDXDriver s3_drv;
|
2007-04-01 11:06:06 +00:00
|
|
|
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)
|
|
|
|
{
|
2007-04-14 10:39:17 +00:00
|
|
|
#ifdef CONFIG_VIDIX_DRV_CYBERBLADE
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&cyberblade_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
2007-05-10 18:47:27 +00:00
|
|
|
#ifdef CONFIG_VIDIX_DRV_IVTV
|
|
|
|
vidix_register_driver (&ivtv_drv);
|
|
|
|
#endif
|
2007-04-14 10:39:17 +00:00
|
|
|
#ifdef CONFIG_VIDIX_DRV_MACH64
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&mach64_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_VIDIX_DRV_MGA
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&mga_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_VIDIX_DRV_MGA_CRTC2
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&mga_crtc2_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_VIDIX_DRV_NVIDIA
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&nvidia_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
2007-04-14 10:52:40 +00:00
|
|
|
#ifdef CONFIG_VIDIX_DRV_PM2
|
|
|
|
vidix_register_driver (&pm2_drv);
|
|
|
|
#endif
|
2007-04-14 10:39:17 +00:00
|
|
|
#ifdef CONFIG_VIDIX_DRV_PM3
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&pm3_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_VIDIX_DRV_RADEON
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&radeon_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_VIDIX_DRV_RAGE128
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&rage128_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
2008-02-29 20:01:28 +00:00
|
|
|
#ifdef CONFIG_VIDIX_DRV_S3
|
|
|
|
vidix_register_driver (&s3_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_VIDIX_DRV_SIS
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&sis_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_VIDIX_DRV_UNICHROME
|
2007-04-01 11:06:06 +00:00
|
|
|
vidix_register_driver (&unichrome_drv);
|
2007-04-14 10:39:17 +00:00
|
|
|
#endif
|
2007-04-01 11:06:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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->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;
|
|
|
|
}
|
|
|
|
|
2007-04-01 13:27:28 +00:00
|
|
|
static void vidix_list_drivers (void)
|
|
|
|
{
|
|
|
|
VDXDriver *drv;
|
|
|
|
|
|
|
|
printf ("Available VIDIX drivers:\n");
|
|
|
|
|
|
|
|
drv = first_driver;
|
|
|
|
while (drv)
|
|
|
|
{
|
|
|
|
vidix_capability_t cap;
|
|
|
|
drv->get_caps (&cap);
|
|
|
|
printf (" * %s - %s\n", drv->name, cap.name);
|
|
|
|
drv = drv->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
int vidix_find_driver (VDXContext *ctx, const char *name,
|
|
|
|
unsigned int cap, int verbose)
|
|
|
|
{
|
|
|
|
VDXDriver *drv;
|
|
|
|
|
2007-04-01 16:22:14 +00:00
|
|
|
if (name && !strcmp (name, "help"))
|
2007-04-01 13:27:28 +00:00
|
|
|
{
|
|
|
|
vidix_list_drivers ();
|
|
|
|
ctx->drv = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
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;
|
|
|
|
}
|