diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-18 15:29:19 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-18 15:29:19 +0000 |
commit | b6a7a1c325f8efe47d302290fe01e8f759b1b964 (patch) | |
tree | 257bcfca82c9138d105099afe598a174c96f4a3e /src/xine-engine/tvmode.c | |
parent | 9fb47c4d2259df214b179a2fffc752e9504f4e66 (diff) | |
download | xine-lib-b6a7a1c325f8efe47d302290fe01e8f759b1b964.tar.gz xine-lib-b6a7a1c325f8efe47d302290fe01e8f759b1b964.tar.bz2 |
nvtv patch by Mattias Eriksson <snaggen@acc.umu.se> with a few changes
NOTE: reported to be still in a non-working state.
use 'configure --enable-nvtv' to test. otherwise lib will be compiled with
xine_tvmode_* dummy functions just to keep compatibility.
CVS patchset: 3954
CVS date: 2003/01/18 15:29:19
Diffstat (limited to 'src/xine-engine/tvmode.c')
-rw-r--r-- | src/xine-engine/tvmode.c | 163 |
1 files changed, 128 insertions, 35 deletions
diff --git a/src/xine-engine/tvmode.c b/src/xine-engine/tvmode.c index 7648ac468..0d410c08f 100644 --- a/src/xine-engine/tvmode.c +++ b/src/xine-engine/tvmode.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: tvmode.c,v 1.9 2002/10/23 17:12:35 guenter Exp $ + * $Id: tvmode.c,v 1.10 2003/01/18 15:29:22 miguelfreitas Exp $ * * tvmode - TV output selection * @@ -32,32 +32,34 @@ #include <string.h> #include <unistd.h> -#include "nvtvd.h" - #include "xine_internal.h" #include "xineutils.h" +#ifdef XINE_HAVE_NVTV +#include "nvtv/back_client.h" + /* * PRIVATE */ /* FIXME: currently the used backend only supports one (1) connection * to a server and needs this global, external pointer */ -BackCardRec *back_card = 0; -BackAccessRec *back_access = 0; +BackCardPtr back_card = 0; +BackAccessPtr back_access = 0; static int current_type, current_width, current_height; static double current_fps; -static TVCrtRegs old_crt; -static TVRegs old_tv; +/* static TVCrtRegs old_crt; */ +static TVRegs old_tvregs; +static TVSettings old_settings; -static int tvmode_enabled; +static int tvmode_enabled = 1; static int was_enabled = 0; /* TODO: config, and better */ static TVSystem opt_system = TV_SYSTEM_PAL; -static TVConnect opt_connect = CONNECT_AUTO; +static TVConnect opt_connect = CONNECT_NONE; /* This is the list of possible modes for the used TV system. * TODO: @@ -80,7 +82,6 @@ static char *scan_overscan[] = { } ; /* TODO: flexible */ -static int opt_flicker = -1; static double opt_aspect = 4.0 / 3.0; /* Just turn off warnings */ @@ -101,8 +102,49 @@ static void nvtvmode_enable_cb(void *this_gen, xine_cfg_entry_t *entry) { } } + + /* Try to connect to nvtvd server */ static void tvmode_connect(xine_t *this) { + CardPtr main_card_list, main_card = NULL; + + if (back_client_avail ()) { + main_card_list = back_client_init (); + } else { + fprintf (stderr, "tvmode: Nvtvd not detected, make sure nvtvd is running.\n"); + /* Handle well in some way... */ + return; + } + + if (back_access) { + back_access->closeCard (); + } + + if (!main_card_list) { + fprintf (stderr, "tvmode: No supported video card found.\n"); + /* Handle well in some way... */ + return; + } + + /* Just pick the first, here we might want to pick an alternative card... */ + main_card = main_card_list; + + if (!main_card) { + fprintf (stderr, "tvmode: No supported video card found at specified address.\n"); + /* Handle well in some way... */ + return; + } + + + if (back_access) { + back_access->openCard (main_card); + fprintf(stderr, "tvmode: Using card %s for tvout\n", main_card->name); + was_enabled = 1; + } else { + fprintf(stderr, "tvmode: cannot connect to nvtvd - no TV mode switching available\n"); + } + + /* CardInfo *card = 0; @@ -122,60 +164,64 @@ static void tvmode_connect(xine_t *this) { } else printf("tvmode: cannot connect to nvtvd - no TV mode switching available\n"); + */ } /* Disconnect from server */ static void tvmode_disconnect (xine_t *this) { - back_card->closeCard (); - back_card = 0; + back_access->closeCard (); + back_access = 0; } /* Save current CRT and TV register configuration */ static void tvmode_savestate (xine_t *this) { - back_card->getMode (&old_crt, &old_tv); +/* back_card->getMode (&old_crt, &old_tv); */ + back_card->getSettings(&old_settings); + back_card->getMode (&old_tvregs); } /* Restore CRT and TV register configuration */ static void tvmode_restorestate (xine_t *this) { - back_card->setMode (0, &old_crt, &old_tv); +/* back_card->setMode (0, &old_crt, &old_tv); */ + + back_card->setModeSettings (&old_tvregs,&old_settings); + fprintf(stderr,"tvmode: Old mode saved!"); current_type = 0; } /* Set CRT and TV registers to given TV-Out configuration */ static void tvmode_settvstate (xine_t *this, int width, int height, double fps) { - TVSettings settings; TVMode mode; - TVCrtRegs crt; - TVRegs tv; +/* TVCrtRegs crt; */ + /* TVRegs tv; */ int found = 0; int *scanm; char **scano; - /* Modify the settings */ - back_card->getSettings (&settings); - if (opt_connect > CONNECT_NONE) { - settings.connector = opt_connect; - } else { - settings.connector = CONNECT_BOTH; - } - if (opt_flicker >= 0) { - settings.flicker = opt_flicker; - } + /* TODO: do that at initialization and save possible combinations */ /* Find supported TV mode */ for (scanm = &scan_mode_pal[0][0]; *scanm && ! found; scanm += 2) { for (scano = scan_overscan; *scano && ! found; scano++) { - printf("tvmode: trying to use %dx%d %s\n", + fprintf(stderr,"tvmode: trying to use %dx%d %s\n", scanm[0], scanm[1], *scano); + /* if (back_card->findBySize (opt_system, scanm[0], scanm[1], *scano, - &mode, &crt, &tv)) { + &mode)) { current_width = scanm[0]; current_height = scanm[1]; + current_fps = 25; + found++; + } */ + if (back_card->findBySize (opt_system, 800, 600, "Large", + &mode)) { + current_width = 800; + current_height = 600; current_fps = 25; /* TODO: currently this is PAL only */ found++; } @@ -184,8 +230,28 @@ static void tvmode_settvstate (xine_t *this, int width, int height, double fps) /* Switch to mode */ if (found) { - back_card->setModeSettings (TV_PRIV_TVMODE | TV_PRIV_DUALVIEW, - &crt, &tv, &settings); + /* back_card->setModeSettings (TV_PRIV_TVMODE | TV_PRIV_DUALVIEW, + &crt, &tv, &settings); */ + /* mode.regs.devFlags = DEV_MONITOR | DEV_TELEVISION; */ + /* Modify the settings */ + + back_card->getSettings (&settings); + if (opt_connect > CONNECT_NONE) { + settings.connector = opt_connect; + } else { + settings.connector = CONNECT_BOTH; + } + + mode.regs.devFlags = DEV_MONITOR | DEV_TELEVISION; + settings.flags |= TV_DESC_DUALVIEW; + + back_card->setModeSettings (&mode.regs, &settings); + + printf("tvmode: Trying to use mode %i x %i\n",current_width,current_height); + /* + back_card->setMode(&mode.regs); + back_card->setTestImage (NULL, &settings); + */ current_type = 1; } else { printf("tvmode: cannot find any valid TV mode - TV output disabled\n"); @@ -193,7 +259,6 @@ static void tvmode_settvstate (xine_t *this, int width, int height, double fps) } } - /* * PUBLIC */ @@ -206,11 +271,12 @@ int xine_tvmode_switch (xine_t *this, int type, int width, int height, double fp /* * Wasn't initialized */ - if(!was_enabled) + if(!was_enabled) { _tvmode_init(this); - + } if (back_card) { - printf("tvmode: switching to %s\n", type ? "TV" : "default"); + fprintf(stderr, "tvmode: switching to %s\n", type ? "TV" : "default"); + switch (type) { case 0: tvmode_restorestate (this); @@ -260,15 +326,22 @@ static void _tvmode_init(xine_t *this) { tvmode_connect (this); if (back_card) tvmode_savestate (this); + } else { + printf("tvmode: not enabled\n"); } } void xine_tvmode_init (xine_t *this) { + printf("tvmode: Initializing tvmode\n"); + xine_config_register_bool (this, "misc.nv_tvmode", 0, _("NVidia TV-Out support."), NULL, 0, nvtvmode_enable_cb, this); + + /* tvmode_enabled = this->config->register_bool(this->config, "misc.nv_tvmode", 0, _("NVidia TV-Out support."), NULL, 10, nvtvmode_enable_cb, this); + */ _tvmode_init(this); } @@ -283,3 +356,23 @@ void xine_tvmode_exit (xine_t *this) { } } +#else + +/* no nvtv support compiled in lib */ + +int xine_tvmode_switch (xine_t *this, int type, int width, int height, double fps) { + /* not supported: return regular mode */ + return 0; +} + +void xine_tvmode_size (xine_t *this, int *width, int *height, + double *pixelratio, double *fps) { +} + +void xine_tvmode_init (xine_t *this) { +} + +void xine_tvmode_exit (xine_t *this) { +} + +#endif |