diff options
-rw-r--r-- | include/xine.h.tmpl.in | 44 | ||||
-rw-r--r-- | src/video_out/video_out_xv.c | 4 | ||||
-rw-r--r-- | src/xine-engine/Makefile.am | 4 | ||||
-rw-r--r-- | src/xine-engine/nvtvd.c | 761 | ||||
-rw-r--r-- | src/xine-engine/nvtvd.h | 1249 | ||||
-rw-r--r-- | src/xine-engine/tvmode.c | 235 |
6 files changed, 2293 insertions, 4 deletions
diff --git a/include/xine.h.tmpl.in b/include/xine.h.tmpl.in index 5a320ec8b..b573ffd56 100644 --- a/include/xine.h.tmpl.in +++ b/include/xine.h.tmpl.in @@ -28,7 +28,7 @@ \endverbatim */ /* - * $Id: xine.h.tmpl.in,v 1.97 2002/06/07 12:42:01 miguelfreitas Exp $ + * $Id: xine.h.tmpl.in,v 1.98 2002/06/10 21:42:44 mshopf Exp $ * */ @@ -2000,6 +2000,48 @@ char *xine_set_locale(void); /** @} end of locale_group */ + /** + * \defgroup xine_tvmode TV mode selection functions + * @{ + */ +/** + * \fn void xine_tvmode_init (); + * \brief connect to nvtvd server and save current TV and X settings + * \param none + */ +void xine_tvmode_init (); + +/** + * \fn void xine_tvmode_exit (); + * \brief restore old TV and X settings and close nvtvd connection + * \param none + */ +void xine_tvmode_exit (); + +/** + * \fn int xine_tvmode_switch (int type, int width, int height, double fps); + * \brief try to change TV state if enabled + * \param type select 'regular' (0) or 'TV' (1) state + * \param width frame width the mode should match best or 0 if unknown + * \param height frame height the mode should match best or 0 if unknown + * \param fps frame rate the mode should match best or 0 if unknown + * \return finally selected state + * \sa xine_tvmode_init(), xine_tvmode_exit(), xine_tvmode_size() + */ +int xine_tvmode_switch (int type, int width, int height, double fps); + +/** + * \fn void xine_tvmode_size (int *width, int *height, double *pixelaspect, double *fps); + * \brief addapt (maximum) output size to visible area if necessary and return pixel aspect and real frame rate if available + * \param width output width to be adapted or NULL + * \param height output height to be adapted or NULL + * \param pixelaspect pixel aspect to be adapted or NULL + * \param frame rate of current TV mode to be adapted or NULL + */ +void xine_tvmode_size (int *width, int *height, double *pixelaspect, double *fps); + + /** @} end of xine_tvmode */ + /** @} end of xine_api */ #ifdef __cplusplus diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index d6e9b1e8d..1e21e816f 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.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: video_out_xv.c,v 1.118 2002/06/09 08:30:58 esnel Exp $ + * $Id: video_out_xv.c,v 1.119 2002/06/10 21:42:45 mshopf Exp $ * * video_out_xv.c, X11 video extension interface for xine * @@ -134,6 +134,7 @@ struct xv_driver_s { int delivered_width; int delivered_height; int delivered_ratio_code; + int delivered_duration; /* * displayed part of delivered images, @@ -847,6 +848,7 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { this->delivered_width = frame->width; this->delivered_height = frame->height; this->delivered_ratio_code = frame->ratio_code; + this->delivered_duration = frame->vo_frame.duration; xv_compute_ideal_size (this); diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am index e492330ca..6db088824 100644 --- a/src/xine-engine/Makefile.am +++ b/src/xine-engine/Makefile.am @@ -10,7 +10,7 @@ lib_LTLIBRARIES = libxine.la libxine_la_SOURCES = xine.c metronom.c configfile.c buffer.c \ load_plugins.c video_decoder.c buffer_types.c \ audio_decoder.c video_out.c audio_out.c resample.c events.c lrb.c \ - video_overlay.c osd.c scratch.c locale.c demux.c + video_overlay.c osd.c scratch.c locale.c demux.c nvtvd.c tvmode.c libxine_la_DEPENDENCIES = @INTLLIBS@ libxine_la_LIBADD = $(THREAD_LIBS) $(DYNAMIC_LD_LIBS) @INTLLIBS@ $(ZLIB_LIBS) -lm @@ -21,7 +21,7 @@ include_HEADERS = buffer.h metronom.h configfile.h \ audio_out.h resample.h video_out.h xine_internal.h spu_decoder.h \ events.h lrb.h video_overlay.h osd.h scratch.h xineintl.h -noinst_HEADERS = bswap.h +noinst_HEADERS = bswap.h nvtvd.h @INCLUDED_INTL_TRUE@@INTLLIBS@: @INCLUDED_INTL_TRUE@ @cd $(top_builddir)/intl && $(MAKE) libintl.la diff --git a/src/xine-engine/nvtvd.c b/src/xine-engine/nvtvd.c new file mode 100644 index 000000000..b9f01b956 --- /dev/null +++ b/src/xine-engine/nvtvd.c @@ -0,0 +1,761 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a unix video player. + * + * xine 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. + * + * xine 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.c,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * nvtvd - Routines for communication with nvtvd. + * + * This is the combination of several files from the nvtvd package + * by Dirk Thierbach <dthierbach@gmx.de>. They have been inserted into + * one single file in order not to clutter the source filespace too much. + * The only change has been the removal of some '#include' statements, + * and only a small fraction from debug.h has been included. + * + * This file contains (in this order): + * pipe.h debug.h back_client.c pipe.c + */ + +#include "nvtvd.h" + + +/* NVTV pipe header -- Dirk Thierbach <dthierbach@gmx.de> + * + * This file is part of nvtv, a tool for tv-output on NVidia cards. + * + * nvtv 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. + * + * nvtv 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.c,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * Contents: + * + * Routine prototypes to access the named pipe for server/client + * communication, and communication protocol constants. + * + */ + +#ifndef _PIPE_H +#define _PIPE_H + +#define PIPE_IN "/tmp/.nvtv-in" +#define PIPE_OUT "/tmp/.nvtv-out" + +#define PIPE_VERSION 2 /* 0.3.1 */ + +/* even commands expect no return, odd commands do */ + +typedef enum { + PCmd_None = 0, /* In: None */ + PCmd_Init = 1, /* In: None; Out: card list */ + PCmd_Kill = 2, /* In: None */ + PCmd_Version = 3, /* In: None; Out: version */ + PCmd_CloseCard = 10, /* In: None */ + PCmd_OpenCard = 11, /* In: Card index; Out: chip list */ + PCmd_SetChip = 12, /* In: Chip index, init; */ + PCmd_ProbeChips = 13, /* In: None; Out: chip list */ + PCmd_SetSettings = 14, /* In: Settings; */ + PCmd_GetSettings = 15, /* In: None; Out: Settings */ + PCmd_SetMode = 16, /* In: Flags, crt, tv; */ + PCmd_GetMode = 17, /* In: None; Out: Crt, tv */ + PCmd_SetModeSettings = 18, /* In: Flags, crt, tv, set; */ + PCmd_SetTestImage = 20, /* In: Flags, tv, set; */ + PCmd_GetStatus = 23, /* In: Index; Out: status */ + 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_SetHeads = 40, /* In: 3 heads */ + PCmd_GetHeads = 41, /* In: None; Out: 3 heads */ + PCmd_InitSharedView = 51, /* In: None; Out: 4 int */ + PCmd_GetTwinView = 53, /* In: None; Out: 2 int, bool */ + PCmd_AdjustView = 55, /* In: 3 int; Out: 2 int, bool */ + PCmd_ServiceVC = 57, /* In: 5 int; Out: 2 int, bool */ +} PipeCmd; + +PipeCmd pipeReadCmd (FILE *pipe); +void pipeWriteCmd (FILE *pipe, PipeCmd cmd); + +int pipeReadArgs (FILE *pipe, int n, ...); +int pipeReadArgsOpt (FILE *pipe, int n, ...); +void pipeWriteArgs (FILE *pipe, int n, ...); + +void* pipeReadList (FILE *pipe, int size); +void pipeWriteList (FILE *pipe, int size, void *list); + +#endif /* _PIPE_H */ + +/* excerpt from debug.h */ +#define ERROR(X...) fprintf(stderr, X) + +/* Fake output */ +#define FPRINTF(X...) fprintf(stderr, X) + +#ifdef NVTV_DEBUG +#define DPRINTF(X...) fprintf(stderr, X) +#define NO_TIMEOUT +#else +#define DPRINTF(X...) /* */ +#endif + +/* NVTV client backend -- Dirk Thierbach <dthierbach@gmx.de> + * + * This file is part of nvtv, a tool for tv-output on NVidia cards. + * + * nvtv 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. + * + * nvtv 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.c,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * Contents: + * + * Client backend for accessing the server + * + */ + +#include <string.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> + +/* -------- State -------- */ + +static FILE *pipe_in = NULL; +static FILE *pipe_out = NULL; + +static CardPtr bcl_root = NULL; +static CardPtr bcl_card = NULL; + +/* -------- Driver routines -------- */ + +void bcl_openPipes (void) +{ + /* IMPORTANT: Open out pipe first, otherwise deadlock */ + pipe_out = fopen (PIPE_OUT, "w"); + pipe_in = fopen (PIPE_IN, "r"); +} + +void bcl_closePipes (void) +{ + fclose (pipe_in ); + fclose (pipe_out); +} + +void bcl_openCard (CardPtr card) +{ + CardPtr c; + int i, index; + + DPRINTF ("bcl_open\n"); + bcl_card = card; + bcl_openPipes (); + /* convert card to index */ + i = index = 0; + for (c = bcl_root; c; c = c->next) { + i++; + if (c == card) index = i; + } + pipeWriteCmd (pipe_out, PCmd_OpenCard); + pipeWriteArgs (pipe_out, 1, sizeof(index), &index); + pipeReadCmd (pipe_in); + bcl_card->chips = pipeReadList (pipe_in, sizeof (ChipInfo)); +} + +void bcl_closeCard (void) +{ + DPRINTF ("bcl_close\n"); + pipeWriteCmd (pipe_out, PCmd_CloseCard); + pipeWriteArgs (pipe_out, 0); + bcl_closePipes (); +} + +void bcl_setHeads (int main, int tv, int video) +{ + DPRINTF ("bcl_setHeads %i %i %i\n", main, tv, video); + pipeWriteCmd (pipe_out, PCmd_SetHeads); + pipeWriteArgs (pipe_out, 3, sizeof(int), &main, sizeof(int), &tv, + sizeof(int), &video); +} + +void bcl_getHeads (int *main, int *tv, int *video, int *max) +{ + DPRINTF ("bcl_getHeads\n"); + pipeWriteCmd (pipe_out, PCmd_GetHeads); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 4, sizeof(int), main, sizeof(int), tv, + sizeof(int), video, sizeof(int), max); +} + +void bcl_probeChips (void) +{ + ChipPtr chip, del; + + DPRINTF ("bcl_probe\n"); + chip = bcl_card->chips; + while (chip) { + del = chip; + chip = chip->next; + free (del->name); + free (del); + } + pipeWriteCmd (pipe_out, PCmd_ProbeChips); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + bcl_card->chips = pipeReadList (pipe_in, sizeof (ChipInfo)); +} + +void bcl_setChip (ChipPtr chip, Bool init) +{ + ChipPtr c; + int i, index; + + DPRINTF ("bcl_setChip %s %i\n", chip->name, init); + /* convert chip to index */ + i = index = 0; + for (c = bcl_card->chips; c; c = c->next) { + i++; + if (c == chip) index = i; + } + pipeWriteCmd (pipe_out, PCmd_SetChip); + pipeWriteArgs (pipe_out, 2, sizeof(index), &index, sizeof(init), &init); +} + +void bcl_setSettings (TVSettings *set) +{ + DPRINTF ("bcl_setSettings\n"); + pipeWriteCmd (pipe_out, PCmd_SetSettings); + pipeWriteArgs (pipe_out, 1, sizeof(TVSettings), set); +} + +void bcl_getSettings (TVSettings *set) +{ + DPRINTF ("bcl_getSettings\n"); + pipeWriteCmd (pipe_out, PCmd_GetSettings); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 1, sizeof(TVSettings), set); +} + +void bcl_setMode (int ModeFlags, TVCrtRegs *crt, TVRegs *tv) +{ + DPRINTF ("bcl_setMode\n"); + pipeWriteCmd (pipe_out, PCmd_SetMode); + pipeWriteArgs (pipe_out, 3, sizeof(ModeFlags), &ModeFlags, + sizeof(TVCrtRegs), crt, sizeof(TVRegs), tv); +} + +void bcl_getMode (TVCrtRegs *crt, TVRegs *tv) +{ + DPRINTF ("bcl_getMode\n"); + pipeWriteCmd (pipe_out, PCmd_GetMode); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 2, sizeof(TVCrtRegs), crt, sizeof(TVRegs), tv); +} + +void bcl_setModeSettings (int ModeFlags, TVCrtRegs *crt, + TVRegs *tv, TVSettings *set) +{ + DPRINTF ("bcl_setModeSettings\n"); + pipeWriteCmd (pipe_out, PCmd_SetModeSettings); + pipeWriteArgs (pipe_out, 4, sizeof(ModeFlags), &ModeFlags, + sizeof(TVCrtRegs), crt, sizeof(TVRegs), tv, + sizeof(TVSettings), set); +} + +void bcl_setTestImage (int ModeFlags, TVRegs *tv, TVSettings *set) +{ + DPRINTF ("bcl_setTestImage\n"); + pipeWriteCmd (pipe_out, PCmd_SetTestImage); + pipeWriteArgs (pipe_out, 3, sizeof(int), &ModeFlags, + sizeof(TVRegs), tv, sizeof(TVSettings), set); +} + +long bcl_getStatus (int index) +{ + long l; + + DPRINTF ("bcl_getStatus\n"); + pipeWriteCmd (pipe_out, PCmd_GetStatus); + pipeWriteArgs (pipe_out, 1, sizeof(index), &index); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 1, sizeof(l), &l); + return l; +} + +TVConnect bcl_getConnection (void) +{ + TVConnect c; + + DPRINTF ("bcl_getConnection\n"); + pipeWriteCmd (pipe_out, PCmd_GetConnection); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 1, sizeof(c), &c); + DPRINTF ("bcl_getConnection got %i\n", c); + return c; +} + +Bool bcl_findBySize (TVSystem system, int xres, int yres, char *size, + TVMode *mode, TVCrtRegs *crt, TVRegs *tv) +{ + int n; + + DPRINTF ("bcl_findBySize %i %i,%i %s\n", system, xres, yres, size); + pipeWriteCmd (pipe_out, PCmd_FindBySize); + pipeWriteArgs (pipe_out, 4, sizeof(system), &system, + sizeof(xres), &xres, sizeof(yres), &yres, + strlen(size)+1, size); + pipeReadCmd (pipe_in); + n = pipeReadArgs (pipe_in, 3, sizeof(TVMode), mode, + sizeof(TVCrtRegs), crt, sizeof(TVRegs), tv); + if (mode) { + mode->crt = crt; + mode->tv = tv; + } + return (n >= 1); +} + +Bool bcl_findByOverscan (TVSystem system, int xres, int yres, + double hoc, double voc, TVMode *mode, TVCrtRegs *crt, TVRegs *tv) +{ + int n; + + DPRINTF ("bcl_findByOC %i %i,%i\n", system, xres, yres); + pipeWriteCmd (pipe_out, PCmd_FindByOverscan); + pipeWriteArgs (pipe_out, 5, sizeof(system), &system, + sizeof(xres), &xres, sizeof(yres), &yres, + sizeof(hoc), &hoc, sizeof(voc), &voc); + pipeReadCmd (pipe_in); + n = pipeReadArgs (pipe_in, 3, sizeof(TVMode), mode, + sizeof(TVCrtRegs), crt, sizeof(TVRegs), tv); + if (mode) { + mode->crt = crt; + mode->tv = tv; + } + return (n >= 1); +} + +void bcl_initSharedView (int *view_x, int *view_y) +{ + DPRINTF ("bcl_initSharedView\n"); + pipeWriteCmd (pipe_out, PCmd_InitSharedView); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 2, sizeof(int), view_x, sizeof(int), view_y); +} + +Bool bcl_getTwinView (int *view_x, int *view_y) +{ + Bool result; + + DPRINTF ("bcl_getTwinVie\n"); + pipeWriteCmd (pipe_out, PCmd_GetTwinView); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 3, sizeof(Bool), &result, + sizeof(int), view_x, sizeof(int), view_y); + return result; +} + +Bool bcl_adjustViewport (int flags, int *view_x, int *view_y) +{ + Bool result; + + DPRINTF ("bcl_adjustViewport\n"); + pipeWriteCmd (pipe_out, PCmd_AdjustView); + pipeWriteArgs (pipe_out, 3, sizeof(int), &flags, + sizeof(int), view_x, sizeof(int), view_y); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_out, 3, sizeof(int), &result, + sizeof(int), view_x, sizeof(int), view_y); + return result; +} + +Bool bcl_serviceViewportCursor (int flags, int cursor_x, int cursor_y, + int *view_x, int *view_y) +{ + Bool result; + + DPRINTF ("bcl_serviceViewportCursor\n"); + pipeWriteCmd (pipe_out, PCmd_ServiceVC); + pipeWriteArgs (pipe_out, 5, sizeof(int), &flags, + sizeof(int), &cursor_x, sizeof(int), &cursor_y, + sizeof(int), view_x, sizeof(int), view_y); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_out, 3, sizeof(int), &result, + sizeof(int), view_x, sizeof(int), view_y); + return result; +} + +BackAccessRec bcl_access_func = { + openCard: bcl_openCard, + closeCard: bcl_closeCard, +#ifdef DEBUG_PROBE + probeSystem: bnull_probeSystem, +#endif +}; + +BackCardRec bcl_card_func = { + openCard: bcl_openCard, + closeCard: bcl_closeCard, +#ifdef DEBUG_PROBE + probeCard: bnull_probeCard, + probeBus: bnull_probeBus, +#endif + setHeads: bcl_setHeads, + getHeads: bcl_getHeads, + probeChips: bcl_probeChips, + setChip: bcl_setChip, + setSettings: bcl_setSettings, + getSettings: bcl_getSettings, + setMode: bcl_setMode, + getMode: bcl_getMode, + setModeSettings: bcl_setModeSettings, + setTestImage: bcl_setTestImage, + getStatus: bcl_getStatus, + getConnection: bcl_getConnection, + findBySize: bcl_findBySize, + findByOverscan: bcl_findByOverscan, + initSharedView: bcl_initSharedView, + getTwinView: bcl_getTwinView, + adjustViewport: bcl_adjustViewport, + serviceViewportCursor: bcl_serviceViewportCursor, +}; + +/* -------- Init -------- */ + +Bool back_client_avail (void) +{ + int version; + int fd_out, fd_in; + + /* IMPORTANT: Open out pipe first, otherwise deadlock */ + fd_out = open (PIPE_OUT, O_WRONLY | O_NONBLOCK); + if (fd_out < 0) return FALSE; + fd_in = open (PIPE_IN, O_RDONLY | O_NONBLOCK); + if (fd_in < 0) { + close (fd_out); + return FALSE; + } + close (fd_in); + close (fd_out); + bcl_openPipes (); + if (!pipe_in || !pipe_out) { + /* FIXME: error message */ + bcl_closePipes (); + return FALSE; + } + pipeWriteCmd (pipe_out, PCmd_Version); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 1, sizeof(version), &version); + bcl_closePipes (); + return (version == PIPE_VERSION); +} + + +CardPtr back_client_init (void) +{ + CardPtr card; + + back_access = &bcl_access_func; + back_card = &bcl_card_func; + bcl_openPipes (); + pipeWriteCmd (pipe_out, PCmd_Init); + pipeWriteArgs (pipe_out, 0); + bcl_root = pipeReadList (pipe_in, sizeof (CardInfo)); + bcl_card = bcl_root; + bcl_closePipes (); + for (card = bcl_card; card; card = card->next) { + card->chips = NULL; + card->dev = NULL; + } + return bcl_root; +} + +/* NVTV pipe -- Dirk Thierbach <dthierbach@gmx.de> + * + * This file is part of nvtv, a tool for tv-output on NVidia cards. + * + * nvtv 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. + * + * nvtv 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.c,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * Contents: + * + * Routines to access the named pipe for server/client communication + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +/* + * Read a command from a pipe + */ + +PipeCmd pipeReadCmd (FILE *pipe) +{ + PipeCmd cmd; + + DPRINTF ("pipe read cmd\n"); + fread (&cmd, sizeof(PipeCmd), 1, pipe); + DPRINTF ("pipe read cmd, got %i\n", cmd); + return cmd; +} + +/* + * Write a command to a pipe + */ + +void pipeWriteCmd (FILE *pipe, PipeCmd cmd) +{ + DPRINTF ("pipe write cmd %i\n", cmd); + fwrite (&cmd, sizeof(PipeCmd), 1, pipe); + fflush (pipe); + DPRINTF ("pipe write cmd done\n"); +} + +/* + * Write arguments to a pipe. Ellipsis paramaters are: + * size1, pointer1, size2, pointer2, ..., 0 + * Ignore zero size of null pointer arguments. + */ + +void pipeWriteArgs (FILE *pipe, int n, ...) +{ + va_list ap; + int i, s; + void *p; + + DPRINTF ("pipe write args\n"); + fwrite (&n, sizeof(n), 1, pipe); + va_start(ap, n); + for (i = 0; i < n; i++) { + s = va_arg(ap, int); + p = va_arg(ap, void *); + if (!p) s = 0; + fwrite (&s, sizeof(s), 1, pipe); + if (s != 0) { + fwrite (p, s, 1, pipe); + } + } + fflush (pipe); + va_end(ap); +} + +/* + * Implements the three following read routines. Allocate elements + * with zero size, and optionally set results. + */ + +int pipeReadArgsMulti (FILE *pipe, int res, int n, va_list ap) +{ + int i, j; + int m, s, t, r; + void *p; + void **q; + int ok; + + r = 0; + fread (&m, sizeof(m), 1, pipe); + ok = (m == n); + for (i = 0; i < m; i++) { + fread (&t, sizeof(t), 1, pipe); + s = va_arg(ap, int); + p = va_arg(ap, void *); + if (ok) { + if (s != 0 && t != 0 && s != t) ok = 0; + } + if (ok) { + r++; + } else { + p = NULL; + } + if (t == 0) p = NULL; + if (s == 0 && p) { /* alloc zero size */ + q = (void **) p; + p = malloc (t); + *q = p; + } + if (res) { /* store result pointer */ + q = va_arg(ap, void **); + if (q) *q = p; + } + if (p) { + fread (p, t, 1, pipe); + } else { + for (j = 0; j < t; j++) fgetc (pipe); + } + } + return r; +} + +/* + * Read arguments from a pipe. Ellipsis parameters are: + * size_1, pointer_1, size_2, pointer_2, ..., size_n, pointer_n + * Ignore null pointer arguments, and allocate arguments with zero size. + * Return number of initial arguments that matched input stream. + */ + +int pipeReadArgs (FILE *pipe, int n, ...) +{ + va_list ap; + int r; + + DPRINTF ("pipe read args\n"); + va_start(ap, n); + r = pipeReadArgsMulti (pipe, 0, n, ap); + va_end(ap); + return r; +} + +/* + * Read optional arguments from a pipe. Ellipsis parameters are: + * size_1, pointer_1, result_1, ..., size_n, pointer_n, result_n + * Ignore zero size or null pointer arguments. Return number of + * initial arguments that matched input stream, and set each result + * either to NULL or to pointer. + */ + +int pipeReadArgsOpt (FILE *pipe, int n, ...) +{ + va_list ap; + int r; + + DPRINTF ("pipe read args opt\n"); + va_start(ap, n); + r = pipeReadArgsMulti (pipe, 1, n, ap); + va_end(ap); + return r; +} + +/* + * Read list from a pipe, alloc elements, and return pointer to first + * element. The elements MUST contain the next field as first entry, + * and a string as second entry. + */ + +void* pipeReadList (FILE *pipe, int size) +{ + void *root, *p, *q; + int i, j, n, t; + char *s; + + DPRINTF ("pipe read list\n"); + root = p = NULL; + fread (&n, sizeof(n), 1, pipe); + n /= 2; + for (i = 0; i < n; i++) { + fread (&t, sizeof(t), 1, pipe); + if (t == size) { + q = malloc (t); + fread (q, t, 1, pipe); + if (p) { + * (void **) p = q; + } else { + root = q; + } + p = q; + } else { + q = NULL; + for (j = 0; j < t; j++) fgetc (pipe); + } + fread (&t, sizeof(t), 1, pipe); + if (q) { + s = NULL; + if (t != 0) { + s = malloc (t); + fread (s, sizeof(char), t, pipe); + } + * (((char **) q) + 1) = s; + } else { + for (j = 0; j < t; j++) fgetc (pipe); + } + } + return root; +} + +/* + * Write list to a pipe. The elements MUST contain the next field as + * first entry, and a string as second entry. + */ + +void pipeWriteList (FILE *pipe, int size, void *list) +{ + void *l; + char *s; + int n, k; + + DPRINTF ("pipe write list\n"); + n = 0; + for (l = list; l; l = * (void **) l) n++; + n *= 2; + fwrite (&n, sizeof(n), 1, pipe); + for (l = list; l; l = * (void **) l) { + fwrite (&size, sizeof(size), 1, pipe); + fwrite (l, size, 1, pipe); + s = * (((char **) l) + 1); + if (s) { + k = strlen(s) + 1; + fwrite (&k, sizeof(k), 1, pipe); + fwrite (s, sizeof(char), k, pipe); + } else { + k = 0; + fwrite (&k, sizeof(k), 1, pipe); + } + } + fflush (pipe); +} + diff --git a/src/xine-engine/nvtvd.h b/src/xine-engine/nvtvd.h new file mode 100644 index 000000000..11ef2284d --- /dev/null +++ b/src/xine-engine/nvtvd.h @@ -0,0 +1,1249 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a unix video player. + * + * xine 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. + * + * xine 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.h,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * nvtvd - Routines for communication with nvtvd. + * + * This is the combination of several files from the nvtvd package + * by Dirk Thierbach <dthierbach@gmx.de>. They have been inserted into + * one single file in order not to clutter the source filespace too much. + * The only change has been the removal of some '#include' statements. + * + * This file contains (in this order): + * Xdefs.h miscstruct.h xfree.h nv_tvchip.h backend.h back_client.h + */ + + +/* $XFree86: xc/include/Xdefs.h,v 1.2 1999/08/22 06:21:20 dawes Exp $ */ + +/*********************************************************** + +Copyright (c) 1999 The XFree86 Project Inc. + +All Rights Reserved. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The XFree86 Project +Inc. shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from The XFree86 Project Inc.. + +*/ + +/** + ** Types definitions shared between server and clients + **/ + +#ifndef _XDEFS_H +#define _XDEFS_H + +#ifdef _XSERVER64 +#include <Xmd.h> +#endif + +#ifndef _XTYPEDEF_ATOM +# define _XTYPEDEF_ATOM +# ifndef _XSERVER64 +typedef unsigned long Atom; +# else +typedef CARD32 Atom; +# endif +#endif + +#ifndef Bool +# ifndef _XTYPEDEF_BOOL +# define _XTYPEDEF_BOOL +typedef int Bool; +# endif +#endif + +#ifndef _XTYPEDEF_POINTER +# define _XTYPEDEF_POINTER +typedef void *pointer; +#endif + +#ifndef _XTYPEDEF_CLIENTPTR +typedef struct _Client *ClientPtr; +# define _XTYPEDEF_CLIENTPTR +#endif + +#ifndef _XTYPEDEF_XID +# define _XTYPEDEF_XID +# ifndef _XSERVER64 +typedef unsigned long XID; +# else +typedef CARD32 XID; +# endif +#endif + +#ifndef _XTYPEDEF_MASK +# define _XTYPEDEF_MASK +# ifndef _XSERVER64 +typedef unsigned long Mask; +# else +typedef CARD32 Mask; +# endif +#endif + +#ifndef _XTYPEDEF_FONTPTR +# define _XTYPEDEF_FONTPTR +typedef struct _Font *FontPtr; /* also in fonts/include/font.h */ +#endif + +#ifndef _XTYPEDEF_FONT +# define _XTYPEDEF_FONT +typedef XID Font; +#endif + +#ifndef _XTYPEDEF_FSID +# ifndef _XSERVER64 +typedef unsigned long FSID; +# else +typedef CARD32 FSID; +# endif +#endif + +typedef FSID AccContext; + +/* OS independant time value + XXX Should probably go in Xos.h */ +typedef struct timeval **OSTimePtr; + + +typedef void (* BlockHandlerProcPtr)(pointer /* blockData */, + OSTimePtr /* pTimeout */, + pointer /* pReadmask */); + +#endif +/* Excerpt from: miscstruct.h and misc.h */ + +/* $TOG: miscstruct.h /main/11 1998/02/09 14:29:04 kaleb $ */ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +All Rights Reserved. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +/* $XFree86: xc/programs/Xserver/include/miscstruct.h,v 3.0 1996/02/18 03:45:10 dawes Exp $ */ + +#ifndef MISCSTRUCT_H +#define MISCSTRUCT_H 1 + +/**** misc.h */ + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +/**** miscstruct.h */ + +typedef struct _Box { + short x1, y1, x2, y2; +} BoxRec; + +typedef union _DevUnion { + pointer ptr; + long val; + unsigned long uval; + pointer (*fptr)(void); +} DevUnion; + +#endif /* MISCSTRUCT_H */ + +/* NVTV xfree -- Dirk Thierbach <dthierbach@gmx.de> + * + * Header: All definitions from xfree that are needed. + * + */ + +#ifndef _XFREE_H +#define _XFREE_H 1 + +#include <stdio.h> +#include <stdlib.h> + +#include <X11/Xmd.h> + +#define DEBUG(x) /*x*/ +#define ErrorF(x...) fprintf(stderr,x) + +#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) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) +#define MMIO_IN16(base, offset) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) +#define MMIO_IN32(base, offset) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +#define MMIO_OUT8(base, offset, val) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val) +#define MMIO_OUT16(base, offset, val) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +#define MMIO_OUT32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +#define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val) +#define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val) +#define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val) + +/* -------- vgahw/vgaHW.h -------- */ + +/* Standard VGA registers */ +#define VGA_ATTR_INDEX 0x3C0 +#define VGA_ATTR_DATA_W 0x3C0 +#define VGA_ATTR_DATA_R 0x3C1 +#define VGA_IN_STAT_0 0x3C2 /* read */ +#define VGA_MISC_OUT_W 0x3C2 /* write */ +#define VGA_ENABLE 0x3C3 +#define VGA_SEQ_INDEX 0x3C4 +#define VGA_SEQ_DATA 0x3C5 +#define VGA_DAC_MASK 0x3C6 +#define VGA_DAC_READ_ADDR 0x3C7 +#define VGA_DAC_WRITE_ADDR 0x3C8 +#define VGA_DAC_DATA 0x3C9 +#define VGA_FEATURE_R 0x3CA /* read */ +#define VGA_MISC_OUT_R 0x3CC /* read */ +#define VGA_GRAPH_INDEX 0x3CE +#define VGA_GRAPH_DATA 0x3CF + +#define VGA_IOBASE_MONO 0x3B0 +#define VGA_IOBASE_COLOR 0x3D0 + +#define VGA_CRTC_INDEX_OFFSET 0x04 +#define VGA_CRTC_DATA_OFFSET 0x05 +#define VGA_IN_STAT_1_OFFSET 0x0A /* read */ +#define VGA_FEATURE_W_OFFSET 0x0A /* write */ + + +/**** common/xf86str.h */ + +/* Video mode flags */ + +typedef enum { + V_PHSYNC = 0x0001, + V_NHSYNC = 0x0002, + V_PVSYNC = 0x0004, + V_NVSYNC = 0x0008, + V_INTERLACE = 0x0010, + V_DBLSCAN = 0x0020, + V_CSYNC = 0x0040, + V_PCSYNC = 0x0080, + V_NCSYNC = 0x0100, + V_HSKEW = 0x0200, /* hskew provided */ + V_BCAST = 0x0400, + V_PIXMUX = 0x1000, + V_DBLCLK = 0x2000, + V_CLKDIV2 = 0x4000 +} ModeFlags; + +typedef enum { + INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */ +} CrtcAdjustFlags; + +/* Flags passed to ChipValidMode() */ +typedef enum { + MODECHECK_INITIAL = 0, + MODECHECK_FINAL = 1 +} ModeCheckFlags; + +/* These are possible return values for xf86CheckMode() and ValidMode() */ +typedef enum { + MODE_OK = 0, /* Mode OK */ + MODE_HSYNC, /* hsync out of range */ + MODE_VSYNC, /* vsync out of range */ + MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_BAD_WIDTH, /* requires an unsupported linepitch */ + MODE_NOMODE, /* no mode with a maching name */ + MODE_NO_INTERLACE, /* interlaced mode not supported */ + MODE_NO_DBLESCAN, /* doublescan mode not supported */ + MODE_NO_VSCAN, /* multiscan mode not supported */ + MODE_MEM, /* insufficient video memory */ + MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ + MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ + MODE_MEM_VIRT, /* insufficient video memory given virtual size */ + MODE_NOCLOCK, /* no fixed clock available */ + MODE_CLOCK_HIGH, /* clock required is too high */ + MODE_CLOCK_LOW, /* clock required is too low */ + MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ + MODE_BAD_HVALUE, /* horizontal timing was out of range */ + MODE_BAD_VVALUE, /* vertical timing was out of range */ + MODE_BAD_VSCAN, /* VScan value out of range */ + MODE_HSYNC_NARROW, /* horizontal sync too narrow */ + MODE_HSYNC_WIDE, /* horizontal sync too wide */ + MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ + MODE_HBLANK_WIDE, /* horizontal blanking too wide */ + MODE_VSYNC_NARROW, /* vertical sync too narrow */ + MODE_VSYNC_WIDE, /* vertical sync too wide */ + MODE_VBLANK_NARROW, /* vertical blanking too narrow */ + MODE_VBLANK_WIDE, /* vertical blanking too wide */ + MODE_PANEL, /* exceeds panel dimensions */ + MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ + MODE_ONE_WIDTH, /* only one width is supported */ + MODE_ONE_HEIGHT, /* only one height is supported */ + MODE_ONE_SIZE, /* only one resolution is supported */ + MODE_BAD = -2, /* unspecified reason */ + MODE_ERROR = -1 /* error condition */ +} ModeStatus; + +# define M_T_BUILTIN 0x01 /* built-in mode */ +# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */ +# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */ +# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C) + /* built-in mode - configure CRTC and clock */ +# define M_T_DEFAULT 0x10 /* (VESA) default modes */ + +/* Video mode */ +typedef struct _DisplayModeRec { + struct _DisplayModeRec * prev; + struct _DisplayModeRec * next; + char * name; /* identifier for the mode */ + ModeStatus status; + int type; + + /* These are the values that the user sees/provides */ + int Clock; /* pixel clock freq */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int HSkew; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int VScan; + int Flags; + + /* These are the values the hardware uses */ + int ClockIndex; + int SynthClock; /* Actual clock freq to + * be programmed */ + int CrtcHDisplay; + int CrtcHBlankStart; + int CrtcHSyncStart; + int CrtcHSyncEnd; + int CrtcHBlankEnd; + int CrtcHTotal; + int CrtcHSkew; + int CrtcVDisplay; + int CrtcVBlankStart; + int CrtcVSyncStart; + int CrtcVSyncEnd; + int CrtcVBlankEnd; + int CrtcVTotal; + Bool CrtcHAdjusted; + Bool CrtcVAdjusted; + int PrivSize; + INT32 * Private; + int PrivFlags; + + float HSync, VRefresh; +} DisplayModeRec, *DisplayModePtr; + +/* + * memType is of the size of the addressable memory (machine size) + * usually unsigned long. + */ +typedef pointer (*funcPointer)(void); + +typedef struct _ScrnInfoRec { + int scrnIndex; /* Number of this screen */ +/* ... */ + DisplayModePtr currentMode; /* current mode */ +/* ... */ + pointer driverPrivate; /* Driver private area */ + DevUnion * privates; /* Other privates can hook in + * here */ +} ScrnInfoRec; + +typedef struct _ScrnInfoRec *ScrnInfoPtr; + +/**** common/xf86.h */ + +extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ + +#define xf86Msg(type,format,args...) /* fprintf(stderr,format,args) */ +#define xf86DrvMsg(scrnIndex,type,format, args...) /* fprintf(stderr,format,args) */ + +/* ---------------- nv driver files ---------------- */ + +/**** nv_local.h */ + +/* + * Typedefs to force certain sized values. + */ +typedef unsigned char U008; +typedef unsigned short U016; +typedef unsigned int U032; + +/* these assume memory-mapped I/O, and not normal I/O space */ +#define NV_WR08(p,i,d) MMIO_OUT8((volatile pointer)(p), (i), (d)) +#define NV_RD08(p,i) MMIO_IN8((volatile pointer)(p), (i)) +#define NV_WR16(p,i,d) MMIO_OUT16((volatile pointer)(p), (i), (d)) +#define NV_RD16(p,i) MMIO_IN16((volatile pointer)(p), (i)) +#define NV_WR32(p,i,d) MMIO_OUT32((volatile pointer)(p), (i), (d)) +#define NV_RD32(p,i) MMIO_IN32((volatile pointer)(p), (i)) + +#define VGA_WR08(p,i,d) NV_WR08(p,i,d) +#define VGA_RD08(p,i) NV_RD08(p,i) + +/**** nv_dac.c */ + +#define DDC_SDA_READ_MASK (1 << 3) +#define DDC_SCL_READ_MASK (1 << 2) +#define DDC_SDA_WRITE_MASK (1 << 4) +#define DDC_SCL_WRITE_MASK (1 << 5) + +/**** riva_hw.h */ + +typedef struct _riva_hw_inst +{ + U032 Architecture; + U032 Version; + U032 CrystalFreqKHz; + U032 RamAmountKBytes; + U032 MaxVClockFreqKHz; + U032 RamBandwidthKBytesPerSec; + U032 EnableIRQ; + U032 IO; +#if 1 /* from a different riva_hw ??? */ + U032 VBlankBit; + U032 FifoFreeCount; + U032 FifoEmptyCount; +#endif + /* + * Non-FIFO registers. + */ + volatile U032 *PCRTC; + volatile U032 *PRAMDAC; + volatile U032 *PFB; + volatile U032 *PFIFO; + volatile U032 *PGRAPH; + volatile U032 *PEXTDEV; + volatile U032 *PTIMER; + volatile U032 *PMC; + volatile U032 *PRAMIN; + volatile U032 *FIFO; + volatile U032 *CURSOR; + volatile U032 *CURSORPOS; + volatile U032 *VBLANKENABLE; + volatile U032 *VBLANK; + volatile U008 *PCIO; + volatile U008 *PVIO; + volatile U008 *PDIO; +#if 1 + volatile U032 *PVIDEO; /* extra */ +#endif + /* Remaining entries cut */ +#if 0 + /* + * Common chip functions. + */ + int (*Busy)(struct _riva_hw_inst *); + void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int,int,int,int,int,int,int,int,int); + void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *); + void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *); + void (*SetStartAddress)(struct _riva_hw_inst *,U032); + void (*SetSurfaces2D)(struct _riva_hw_inst *,U032,U032); + void (*SetSurfaces3D)(struct _riva_hw_inst *,U032,U032); + int (*ShowHideCursor)(struct _riva_hw_inst *,int); + void (*LockUnlock)(struct _riva_hw_inst *, int); + /* + * Current extended mode settings. + */ + struct _riva_hw_state *CurrentState; + /* + * FIFO registers. + */ + RivaRop *Rop; + RivaPattern *Patt; + RivaClip *Clip; + RivaPixmap *Pixmap; + RivaScreenBlt *Blt; + RivaBitmap *Bitmap; + RivaLine *Line; + RivaTexturedTriangle03 *Tri03; + RivaTexturedTriangle05 *Tri05; +#endif +} RIVA_HW_INST; + +#endif +/* NVTV tv_chip header -- Dirk Thierbach <dthierbach@gmx.de> + * + * This file is part of nvtv, a tool for tv-output on NVidia cards. + * + * nvtv 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. + * + * nvtv 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.h,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * Contents: + * + * Header: Structures and defines for the Brooktree, the Chrontel and the + * Philips chip. This part could eventually become a part of the XFree + * NV-Driver. + * + */ + +#ifndef _TV_CHIP_H +#define _TV_CHIP_H + +typedef enum { + TYPE_NONE = 0, + TYPE_INT = 1, + TYPE_ULONG = 2, +} VarType; + +typedef enum { + CARD_NONE = 0, + CARD_NVIDIA = 1, + CARD_TDFX = 2, + CARD_I810 = 3, +} CardType; + +typedef enum { + TV_SYSTEM_NONE = -1, + TV_SYSTEM_NTSC = 0, + TV_SYSTEM_NTSC_J = 1, /* same as NTSC_60 */ + TV_SYSTEM_PAL = 2, + TV_SYSTEM_PAL_60 = 3, + TV_SYSTEM_PAL_N = 4, + TV_SYSTEM_PAL_NC = 5, + TV_SYSTEM_PAL_M = 6, + TV_SYSTEM_PAL_M60 = 7, + TV_SYSTEM_PAL_X = 8, /* Fake PAL System to correct color carriers, + useful at least in Sweden PAL-B */ + TV_SYSTEM_SECAM = 9, /* only on Conexant chips */ +} TVSystem; + +typedef enum { + TV_NO_CHIP = 0, + TV_CHRONTEL = 1, + TV_BROOKTREE = 2, + TV_CONEXANT = 3, + TV_PHILIPS = 4, +} TVChip; + +/* -------- Host interface flags, all chips -------- */ + +#define HOST_SYNC_DIR (1 << 0) +#define HOST_SYNC_IN 0 +#define HOST_SYNC_OUT (1 << 0) + +#define HOST_VSYNC_ACTIVE (1 << 1) +#define HOST_VSYNC_LOW 0 +#define HOST_VSYNC_HIGH (1 << 1) + +#define HOST_HSYNC_ACTIVE (1 << 2) +#define HOST_HSYNC_LOW 0 +#define HOST_HSYNC_HIGH (1 << 2) + +#define HOST_BLANK_ACTIVE (1 << 3) +#define HOST_BLANK_LOW 0 +#define HOST_BLANK_HIGH (1 << 3) + +#define HOST_BLANK_DIR (1 << 4) +#define HOST_BLANK_IN 0 +#define HOST_BLANK_OUT (1 << 4) + +#define HOST_BLANK_MODE (1 << 5) +#define HOST_BLANK_AREA 0 +#define HOST_BLANK_DOT (1 << 5) + +#define HOST_MODE_MASK (1 << 6) +#define HOST_MODE_MASTER 0 +#define HOST_MODE_SLAVE (1 << 6) + +#define HOST_PCLK_ACTIVE (1 << 7) +#define HOST_PCLK_LOW 0 +#define HOST_PCLK_HIGH (1 << 7) + +#define HOST_PCLK_VDD (1 << 8) +#define HOST_VDD_LOW 0 +#define HOST_VDD_HIGH (1 << 8) + +#define HOST_NVIDIA (HOST_VSYNC_HIGH | HOST_HSYNC_HIGH | \ + HOST_SYNC_OUT | HOST_PCLK_HIGH | \ + HOST_BLANK_LOW | HOST_BLANK_OUT | \ + HOST_BLANK_AREA | HOST_MODE_MASTER) + +#define HOST_TDFX (HOST_VSYNC_HIGH | HOST_HSYNC_HIGH | \ + HOST_BLANK_LOW | HOST_BLANK_IN | \ + HOST_BLANK_DOT | HOST_MODE_MASTER) + +#define HOST_I810 (HOST_VSYNC_LOW | HOST_HSYNC_LOW | \ + HOST_SYNC_IN | HOST_PCLK_LOW | \ + HOST_BLANK_LOW | HOST_BLANK_IN | \ + HOST_BLANK_AREA | HOST_MODE_MASTER) + +/* -------- Brooktree -------- */ + +#define BT_FLAG1_NI_OUT (1 << 0) +#define BT_FLAG1_SETUP (1 << 1) +#define BT_FLAG1_625LINE (1 << 2) +#define BT_FLAG1_VSYNC_DUR (1 << 3) +#define BT_FLAG1_DIS_SCRESET (1 << 4) +#define BT_FLAG1_PAL_MD (1 << 5) +#define BT_FLAG1_ECLIP (1 << 6) +#define BT_FLAG1_EN_ASYNC (1 << 8) + +#define BT_FLAG1_NTSC (BT_FLAG1_VSYNC_DUR | BT_FLAG1_SETUP) +#define BT_FLAG1_NTSC_JAPAN (BT_FLAG1_VSYNC_DUR) +#define BT_FLAG1_PAL_BDGHI (BT_FLAG1_PAL_MD | BT_FLAG1_625LINE) +#define BT_FLAG1_PAL_N (BT_FLAG1_VSYNC_DUR | BT_FLAG1_SETUP | \ + BT_FLAG1_PAL_MD | BT_FLAG1_625LINE) +#define BT_FLAG1_PAL_M (BT_FLAG1_VSYNC_DUR | BT_FLAG1_SETUP | \ + BT_FLAG1_PAL_MD) +#define BT_FLAG1_PAL_BDGHI (BT_FLAG1_PAL_MD | BT_FLAG1_625LINE) +#define BT_FLAG1_PAL_60 (BT_FLAG1_PAL_MD | BT_FLAG1_VSYNC_DUR) + +#define BT_FLAG2_DIS_FFILT (1 << 0) +#define BT_FLAG2_DIS_YFLPF (1 << 1) +#define BT_FLAG2_DIS_GMSHY (1 << 2) +#define BT_FLAG2_DIS_GMUSHY (1 << 3) +#define BT_FLAG2_DIS_GMSHC (1 << 4) +#define BT_FLAG2_DIS_GMUSHC (1 << 5) +#define BT_FLAG2_DIS_CHROMA (1 << 6) + +#define BT_FLAG2_DIS_GM (BT_FLAG2_DIS_GMSHY | BT_FLAG2_DIS_GMUSHY \ + | BT_FLAG2_DIS_GMSHC | BT_FLAG2_DIS_GMUSHC) + +#define BT_FLAG3_DACDISA (1 << 0) +#define BT_FLAG3_DACDISB (1 << 1) +#define BT_FLAG3_DACDISC (1 << 2) +#define BT_FLAG3_DACDISD (1 << 3) +#define BT_FLAG3_DAC (BT_FLAG3_DACDISA | BT_FLAG3_DACDISB \ + | BT_FLAG3_DACDISC | BT_FLAG3_DACDISD) + +#define BT_FLAG3_FBAS (BT_FLAG3_DACDISB | BT_FLAG3_DACDISC) +#define BT_FLAG3_SVHS (BT_FLAG3_DACDISA) +#define BT_FLAG3_CONVERT (BT_FLAG3_DACDISA) +#define BT_FLAG3_BOTH 0 + +/* DACDISD is available only for the Conexant chip, and is reserved for + the Brooktree chip. It is reset by default */ + +/* FIXME URGENT: Conexant doc says no more than 1 DAC should be disabled */ + +typedef struct { + int hsynoffset; /* time */ + int vsynoffset; /* time */ + int hsynwidth; /* time */ /* don't confuse with hsync_width ! */ + int vsynwidth; /* time */ + int h_clko; /* time */ + int h_active; /* time */ + int hsync_width; /* time(system) */ + int hburst_begin; /* time(system) */ + int hburst_end; /* time(system) */ + int h_blanko; /* time */ + int v_blanko; /* time */ + int v_activeo; /* time */ + int h_fract; /* time */ + int h_clki; /* time */ + int h_blanki; /* time */ + int v_linesi; /* time */ + int v_blanki; /* time */ + int v_activei; /* time */ + int v_scale; /* time */ + int pll_fract; /* time */ + int pll_int; /* time */ + int sync_amp; /* level(system) */ + int bst_amp; /* level(system) */ + int mcr; /* level(system) */ + int mcb; /* level(system) */ + int my; /* level(system) */ + unsigned long msc; /* time */ + int flags1; /* time */ + int flags2; /* func */ + int flags3; /* func */ + int f_selc; /* func */ + int f_sely; /* func */ + int ycoring; /* func */ + int ccoring; /* func */ + int yattenuate; /* func */ + int cattenuate; /* func */ + int ylpf; /* func */ + int clpf; /* func */ + int out_muxa; /* func */ + int out_muxb; /* func */ + int out_muxc; /* func */ + int out_muxd; /* func */ + int phase_off; /* time(?) */ + int macro; /* time(all) */ +} TVBtRegs; + +/* -------- Conexant -------- */ + +#define CX_FLAG1_FM (1 << 7) +#define CX_FLAG1_EXT (1 << 9) /* Is extension, don't init */ + +#define CX_FLAG4_PROG_SC (1 << 0) +#define CX_FLAG4_SC_PATTERN (1 << 1) +#define CX_FLAG4_FIELD_ID (1 << 3) +#define CX_FLAG4_BY_YCCR (1 << 6) +#define CX_FLAG4_CHROMA_BW (1 << 7) + +#define CX_FLAG4_MASK (CX_FLAG4_PROG_SC | CX_FLAG4_SC_PATTERN | \ + CX_FLAG4_FIELD_ID | CX_FLAG4_BY_YCCR | \ + CX_FLAG4_CHROMA_BW) + +#define CX_FLAG5_ADPT_FF (1 << 0) +#define CX_FLAG5_FFRTN (1 << 1) +#define CX_FLAG5_YSELECT (1 << 2) +#define CX_FLAG5_DIV2 (1 << 4) +#define CX_FLAG5_PLL_32CLK (1 << 5) +#define CX_FLAG5_PIX_DOUBLE (1 << 6) +#define CX_FLAG5_EWSSF1 (1 << 8) +#define CX_FLAG5_EWSSF2 (1 << 9) + +typedef struct { + TVBtRegs bt; + unsigned long msc_db; /* time */ + int dr_limitp; /* time */ + int dr_limitn; /* time */ + int db_limitp; /* time */ + int db_limitn; /* time */ + int filfsconv; /* ?? */ + int filincr; /* ?? */ /* fil4286incr */ + int flags4; /* time & func */ + int flags5; /* time & func */ + int mcompy; /* level */ + int mcompu; /* level */ + int mcompv; /* level */ + int y_off; /* level */ + int hue_adj; /* time(?) */ + long wsdat; /* time */ + int wssinc; /* time */ + int c_altff; /* func */ + int y_altff; /* func */ + int c_thresh; /* func */ + int y_thresh; /* func */ + int pkfil_sel; /* func */ +} TVCxRegs; + +/* -------- Chrontel -------- */ + +#define CH_FLAG_DAC 1:0 +#define CH_FLAG_DAC_MASK 3 +#define CH_FLAG_FBAS 2 +#define CH_FLAG_SVHS 0 +#define CH_FLAG_BOTH 3 + +typedef struct { + int dmr_ir; /* time */ + int dmr_vs; /* time */ + int dmr_sr; /* time */ + int ffr_fc; /* func */ + int ffr_fy; /* func */ + int ffr_ft; /* func */ + int vbw_flff; /* func */ /* flag */ + int vbw_cvbw; /* func */ /* flag */ + int vbw_cbw; /* func */ + int vbw_ypeak; /* func */ /* flag */ + int vbw_ysv; /* func */ + int vbw_ycv; /* func */ /* flag */ + int dacg; /* level(system) */ /* flag */ + int aciv; /* time */ /* flag */ + int civh; /* time */ + int sav; /* time */ + int blr; /* level(system) */ + int hpr; /* func/time */ + int vpr; /* func/time */ + int ce; /* func */ + int pll_m; /* time */ + int pll_n; /* time */ + int pllcap; /* time */ /* flag */ + unsigned long fsci; +#if 0 /* Test register; no documentation */ + int ylm; /* y multiplier ? */ + int clm; /* c multiplier ? */ +#endif + int flags; /* func */ + int mode; /* for macrovision table */ + int macro; +} TVChRegs; + +/* -------- Philips -------- */ + +#define PH_FLAG1_FISE (1 << 0) +#define PH_FLAG1_PAL (1 << 1) +#define PH_FLAG1_SCBW (1 << 2) +#define PH_FLAG1_YGS (1 << 4) +#define PH_FLAG1_YFIL (1 << 8) + +#define PH_FLAG1_MASK (PH_FLAG1_FISE | PH_FLAG1_PAL | \ + PH_FLAG1_SCBW | PH_FLAG1_YGS) + +#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_NORMAL (PH_FLAG2_CEN | PH_FLAG2_CVBSEN0 | \ + PH_FLAG2_VBSEN) +#define PH_FLAG2_CONVERT (PH_FLAG2_CEN | PH_FLAG2_CVBSEN0 | \ + PH_FLAG2_CVBSEN1) +#define PH_FLAG2_FBAS PH_FLAG2_NORMAL +#define PH_FLAG2_SVHS PH_FLAG2_NORMAL +#define PH_FLAG2_BOTH PH_FLAG2_NORMAL + +typedef struct { + int adwhs; /* time */ + int adwhe; /* time */ + int xofs; /* time */ + int xpix; /* time */ + int xinc; /* time */ + int hlen; /* time */ + int fal; /* time */ + int lal; /* time */ + int yinc; /* time */ + int yskip; /* time */ + int yofso; /* time */ + int yofse; /* time */ + int ypix; /* time */ + int yiwgto; /* time */ + int yiwgte; /* time */ + long pcl; /* time */ + long fsc; /* time */ + int idel; /* init */ + int bs; /* time(system) */ + int be; /* time(system) */ + int bsta; /* level(system) */ + int blckl; /* level(system) */ + int blnnl; /* level(system) */ + int chps; /* time(phase) */ + int gy; /* level */ + int gcd; /* level */ + int bcy; /* func */ + int bcu; /* func */ + int bcv; /* func */ + int ccrs; /* func */ + int gainu; /* func */ + int gainv; /* func */ + int flc; /* time */ + int phres; /* func(phase) */ + int flags1; + int flags2; + int macro; +} TVPhRegs; + +/* -------- CRT -------- */ + +#ifndef V_INTERLACE +#define V_INTERLACE 0x0010 +#endif + +#ifndef V_DBLSCAN +#define V_DBLSCAN 0x0020 +#endif + +#ifndef V_HSKEW +#define V_HSKEW 0x0200 +#endif + +/* Flags that describe the mode (in TVCrtRegs.PrivFlags) */ + +#define TV_MODE_TVMODE (1 << 0) /* Is TV Mode */ +#define TV_MODE_DUALVIEW (1 << 2) /* Default dualview */ +#define TV_MODE_MACROVISION (1 << 3) /* Default macrovision */ +#define TV_MODE_NONINTERLACED (1 << 4) /* Default noninterlace */ +#define TV_MODE_MONOCHROME (1 << 5) /* Default monochrome */ +#define TV_MODE_CARRIER_LOCK (1 << 6) /* Default carrier lock */ + +#define TV_CAN_DUALVIEW (1 << 10) /* Has dualview */ +#define TV_CAN_MACROVISION (1 << 11) /* Has macrovision choice */ +#define TV_CAN_NONINTERLACED (1 << 12) /* Has noninterlace */ +#define TV_CAN_MONOCHROME (1 << 13) /* Has monochrome */ +#define TV_CAN_CARRIER_LOCK (1 << 14) /* Default carrier lock */ + +#define TV_CAN_BIT 8 /* Bit shift for HAS -> MODE */ + +#define TV_CAN_MASK (TV_CAN_DUALVIEW | TV_CAN_MACROVISION | \ + TV_CAN_MONOCHROME | TV_CAN_NONINTERLACED) + +#define TV_DEF_DUALVIEW (TV_CAN_DUALVIEW | TV_MODE_DUALVIEW) + +/* Flags that affect the mode (in DisplayModeRec.PrivFlags) */ + +#define TV_PRIV_TVMODE (1 << 0) /* TV or monitor mode? */ +#define TV_PRIV_BYPASS (1 << 1) /* Bypass settings */ +#define TV_PRIV_DUALVIEW (1 << 2) /* Set single/dualview */ + +/* We use our own crt structure in the frontend and database, and convert + * to DisplayModeRec, XF86VidModeModeLine, or XF86VidModeModeInfo as + * required. The direct backend uses DisplayModeRec. The 'private' + * structure is the same in all cases, and defined in nv_type.h. + * FIXME: Change this. + */ + +typedef struct { + long Clock; /* Pixel clock in kHz, 0 = ignore */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int Flags; + int PrivFlags; +} TVCrtRegs; + +/* -------- TV Regs Diff -------- */ + +typedef struct { + int ofs; + VarType type; + unsigned long ulval; + int ival; +} TVDiff; + +#define TV_FIELD_LONG(r,f,v) ofs:(char *)(&r.f) - (char *)(&r), \ + type:TYPE_ULONG, ulval:(v) +#define TV_FIELD_INT(r,f,v) ofs:(char *)(&r.f) - (char *)(&r), \ + type:TYPE_INT, ival:(v) +#define TV_FIELD_END ofs:-1, type:TYPE_NONE + +/* -------- Common -------- */ + +typedef union { + TVBtRegs bt; + TVCxRegs cx; + TVChRegs ch; + TVPhRegs ph; +} TVRegs; + +typedef enum { + TV_UNKNOWN = 0, + TV_OFF = 1, + TV_BARS = 2, + TV_ON = 3 +} TVState; + +typedef enum { + CONNECT_AUTO = -2, + CONNECT_NONE = -1, + CONNECT_FBAS = 0, + CONNECT_SVHS = 1, + CONNECT_BOTH = 2, + CONNECT_CONVERT = 3, /* FBAS on both S-VHS lines, for converter */ +} TVConnect; + +typedef struct { + int tv_hoffset, tv_voffset; + int mon_hoffset, mon_voffset; + int brightness_sig; /* -50 - 50 % */ + int contrast; /* -100 - 100 % */ + int contrast_sig; /* -50 - 50 % */ + int saturation; /* -100 - 100 % */ + int saturation_sig; /* -50 - 50 % */ + int phase; /* -90 - 90 deg */ + int hue; /* -90 - 90 deg */ + int flicker; /* 0 - 100 % */ + int flicker_adapt; /* 0 - 100 % */ + int luma_bandwidth; /* 0 - 100 % */ + int chroma_bandwidth; /* 0 - 100 % */ + int sharpness; /* 0 - 100 % */ + int cross_color; /* 0 - 100 % */ + int flags; + TVConnect connector; +} TVSettings; + +/* FIXME: defines for TVSettings flags */ + +/* FIXME: Get rid of NVPrivate */ + +typedef struct { + char magic[4]; + TVChip chip; + TVRegs tv; +} NVPrivate; + +typedef struct { + TVSystem system; + int res_x; + int res_y; + char *size; + char *aspect; + double hoc; + double voc; + TVCrtRegs *crt; + TVRegs *tv; + TVDiff *diff; +} TVMode; + +#endif /* _TV_CHIP */ +/* NVTV backend -- Dirk Thierbach <dthierbach@gmx.de> + * + * This file is part of nvtv, a tool for tv-output on NVidia cards. + * + * nvtv 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. + * + * nvtv 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.h,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * Contents: + * + * Common header for all backends + */ + +#ifndef _BACKEND_H +#define _BACKEND_H + +#ifdef DEBUG_PROBE +#include "tv_common.h" +#endif + +/* 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, + the pipe routines will crash. Other pointers besides those two are + transfered through the pipe, but should be ignored, as there value is + invalid. */ + +/* List of chips accessible on one card. Most of the time, there will + be only one tv chip, though in theory one could use two on dual-head + cards. Other chips can be stored here as well. We duplicate the + information in I2Chain and I2CDev to make the frontend independent + of the back end. +*/ + +typedef struct chip_info { + struct chip_info *next; /* must be 1st entry! */ + char *name; /* must be 2nd entry! (name including version and I2C addr) */ + TVChip chip; /* chip type */ + void *private; /* identify device, backend private */ +} ChipInfo, *ChipPtr; + +/* List of all NVidia cards available */ + +typedef struct card_info { + struct card_info *next; /* must be 1st entry! */ + char *name; /* must be 2nd entry! (name including bus addr) */ + char *dev; /* name of device for mmap */ + char *arch; /* architecture */ + CardType type; + unsigned long reg_base; + int pci_id; + ChipPtr chips; +} CardInfo, *CardPtr; + +#define BACK_SERVICE_CURSOR (1 << 0) +#define BACK_SERVICE_VIDEO (1 << 1) +#define BACK_SERVICE_VIEW_CURSOR (1 << 2) +#define BACK_SERVICE_VIEW_MAIN (1 << 3) + +typedef struct { + void (*openCard) (CardPtr card); + void (*closeCard) (void); +#ifdef DEBUG_PROBE + void (*probeSystem) (CardPtr card_list); +#endif +} BackAccessRec, *BackAccessPtr; + +typedef struct { + void (*openCard) (CardPtr card); + void (*closeCard) (void); + void (*probeChips) (void); +#ifdef DEBUG_PROBE + void (*probeCard) (void); + I2CChainPtr (*probeBus) (void); +#endif + void (*setHeads) (int main, int tv, int video); + void (*getHeads) (int *main, int *tv, int *video, int *max); + void (*setChip) (ChipPtr chip, Bool init); + void (*setSettings) (TVSettings *set); + void (*getSettings) (TVSettings *set); + void (*setMode) (int ModeFlags, TVCrtRegs *crt, TVRegs *tv); + void (*getMode) (TVCrtRegs *crt, TVRegs *tv); + void (*setModeSettings) (int ModeFlags, TVCrtRegs *crt, TVRegs *tv, + TVSettings *set); + void (*setTestImage) (int ModeFlags, TVRegs *tv, TVSettings *set); + long (*getStatus) (int index); + TVConnect (*getConnection) (void); + Bool (*findBySize) (TVSystem system, int xres, int yres, char *size, + TVMode *mode, TVCrtRegs *crt, TVRegs *tv); + Bool (*findByOverscan) (TVSystem system, int xres, int yres, + double hoc, double voc, TVMode *mode, TVCrtRegs *crt, TVRegs *tv); + void (*initSharedView) (int *view_x, int *view_y); + Bool (*getTwinView) (int *view_x, int *view_y); + Bool (*adjustViewport) (int flags, int *view_x, int *view_y); + Bool (*serviceViewportCursor) (int flags, int cursor_x, int cursor_y, + int *view_x, int *view_y); +} BackCardRec, *BackCardPtr; + +/* The backend(s) use static information, so there can only be one + backend active: */ + +extern BackAccessPtr back_access; +extern BackCardPtr back_card; + +#endif /* _BACKEND_H */ +/* NVTV client backend header -- Dirk Thierbach <dthierbach@gmx.de> + * + * This file is part of nvtv, a tool for tv-output on NVidia cards. + * + * nvtv 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. + * + * nvtv 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: nvtvd.h,v 1.1 2002/06/10 21:42:45 mshopf Exp $ + * + * Contents: + * + * Header for client backend + */ + +#ifndef _BACK_CLIENT_H +#define _BACK_CLIENT_H + +Bool back_client_avail (void); +CardPtr back_client_init (void); + +/* client backend methods */ + +void bcl_openCard (CardPtr card); +void bcl_closeCard (void); +#ifdef DEBUG_PROBE +void bcl_probeCards (CardPtr card_list); +#endif +void bcl_setHeads (int main, int tv, int video); +void bcl_getHeads (int *main, int *tv, int *video, int *max); +void bcl_probeChips (void); +void bcl_setChip (ChipPtr chip, Bool init); +void bcl_setSettings (TVSettings *set); +void bcl_getSettings (TVSettings *set); +void bcl_setMode (int ModeFlags, TVCrtRegs *crt, TVRegs *tv); +void bcl_getMode (TVCrtRegs *crt, TVRegs *tv); +void bcl_setModeSettings (int ModeFlags, TVCrtRegs *crt, + TVRegs *tv, TVSettings *set); +void bcl_setTestImage (int ModeFlags, TVRegs *tv, TVSettings *set); +long bcl_getStatus (int index); +TVConnect bcl_getConnection (void); +Bool bcl_findBySize (TVSystem system, int xres, int yres, char *size, + TVMode *mode, TVCrtRegs *crt, TVRegs *tv); +Bool bcl_findByOverscan (TVSystem system, int xres, int yres, + double hoc, double voc, TVMode *mode, TVCrtRegs *crt, TVRegs *tv); + +void bcl_initSharedView (int *view_x, int *view_y); +Bool bcl_getTwinView (int *view_x, int *view_y); +Bool bcl_adjustViewportVideo (int flags, int *view_x, int *view_y); +Bool bcl_serviceViewportVideoCursor (int flags, int cursor_x, int cursor_y, + int *view_x, int *view_y); + +#endif /* _BACK_CLIENT_H */ + diff --git a/src/xine-engine/tvmode.c b/src/xine-engine/tvmode.c new file mode 100644 index 000000000..1f419ea4b --- /dev/null +++ b/src/xine-engine/tvmode.c @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a unix video player. + * + * xine 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. + * + * xine 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. + * + * You should have received a copy of the GNU General Public License + * 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.1 2002/06/10 21:42:45 mshopf Exp $ + * + * tvmode - TV output selection + * + * Currently uses nvtvd (Dirk Thierbach <dthierbach@gmx.de>) + * for setting TV mode + * xine support hacked in by Matthias Hopf <mat@mshopf.de> + */ + + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#include "nvtvd.h" +/* FIXME: how to include that? */ +/*#include "xine.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; + +static int current_type, current_width, current_height; +static double current_fps; +static TVCrtRegs old_crt; +static TVRegs old_tv; + + +/* TODO: config, and better */ +static TVSystem opt_system = TV_SYSTEM_PAL; +static TVConnect opt_connect = CONNECT_AUTO; + +/* 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 }, { 800, 576 }, { 720, 576 }, + { 800, 600 }, + { 720, 480 }, { 640, 480 }, + { 800, 450 }, + { 1024, 768 }, + { 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 +} ; + +/* TODO: flexible */ +static int opt_flicker = -1; +static double opt_aspect = 4.0 / 3.0; + + +/* Try to connect to nvtvd server */ +static void tvmode_connect () { + + CardInfo *card = 0; + + if (back_card) + back_card->closeCard (); + + if (back_client_avail ()) { + if (! (card = back_client_init ())) + back_card = 0; + } else { + back_card = 0; + } + + if (back_card) + back_card->openCard (card); + else + fprintf (stderr, "tvmode: cannot connect to nvtvd - no TV mode switching available\n"); +} + + +/* Disconnect from server */ +static void tvmode_disconnect () { + back_card->closeCard (); + back_card = 0; +} + + +/* Save current CRT and TV register configuration */ +static void tvmode_savestate () { + back_card->getMode (&old_crt, &old_tv); +} + + +/* Restore CRT and TV register configuration */ +static void tvmode_restorestate () { + back_card->setMode (0, &old_crt, &old_tv); + current_type = 0; +} + + +/* Set CRT and TV registers to given TV-Out configuration */ +static void tvmode_settvstate (int width, int height, double fps) { + + TVSettings settings; + TVMode mode; + 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++) { + 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)) { + current_width = scanm[0]; + current_height = scanm[1]; + current_fps = 25; /* TODO: currently this is PAL only */ + found++; + } + } + } + + /* Switch to mode */ + if (found) { + back_card->setModeSettings (TV_PRIV_TVMODE | TV_PRIV_DUALVIEW, + &crt, &tv, &settings); + current_type = 1; + } else { + fprintf (stderr, "tvmode: cannot find any valid TV mode - TV output disabled\n"); + xine_tvmode_exit (); + } +} + + +/* + * PUBLIC + */ + +/* Set to 'regular'(0) or 'tv'(1) state, that is if it is enabled */ +int xine_tvmode_switch (int type, int width, int height, double fps) { + + if (back_card) { + fprintf (stderr, "tvmode: switching to %s\n", type ? "TV" : "default"); + switch (type) { + case 0: + tvmode_restorestate (); + break; + case 1: + tvmode_settvstate (width, height, fps); + break; + default: + fprintf (stderr, "tvmode: illegal type for switching\n"); + tvmode_restorestate (); + } + } else { + fprintf (stderr, "tvmode: not connected to nvtvd for switching\n"); + } + return current_type; +} + + +/* Addapt (maximum) output size to visible area and set pixel aspect and fps */ +void xine_tvmode_size (int *width, int *height, + double *pixelratio, double *fps) { + + 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; + } +} + +/* Connect to nvtvd server if possible and fetch settings */ +void xine_tvmode_init () { + tvmode_connect (); + if (back_card) + tvmode_savestate (); +} + + +/* Restore old CRT and TV registers and close nvtvd connection */ +void xine_tvmode_exit () { + if (back_card) { + tvmode_restorestate (); + tvmode_disconnect (); + } +} + |