From 8e2df27969adca164df2ab27bcebe6e026e8ee52 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sun, 4 May 2003 01:35:04 +0000 Subject: - plenty of nvtv updates by Mattias Eriksson , see the changes to xine.h.in for the API updates, and the mailing list (dated May 3rd 2003) CVS patchset: 4760 CVS date: 2003/05/04 01:35:04 --- src/xine-engine/nvtv/back_client.c | 82 +++++++++++++++++++++++++--- src/xine-engine/nvtv/back_client.h | 2 +- src/xine-engine/nvtv/backend.h | 10 +++- src/xine-engine/nvtv/error.c | 2 +- src/xine-engine/nvtv/error.h | 2 +- src/xine-engine/nvtv/local.h | 44 ++++++++++----- src/xine-engine/nvtv/pipe.c | 49 +++++++++++++++-- src/xine-engine/nvtv/pipe.h | 12 +++-- src/xine-engine/nvtv/tv_chip.h | 62 +++++++++++++-------- src/xine-engine/nvtv/tv_common.h | 5 +- src/xine-engine/nvtv/xfree.h | 16 +----- src/xine-engine/tvmode.c | 108 +++++++++++++++++++++++++++---------- 12 files changed, 298 insertions(+), 96 deletions(-) (limited to 'src') diff --git a/src/xine-engine/nvtv/back_client.c b/src/xine-engine/nvtv/back_client.c index e8c1aadaf..5a3ee0ec6 100644 --- a/src/xine-engine/nvtv/back_client.c +++ b/src/xine-engine/nvtv/back_client.c @@ -16,7 +16,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: back_client.c,v 1.2 2003/02/05 00:14:02 miguelfreitas Exp $ + * $Id: back_client.c,v 1.3 2003/05/04 01:35:05 hadess Exp $ * * Contents: * @@ -24,6 +24,9 @@ * */ +#include "local.h" /* before everything else */ + +#include /* for free */ #include #ifdef HAVE_UNISTD_H @@ -33,11 +36,8 @@ #include #endif - #include -#include "debug.h" -#include "error.h" #include "backend.h" #include "back_client.h" #include "pipe.h" @@ -50,6 +50,51 @@ static FILE *pipe_out = NULL; static CardPtr bcl_root = NULL; static CardPtr bcl_card = NULL; +/* -------- String pool -------- */ + +/* + * Add string to pool, and free original if already in pool. + */ + +static int pool_size = 0; +static char** pool_list = NULL; + +char* pool_addFree (char *s) +{ + int l, r, i; + + DPRINTF ("pool %s ", s); + if (!s) return NULL; + l = 0; r = pool_size-1; + while (l <= r) { + register int c; + + i = (l + r) / 2; + c = strcmp (s, pool_list[i]); + if (c < 0) r = i-1; else + if (c > 0) l = i+1; else + { + DPRINTF ("found\n"); + xfree (s); + return pool_list [i]; + } + } + /* Must insert between r and l */ + if (r < 0) r = 0; /* sanitize for DPRINTF */ + if (pool_list && r >= 0) DPRINTF (" %i=%s ", r, pool_list[r]); + DPRINTF ("*"); + if (pool_list && l < pool_size) DPRINTF (" %i=%s ", l, pool_list[l]); + DPRINTF ("\n"); + pool_size++; + pool_list = xrealloc (pool_list, pool_size * sizeof (char *)); + i = l+1; + if (pool_size > 1) { + memmove (pool_list+i, pool_list+l, (pool_size-i) * sizeof(char *)); + } + pool_list[l] = s; + return s; +} + /* -------- Driver routines -------- */ void bcl_openPipes (void) @@ -226,9 +271,27 @@ TVConnect bcl_getConnection (void) return c; } -/* Attention! The 'size' and 'aspect' strings returned mode.spec are - allocated, and should be freed when not needed anymore. -*/ +int bcl_listModes (TVSystem system, TVMode *(list[])) +{ + TVMode *m, *r; + int n, i, c; + + DPRINTF ("bcl_listModes %i\n", system); + pipeWriteCmd (pipe_out, PCmd_ListModes); + pipeWriteArgs (pipe_out, 1, sizeof(system), &system); + pipeReadCmd (pipe_in); + pipeReadArray (pipe_in, &c); + m = r = xcalloc (sizeof (TVMode), c); + *list = r; + for (i = 1; i <= c; i++, m++) { + n = pipeReadArgs (pipe_in, 3, sizeof(TVMode), m, + 0, &m->spec.size, 0, &m->spec.aspect); + /* assert n == 3 */ + m->spec.size = pool_addFree (m->spec.size); + m->spec.aspect = pool_addFree (m->spec.aspect); + } + return c; +} Bool bcl_findBySize (TVSystem system, int xres, int yres, char *size, TVMode *mode) @@ -244,6 +307,8 @@ Bool bcl_findBySize (TVSystem system, int xres, int yres, char *size, mode->spec.size = mode->spec.aspect = NULL; n = pipeReadArgs (pipe_in, 3, sizeof(TVMode), mode, 0, &mode->spec.size, 0, &mode->spec.aspect); + mode->spec.size = pool_addFree (mode->spec.size); + mode->spec.aspect = pool_addFree (mode->spec.aspect); return (n >= 3); } @@ -261,6 +326,8 @@ Bool bcl_findByOverscan (TVSystem system, int xres, int yres, mode->spec.size = mode->spec.aspect = NULL; n = pipeReadArgs (pipe_in, 3, sizeof(TVMode), mode, 0, &mode->spec.size, 0, &mode->spec.aspect); + mode->spec.size = pool_addFree (mode->spec.size); + mode->spec.aspect = pool_addFree (mode->spec.aspect); return (n >= 3); } @@ -366,6 +433,7 @@ BackCardRec bcl_card_func = { setTestImage: bcl_setTestImage, getStatus: bcl_getStatus, getConnection: bcl_getConnection, + listModes: bcl_listModes, findBySize: bcl_findBySize, findByOverscan: bcl_findByOverscan, initSharedView: bcl_initSharedView, diff --git a/src/xine-engine/nvtv/back_client.h b/src/xine-engine/nvtv/back_client.h index 111f61e04..49b2e29d5 100644 --- a/src/xine-engine/nvtv/back_client.h +++ b/src/xine-engine/nvtv/back_client.h @@ -16,7 +16,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: back_client.h,v 1.2 2003/02/05 00:14:02 miguelfreitas Exp $ + * $Id: back_client.h,v 1.3 2003/05/04 01:35:06 hadess Exp $ * * Contents: * diff --git a/src/xine-engine/nvtv/backend.h b/src/xine-engine/nvtv/backend.h index 434065362..af652b8a2 100644 --- a/src/xine-engine/nvtv/backend.h +++ b/src/xine-engine/nvtv/backend.h @@ -16,7 +16,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: backend.h,v 1.2 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: backend.h,v 1.3 2003/05/04 01:35:06 hadess Exp $ * * Contents: * @@ -33,7 +33,7 @@ #include "tv_common.h" #endif -#include "local.h" /* for Bool, after xfree.h */ +#include "local.h" /* for Bool */ /* WARNING! The first entry of the two following data structures MUST be the 'next' field, and the second entry MUST be a string. If they are not, @@ -84,6 +84,11 @@ typedef struct { #endif } BackAccessRec, *BackAccessPtr; +/* + * listModes: Allocate a list of modes matching system, and return + * size of list. System may be TV_SYSTEM_NONE to match all systems. + */ + typedef struct { void (*openCard) (CardPtr card); void (*closeCard) (void); @@ -104,6 +109,7 @@ typedef struct { void (*setTestImage) (TVEncoderRegs *tv, TVSettings *set); long (*getStatus) (int index); TVConnect (*getConnection) (void); + int (*listModes) (TVSystem system, TVMode *(modes[])); Bool (*findBySize) (TVSystem system, int xres, int yres, char *size, TVMode *mode); Bool (*findByOverscan) (TVSystem system, int xres, int yres, diff --git a/src/xine-engine/nvtv/error.c b/src/xine-engine/nvtv/error.c index 45092cdd4..517eed306 100644 --- a/src/xine-engine/nvtv/error.c +++ b/src/xine-engine/nvtv/error.c @@ -16,7 +16,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: error.c,v 1.1 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: error.c,v 1.2 2003/05/04 01:35:06 hadess Exp $ * * Contents: * diff --git a/src/xine-engine/nvtv/error.h b/src/xine-engine/nvtv/error.h index a7718d28f..918c777bf 100644 --- a/src/xine-engine/nvtv/error.h +++ b/src/xine-engine/nvtv/error.h @@ -16,7 +16,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: error.h,v 1.1 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: error.h,v 1.2 2003/05/04 01:35:06 hadess Exp $ * * Contents: * diff --git a/src/xine-engine/nvtv/local.h b/src/xine-engine/nvtv/local.h index 499982cfa..1b89ec977 100644 --- a/src/xine-engine/nvtv/local.h +++ b/src/xine-engine/nvtv/local.h @@ -16,7 +16,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: local.h,v 1.2 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: local.h,v 1.3 2003/05/04 01:35:06 hadess Exp $ * * Contents: * @@ -25,31 +25,51 @@ * - Defines for GTK2 vs. GTK. * - Define for Bool (must be included after xfree.h for this reason) * + * Defines for all basic types, for + * a) without X, b) with xfree.h, c) under windows. + * Map allocations a) X to normal b) normal to X */ #ifndef _LOCAL_H #define _LOCAL_H -#ifdef __BORLANDC__ -#define inline -#endif +#include "config.h" +#include "debug.h" +#include "error.h" -#ifdef HAVE_GTK +/* -------- GTK -------- */ -#if GTK_MAJOR_VERSION >= 2 +#ifdef HAVE_GTK -#define gdk_screen gdk_x11_get_default_screen() -#define gdk_root_window gdk_x11_get_default_root_xwindow() -#define gtk_spin_button_set_shadow_type(x, y) +#if HAVE_GTK_VERSION == 1 +#define my_gdk_screen gdk_screen +#define my_gdk_root_window gdk_root_window +#define my_gtk_spin_button_set_shadow_type(x, y) gtk_spin_button_set_shadow_type (x,y) +#endif +#if HAVE_GTK_VERSION == 2 +#define my_gdk_screen gdk_x11_get_default_screen() +#define my_gdk_root_window gdk_x11_get_default_root_xwindow() +#define my_gtk_spin_button_set_shadow_type(x, y) #endif + #endif /* HAVE_GTK */ +/* -------- Allocation layer -------- */ + +/* Simulate X via stdlib. nf means 'no failure' */ + +#define xalloc(_size) malloc(_size) +#define xnfcalloc(_num, _size) calloc(_num, _size) +#define xcalloc(_num, _size) calloc(_num, _size) +#define xfree(_ptr) free(_ptr) +#define xrealloc(_ptr, _size) realloc(_ptr, _size) + +/* -------- Basic types -------- */ + #ifndef _XDEFS_H -#ifndef __BORLANDC__ -typedef int Bool; -#endif +#define Bool int #ifndef TRUE #define TRUE 1 diff --git a/src/xine-engine/nvtv/pipe.c b/src/xine-engine/nvtv/pipe.c index 9798072e7..7d428cbcf 100644 --- a/src/xine-engine/nvtv/pipe.c +++ b/src/xine-engine/nvtv/pipe.c @@ -16,7 +16,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: pipe.c,v 1.2 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: pipe.c,v 1.3 2003/05/04 01:35:06 hadess Exp $ * * Contents: * @@ -24,15 +24,25 @@ * */ +#include "local.h" /* before everything else */ + #include #include #include #include -#include "debug.h" -#include "error.h" #include "pipe.h" +/* + * The communication will always include sizes and number of elements + * sent, so even if there are version mismatches, the other end will be + * able to properly synchronize. + * A message consists of + * - the command + * - the number of arguments + * - the size of each argument, followed by the argument itself + */ + /* * Read a command from a pipe */ @@ -251,3 +261,36 @@ void pipeWriteList (FILE *pipe, int size, void *list) fflush (pipe); } +/* + * Read an array with 'nelem' elements. The elements themselves are + * written by their own pipeWrite commands to allow the transfer of + * embedded strings. + */ + +void pipeReadArray (FILE *pipe, int *nelem) +{ + int n; + + DPRINTF ("pipe read array "); + fread (&n, sizeof(n), 1, pipe); + fread (nelem, sizeof(int), 1, pipe); + DPRINTF ("%i (%i)\n", *nelem, n); +} + +/* + * Write an array with 'nelem' elements, each of which has 'nsub' elements + * of size 'size' to the pipe. The elements themselves are written + * by their own pipeWrite commands to allow the transfer of embedded + * strings. + */ + +void pipeWriteArray (FILE *pipe, int nelem, int nsub) +{ + int n; + + DPRINTF ("pipe write array %i * %i\n", nelem, nsub); + n = nelem * nsub + 1; + fwrite (&n, sizeof(n), 1, pipe); + fwrite (&nelem, sizeof(nelem), 1, pipe); + fflush (pipe); +} diff --git a/src/xine-engine/nvtv/pipe.h b/src/xine-engine/nvtv/pipe.h index b65b5235e..0cfaaac6d 100644 --- a/src/xine-engine/nvtv/pipe.h +++ b/src/xine-engine/nvtv/pipe.h @@ -16,7 +16,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: pipe.h,v 1.2 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: pipe.h,v 1.3 2003/05/04 01:35:06 hadess Exp $ * * Contents: * @@ -34,10 +34,10 @@ #define CONFIG_PIPE_PATH "/var/run" #endif -#define PIPE_IN CONFIG_PIPE_PATH ## "/nvtv-in" -#define PIPE_OUT CONFIG_PIPE_PATH ## "/nvtv-out" +#define PIPE_IN CONFIG_PIPE_PATH "/nvtv-in" +#define PIPE_OUT CONFIG_PIPE_PATH "/nvtv-out" -#define PIPE_VERSION 0x000403 /* 0.4.3 */ +#define PIPE_VERSION 0x000404 /* 0.4.4 */ /* even numbered commands expect no return, odd numbered commands do */ @@ -60,6 +60,7 @@ typedef enum { PCmd_GetConnection = 25, /* In: None; Out: connect */ PCmd_FindBySize = 31, /* In: System, x, y, size; Out: mode */ PCmd_FindByOverscan = 33, /* In: System, x, y, hoc, voc; Out: mode */ + PCmd_ListModes = 35, /* In: System Out: int, modes */ PCmd_SetHeads = 40, /* In: 3 heads */ PCmd_GetHeads = 41, /* In: None; Out: 3 heads */ PCmd_GetHeadDev = 43, /* In: Head; Out: Dev Flags */ @@ -79,4 +80,7 @@ void pipeWriteArgs (FILE *pipe, int n, ...); void* pipeReadList (FILE *pipe, int size); void pipeWriteList (FILE *pipe, int size, void *list); +void pipeReadArray (FILE *pipe, int *nelem); +void pipeWriteArray (FILE *pipe, int nelem, int nsub); + #endif /* _PIPE_H */ diff --git a/src/xine-engine/nvtv/tv_chip.h b/src/xine-engine/nvtv/tv_chip.h index 7b5a94634..880a0e9e3 100644 --- a/src/xine-engine/nvtv/tv_chip.h +++ b/src/xine-engine/nvtv/tv_chip.h @@ -16,7 +16,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: tv_chip.h,v 1.2 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: tv_chip.h,v 1.3 2003/05/04 01:35:06 hadess Exp $ * * Contents: * @@ -63,24 +63,23 @@ typedef enum { typedef enum { TV_CHIP_BY_ADDR = -1, TV_NO_CHIP = 0, - TV_CHRONTEL = 0x1000, - TV_BROOKTREE = 0x2000, - TV_CONEXANT = 0x2100, + TV_CHRONTEL = 0x1100, + TV_BROOKTREE = 0x2100, + TV_CONEXANT = 0x2200, TV_PHILIPS = 0x3000, - TV_PHILIPS_7102 = 0x3010, - TV_PHILIPS_7103 = 0x3011, - TV_PHILIPS_7108 = 0x3012, - TV_PHILIPS_7109 = 0x3013, - TV_PHILIPS_7104 = 0x3020, - TV_PHILIPS_7105 = 0x3021, - TV_PHILIPS_7108A = 0x3022, - TV_PHILIPS_7109A = 0x3023, + TV_PHILIPS_MODEL1 = 0x3100, + TV_PHILIPS_MODEL2 = 0x3200, + TV_PHILIPS_7102 = 0x3100, + TV_PHILIPS_7103 = 0x3101, + TV_PHILIPS_7108 = 0x3102, + TV_PHILIPS_7109 = 0x3103, + TV_PHILIPS_7104 = 0x3200, + TV_PHILIPS_7105 = 0x3201, + TV_PHILIPS_7108A = 0x3202, + TV_PHILIPS_7109A = 0x3203, } TVChip; -#define TV_PHILIPS_MODEL 0x00f0 -#define TV_PHILIPS_MODEL1 0x0010 -#define TV_PHILIPS_MODEL2 0x0020 - +#define TV_COMPANY 0xf000 /* mask for company encoder type */ #define TV_ENCODER 0xff00 /* mask for principal encoder type */ /* -------- Host interface flags, all chips -------- */ @@ -313,10 +312,13 @@ typedef struct { #define CH_FLAG_DAC 1:0 #define CH_FLAG_DAC_MASK 3 +#define CH_FLAG_DAC_PD0 (1 << 0) +#define CH_FLAG_DAC_PD1 (1 << 1) #define CH_FLAG_FBAS 2 #define CH_FLAG_SVHS 0 #define CH_FLAG_BOTH 3 +#define CH_FLAG_POUTP (1 << 3) #define CH_FLAG_ACIV (1 << 4) #define CH_FLAG_CFRB (1 << 5) #define CH_FLAG_CVBW (1 << 6) @@ -362,16 +364,20 @@ typedef struct { #define PH_FLAG1_SCBW (1 << 2) #define PH_FLAG1_YGS (1 << 4) #define PH_FLAG1_YFIL (1 << 8) -#define PH_FLAG1_EDGE (1 << 9) #define PH_FLAG1_MASK (PH_FLAG1_FISE | PH_FLAG1_PAL | \ PH_FLAG1_SCBW | PH_FLAG1_YGS) +#define PH_FLAG2_CVBSEN2 (1 << 1) /* Model2 only */ #define PH_FLAG2_CEN (1 << 4) #define PH_FLAG2_CVBSEN0 (1 << 5) #define PH_FLAG2_CVBSEN1 (1 << 6) #define PH_FLAG2_VBSEN (1 << 7) +#define PH_FLAG2_MASK (PH_FLAG2_CEN | PH_FLAG2_CVBSEN0 | \ + PH_FLAG2_CVBSEN1 | PH_FLAG2_CVBSEN2 | \ + PH_FLAG2_VBSEN) + #define PH_FLAG2_NORMAL (PH_FLAG2_CEN | PH_FLAG2_CVBSEN0 | \ PH_FLAG2_VBSEN) #define PH_FLAG2_CONVERT (PH_FLAG2_CEN | PH_FLAG2_CVBSEN0 | \ @@ -380,8 +386,6 @@ typedef struct { #define PH_FLAG2_SVHS PH_FLAG2_NORMAL #define PH_FLAG2_BOTH PH_FLAG2_NORMAL -#define PH_FLAG3_DOUBLE (1 << 0) - typedef struct { int adwhs; /* time */ int adwhe; /* time */ @@ -421,7 +425,22 @@ typedef struct { int flags2; int flags3; int macro; -} TVPhRegs; +} TVPh1Regs; + +#define PH_FLAG3_XINT (1 << 0) /* interpol. filter for upscaling */ +#define PH_FLAG3_IFBP (1 << 4) /* (for high pixel rates) */ +#define PH_FLAG3_IFRA (1 << 5) +#define PH_FLAG3_YUPSC (1 << 6) /* y upscaling enabled */ +#define PH_FLAG3_EIDIV (1 << 7) + +typedef struct { + TVPh1Regs super; /* watch alignment? */ + int yfil; + int fili; + int pcle; + int pcli; + int flags3; +} TVPh2Regs; /* -------- CRT -------- */ @@ -563,7 +582,8 @@ typedef union { TVBtRegs bt; TVCxRegs cx; TVChRegs ch; - TVPhRegs ph; + TVPh1Regs ph1; + TVPh2Regs ph2; } TVEncoderRegs; typedef union { diff --git a/src/xine-engine/nvtv/tv_common.h b/src/xine-engine/nvtv/tv_common.h index 41cf81082..7189506e6 100644 --- a/src/xine-engine/nvtv/tv_common.h +++ b/src/xine-engine/nvtv/tv_common.h @@ -16,7 +16,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: tv_common.h,v 1.2 2003/02/05 00:14:03 miguelfreitas Exp $ + * $Id: tv_common.h,v 1.3 2003/05/04 01:35:06 hadess Exp $ * * Contents: * @@ -27,7 +27,6 @@ #ifndef _TV_COMMON_H #define _TV_COMMON_H -#include "xfree.h" #include "xf86i2c.h" #include "tv_chip.h" @@ -48,7 +47,9 @@ struct _TvEncoderObj { void (*Create) (TVEncoderObj *this, TVChip chip, I2CDevPtr dev); void (*InitRegs) (TVEncoderObj *this, int port); void (*SetRegs) (TVEncoderObj *this, TVEncoderRegs *r, TVState state); + void (*GetRegs) (TVEncoderObj *this, TVEncoderRegs *r); void (*SetPort) (TVEncoderObj *this, int port); + void (*GetPort) (TVEncoderObj *this, int *port); void (*SetState) (TVEncoderObj *this, TVEncoderRegs *r, TVState state); TVConnect (*GetConnect) (TVEncoderObj *this); long (*GetStatus) (TVEncoderObj *this, int index); diff --git a/src/xine-engine/nvtv/xfree.h b/src/xine-engine/nvtv/xfree.h index 47d964b5a..c65a0681b 100644 --- a/src/xine-engine/nvtv/xfree.h +++ b/src/xine-engine/nvtv/xfree.h @@ -7,6 +7,8 @@ #ifndef _XFREE_H #define _XFREE_H 1 +#include "config.h" + #include #include @@ -18,20 +20,6 @@ #define __inline__ inline -/**** libc_wrapper.c */ - -void xf86usleep(unsigned long usec); -void xf86getsecs(long * secs, long * usecs); - -/**** include/os.h */ - -/* modified for stdlib */ - -#define xalloc(size) malloc(size) -#define xnfcalloc(_num, _size) calloc(_num, _size) -#define xcalloc(_num, _size) calloc(_num, _size) -#define xfree(ptr) free(ptr) - /**** common/compiler.h */ #define MMIO_IN8(base, offset) \ diff --git a/src/xine-engine/tvmode.c b/src/xine-engine/tvmode.c index 8d1bcd915..28db0aab5 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.12 2003/02/05 00:14:02 miguelfreitas Exp $ + * $Id: tvmode.c,v 1.13 2003/05/04 01:35:05 hadess Exp $ * * tvmode - TV output selection * @@ -71,11 +71,22 @@ static TVConnect opt_connect = CONNECT_NONE; * if select_origsize == true: * The first available mode is selected (stick to tv resolution) */ static int scan_mode_pal[][2] = { - { 768, 576 }, { 800, 576 }, { 720, 576 }, + { 768, 576 }, + { 720, 576 }, + { 800, 576 }, { 800, 600 }, - { 720, 480 }, { 640, 480 }, + { 720, 480 }, { 800, 450 }, { 1024, 768 }, + { 640, 480 }, + { 0 } +} ; + +static int scan_mode_ntsc[][2] = { + { 720, 480 }, + { 800, 600 }, + { 1024, 768 }, + { 640, 480 }, { 0 } } ; @@ -87,13 +98,9 @@ static char *scan_overscan[] = { /* TODO: flexible */ static double opt_aspect = 4.0 / 3.0; -/* Just turn off warnings */ -static void _tvmode_init(xine_t *this); -void xine_tvmode_exit (xine_t *this); /* * 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; @@ -104,6 +111,7 @@ static void nvtvmode_enable_cb(void *this_gen, xine_cfg_entry_t *entry) { was_enabled = 0; } } + */ @@ -183,26 +191,34 @@ static void tvmode_settvstate (xine_t *this, int width, int height, double fps) /* TVRegs tv; */ int found = 0; int *scanm; + int tmp_fps; char **scano; /* 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++) { - 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)) { - current_width = scanm[0]; - current_height = scanm[1]; - current_fps = 25; + if (opt_system == TV_SYSTEM_NTSC) { + scanm = &scan_mode_ntsc[0][0]; + tmp_fps = 29.97; + } else { + scanm = &scan_mode_pal[0][0]; + tmp_fps = 25; + } + + 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))) { + current_width = mode.spec.res_x; + current_height = mode.spec.res_y; + current_fps = tmp_fps; found++; } } +/* } - + } +*/ /* Switch to mode */ if (found) { back_card->getSettings (&settings); @@ -238,7 +254,7 @@ int xine_tvmode_switch (xine_t *this, int type, int width, int height, double fp * Wasn't initialized */ if(!was_enabled) { - _tvmode_init(this); + xine_tvmode_init(this); } if (back_card) { fprintf(stderr, "tvmode: switching to %s\n", type ? "TV" : "default"); @@ -286,16 +302,44 @@ void xine_tvmode_size (xine_t *this, int *width, int *height, } } -/* Connect to nvtvd server if possible and fetch settings */ -static void _tvmode_init(xine_t *this) { - if(tvmode_enabled) { - tvmode_connect (this); - if (back_card) - tvmode_savestate (this); - } else { - printf("tvmode: not enabled\n"); +/* 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); + 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)) { + tvmode_enabled = 1; + } + } + + return (tvmode_enabled); } + +void xine_tvmode_set_tvsystem(xine_t *self, xine_tvsystem system) { + + switch (system) { + case XINE_TVSYSTEM_PAL: + opt_system = TV_SYSTEM_PAL; + break; + case XINE_TVSYSTEM_NTSC: + opt_system = TV_SYSTEM_NTSC; + break; + default: + opt_system = TV_SYSTEM_PAL; + } +} +/* void xine_tvmode_init (xine_t *this) { printf("tvmode: Initializing tvmode\n"); @@ -303,6 +347,7 @@ void xine_tvmode_init (xine_t *this) { _tvmode_init(this); } +*/ /* Restore old CRT and TV registers and close nvtvd connection */ void xine_tvmode_exit (xine_t *this) { @@ -328,10 +373,17 @@ void xine_tvmode_size (xine_t *this, int *width, int *height, double *pixelratio, double *fps) { } -void xine_tvmode_init (xine_t *this) { +int xine_tvmode_init (xine_t *this) { + return 0; } void xine_tvmode_exit (xine_t *this) { } +void xine_tvmode_set_tvsystem(xine_t *self, xine_tvsystem system) { +} + +int xine_tvmode_use(xine_t *self, int use_tvmode) { + return 0; +} #endif -- cgit v1.2.3