summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBastien Nocera <hadess@users.sourceforge.net>2003-05-16 11:39:50 +0000
committerBastien Nocera <hadess@users.sourceforge.net>2003-05-16 11:39:50 +0000
commit02bccf94416bf678511dff6fb1bd1a986f69117d (patch)
treebf822e439bbd961ee11ad8ac10660182ca4fcf14 /src
parent0dc71e0c3e90cd732f149fefc601a65f6ef530a1 (diff)
downloadxine-lib-02bccf94416bf678511dff6fb1bd1a986f69117d.tar.gz
xine-lib-02bccf94416bf678511dff6fb1bd1a986f69117d.tar.bz2
- nvtv fixes by Mattias Eriksson <snaggen@acc.umu.se>
CVS patchset: 4865 CVS date: 2003/05/16 11:39:50
Diffstat (limited to 'src')
-rw-r--r--src/xine-engine/tvmode.c293
1 files changed, 134 insertions, 159 deletions
diff --git a/src/xine-engine/tvmode.c b/src/xine-engine/tvmode.c
index b928c2f2d..2b1f62f0c 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.14 2003/05/06 20:59:43 mroi Exp $
+ * $Id: tvmode.c,v 1.15 2003/05/16 11:39:50 hadess Exp $
*
* tvmode - TV output selection
*
@@ -45,122 +45,77 @@
* PRIVATE
*/
-/* FIXME: currently the used backend only supports one (1) connection
- * to a server and needs this global, external pointer */
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_tvregs;
static TVSettings old_settings;
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_NONE;
-/* This is the list of possible modes for the used TV system.
- * TODO:
- * if select_origsize == false:
- * The one closest (but larger) to the input stream size is selected.
- * if select_origsize == true:
- * The first available mode is selected (stick to tv resolution) */
-static int scan_mode_pal[][2] = {
- { 768, 576 },
- { 720, 576 },
- { 800, 576 },
- { 800, 600 },
- { 720, 480 },
- { 800, 450 },
- { 1024, 768 },
- { 640, 480 },
- { 0 }
-} ;
-
-static int scan_mode_ntsc[][2] = {
- { 720, 480 },
- { 800, 600 },
- { 1024, 768 },
- { 640, 480 },
- { 0 }
-} ;
-
-/* FIXME: needed? */
-#if 0
-/* Overscan sizes to be scaned for - note that we do *not* scan for 'Small' */
-static char *scan_overscan[] = {
- "Interl", "Huge", "Large", "DVD", "Normal", 0
-} ;
-#endif
+static TVMode *modes_pal = NULL;
+static int size_modes_pal = 0;
+static TVMode *modes_ntsc =NULL;
+static int size_modes_ntsc = 0;
-/* TODO: flexible */
static double opt_aspect = 4.0 / 3.0;
-/*
- * Config callback for tvmode enability.
-static void nvtvmode_enable_cb(void *this_gen, xine_cfg_entry_t *entry) {
- xine_t *this = (xine_t *) this_gen;
-
- tvmode_enabled = entry->num_value;
-
- if(!tvmode_enabled && was_enabled) {
- xine_tvmode_exit(this);
- was_enabled = 0;
- }
-}
- */
-
-
-
/* Try to connect to nvtvd server */
static void tvmode_connect(xine_t *this) {
CardPtr main_card_list, main_card = NULL;
-
+
+ if (was_enabled) {
+ if (this->verbosity >= XINE_VERBOSITY_LOG)
+ printf ("tvmode: Already initialized!\n");
+ return;
+ }
if (back_client_avail ()) {
main_card_list = back_client_init ();
} else {
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf ("tvmode: Nvtvd not detected, make sure nvtvd is running.\n");
+ printf ("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) {
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf ("tvmode: No supported video card found.\n");
+ printf ("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) {
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf ("tvmode: No supported video card found at specified address.\n");
+ printf ("tvmode: No supported video card found at specified address.\n");
/* Handle well in some way... */
return;
}
-
+
if (back_access) {
back_access->openCard (main_card);
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: Using card %s for tvout\n", main_card->name);
+ printf("tvmode: Using card %s for tvout\n", main_card->name);
was_enabled = 1;
} else {
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: cannot connect to nvtvd - no TV mode switching available\n");
+ printf("tvmode: cannot connect to nvtvd - no TV mode switching available\n");
}
}
@@ -170,12 +125,12 @@ static void tvmode_connect(xine_t *this) {
static void tvmode_disconnect (xine_t *this) {
back_access->closeCard ();
back_access = 0;
+ was_enabled = 0;
}
/* Save current CRT and TV register configuration */
static void tvmode_savestate (xine_t *this) {
-/* back_card->getMode (&old_crt, &old_tv); */
back_card->getSettings(&old_settings);
back_card->getMode (&old_tvregs);
}
@@ -183,11 +138,11 @@ static void tvmode_savestate (xine_t *this) {
/* Restore CRT and TV register configuration */
static void tvmode_restorestate (xine_t *this) {
-/* back_card->setMode (0, &old_crt, &old_tv); */
-
back_card->setModeSettings (&old_tvregs,&old_settings);
+
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: Old mode saved!");
+ printf("tvmode: Old mode saved!");
+
current_type = 0;
}
@@ -196,37 +151,36 @@ static void tvmode_restorestate (xine_t *this) {
static void tvmode_settvstate (xine_t *this, int width, int height, double fps) {
TVSettings settings;
TVMode mode;
-/* TVCrtRegs crt; */
- /* TVRegs tv; */
+ TVMode *modes;
+ int size;
int found = 0;
- int *scanm;
int tmp_fps;
-
-
+ int i;
+
/* TODO: do that at initialization and save possible combinations */
/* Find supported TV mode */
if (opt_system == TV_SYSTEM_NTSC) {
- scanm = &scan_mode_ntsc[0][0];
+ modes = modes_ntsc;
+ size = size_modes_ntsc;
tmp_fps = 29.97;
} else {
- scanm = &scan_mode_pal[0][0];
+ modes = modes_pal;
tmp_fps = 25;
+ size = size_modes_pal;
}
-
- for (; *scanm && ! found; scanm += 2) {
- if ((width <= scanm[0]) && (height <= scanm[1]) &&
- (back_card->findByOverscan (opt_system, scanm[0], scanm[1], 0.1,0.1, &mode))) {
+ for (i=0; i < size; i++) {
+ /*
+ printf ("Trying mode %dx%d %f %f\n", modes[i].spec.res_x, modes[i].spec.res_y, modes[i].spec.hoc, modes[i].spec.voc);
+ */
+ if ((width <= modes[i].spec.res_x) && (height <= modes[i].spec.res_y) &&
+ (back_card->findByOverscan (opt_system, modes[i].spec.res_x, modes[i].spec.res_y, 10, 5, &mode))) {
current_width = mode.spec.res_x;
current_height = mode.spec.res_y;
current_fps = tmp_fps;
- found++;
- }
- }
-/*
- }
+ found++;
+ }
}
-*/
/* Switch to mode */
if (found) {
back_card->getSettings (&settings);
@@ -242,12 +196,12 @@ static void tvmode_settvstate (xine_t *this, int width, int height, double fps)
back_card->setModeSettings (&mode.regs, &settings);
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: Trying to use mode %i x %i\n",current_width,current_height);
- current_type = 1;
+ printf("tvmode: Trying to use mode %i x %i\n",current_width,current_height);
+ current_type = 1;
} else {
if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: cannot find any valid TV mode - TV output disabled\n");
- xine_tvmode_exit (this);
+ printf("tvmode: cannot find any valid TV mode - TV output disabled\n");
+ xine_tvmode_exit (this);
}
}
@@ -258,77 +212,101 @@ static void tvmode_settvstate (xine_t *this, int width, int height, double fps)
/* Set to 'regular'(0) or 'tv'(1) state, that is if it is enabled */
int xine_tvmode_switch (xine_t *this, int type, int width, int height, double fps) {
- if(tvmode_enabled) {
-
- /*
- * Wasn't initialized
- */
- if(!was_enabled) {
- xine_tvmode_init(this);
- }
- if (back_card) {
- if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: switching to %s\n", type ? "TV" : "default");
-
- switch (type) {
- case 0:
- tvmode_restorestate (this);
- break;
- case 1:
- tvmode_settvstate (this, width, height, fps);
- break;
- default:
- if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: illegal type for switching\n");
- tvmode_restorestate (this);
- }
- } else {
- if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf("tvmode: not connected to nvtvd for switching\n");
- }
+ if(tvmode_enabled) {
- }
+ /*
+ * Wasn't initialized
+ */
+ if(!was_enabled) {
+ xine_tvmode_init(this);
+ }
+ if (back_card) {
+ if (this->verbosity >= XINE_VERBOSITY_LOG)
+ printf("tvmode: switching to %s\n", type ? "TV" : "default");
+
+ switch (type) {
+ case 0:
+ tvmode_restorestate (this);
+ break;
+ case 1:
+ tvmode_settvstate (this, width, height, fps);
+ break;
+ default:
+ if (this->verbosity >= XINE_VERBOSITY_LOG)
+ printf("tvmode: illegal type for switching\n");
+ tvmode_restorestate (this);
+ }
+ } else {
+ if (this->verbosity >= XINE_VERBOSITY_LOG)
+ printf("tvmode: not connected to nvtvd for switching\n");
+ }
- return current_type;
+ }
+ return current_type;
}
-
/* Addapt (maximum) output size to visible area and set pixel aspect and fps */
void xine_tvmode_size (xine_t *this, int *width, int *height,
- double *pixelratio, double *fps) {
-
- if(tvmode_enabled) {
-
- switch (current_type) {
- case 1:
- if (width && *width > current_width)
- *width = current_width;
- if (height && *height > current_height)
- *height = current_height;
- if (pixelratio)
- *pixelratio = ((double) current_width / current_height) / opt_aspect;
- if (fps)
- *fps = current_fps;
- break;
+ double *pixelratio, double *fps) {
+
+ if(tvmode_enabled) {
+
+ switch (current_type) {
+ case 1:
+ /*
+ if (width && *width > current_width)
+ */
+ if (width)
+ *width = current_width;
+ /*
+ if (height && *height > current_height)
+ */
+ if (height)
+ *height = current_height;
+ if (pixelratio)
+ *pixelratio = ((double) current_width / current_height) / opt_aspect;
+ if (fps)
+ *fps = current_fps;
+ break;
+ }
+
}
+}
+
+void init_modes() {
+ int i;
+
+ size_modes_pal = back_card->listModes(TV_SYSTEM_PAL, &modes_pal);
+
+ size_modes_ntsc = back_card->listModes(TV_SYSTEM_NTSC, &modes_ntsc);
+
+ /*
+ for (i=0; i < size_modes_pal; i++) {
+ printf ("Modes PAL %dx%d %f %f\n", modes_pal[i].spec.res_x, modes_pal[i].spec.res_y, modes_pal[i].spec.hoc, modes_pal[i].spec.voc);
+ }
+
+ for (i=0; i < size_modes_pal; i++) {
+ printf ("Modes NTSC %dx%d %f %f\n", modes_ntsc[i].spec.res_x, modes_ntsc[i].spec.res_y, modes_ntsc[i].spec.hoc, modes_ntsc[i].spec.voc);
+ }
+ */
- }
}
/* Connect to nvtvd server if possible and store settings */
int xine_tvmode_init(xine_t *self) {
-
+
tvmode_connect (self);
if (back_card) {
tvmode_savestate (self);
+ init_modes();
return 1;
- }
+ }
return 0;
}
int xine_tvmode_use(xine_t *self, int use_tvmode) {
-
+
tvmode_enabled = 0;
if (use_tvmode) {
if (was_enabled || xine_tvmode_init(self)) {
@@ -340,7 +318,7 @@ int xine_tvmode_use(xine_t *self, int use_tvmode) {
}
void xine_tvmode_set_tvsystem(xine_t *self, xine_tvsystem system) {
-
+
switch (system) {
case XINE_TVSYSTEM_PAL:
opt_system = TV_SYSTEM_PAL;
@@ -352,25 +330,22 @@ void xine_tvmode_set_tvsystem(xine_t *self, xine_tvsystem system) {
opt_system = TV_SYSTEM_PAL;
}
}
-/*
-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_init(this);
-}
-*/
/* Restore old CRT and TV registers and close nvtvd connection */
void xine_tvmode_exit (xine_t *this) {
- if(tvmode_enabled || was_enabled) {
- if (back_card) {
- tvmode_restorestate (this);
- tvmode_disconnect (this);
+ if(tvmode_enabled || was_enabled) {
+ if (back_card) {
+ tvmode_restorestate (this);
+ tvmode_disconnect (this);
+ }
+ if (modes_pal != NULL) {
+ free(modes_pal);
+ }
+ if (modes_ntsc != NULL) {
+ free(modes_ntsc);
+ }
}
- }
}
#else
@@ -378,12 +353,12 @@ void xine_tvmode_exit (xine_t *this) {
/* 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;
+ /* not supported: return regular mode */
+ return 0;
}
void xine_tvmode_size (xine_t *this, int *width, int *height,
- double *pixelratio, double *fps) {
+ double *pixelratio, double *fps) {
}
int xine_tvmode_init (xine_t *this) {