diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-18 15:29:19 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-18 15:29:19 +0000 |
commit | b6a7a1c325f8efe47d302290fe01e8f759b1b964 (patch) | |
tree | 257bcfca82c9138d105099afe598a174c96f4a3e /src/xine-engine/nvtv | |
parent | 9fb47c4d2259df214b179a2fffc752e9504f4e66 (diff) | |
download | xine-lib-b6a7a1c325f8efe47d302290fe01e8f759b1b964.tar.gz xine-lib-b6a7a1c325f8efe47d302290fe01e8f759b1b964.tar.bz2 |
nvtv patch by Mattias Eriksson <snaggen@acc.umu.se> with a few changes
NOTE: reported to be still in a non-working state.
use 'configure --enable-nvtv' to test. otherwise lib will be compiled with
xine_tvmode_* dummy functions just to keep compatibility.
CVS patchset: 3954
CVS date: 2003/01/18 15:29:19
Diffstat (limited to 'src/xine-engine/nvtv')
-rw-r--r-- | src/xine-engine/nvtv/Makefile.am | 37 | ||||
-rw-r--r-- | src/xine-engine/nvtv/back_client.c | 414 | ||||
-rw-r--r-- | src/xine-engine/nvtv/back_client.h | 66 | ||||
-rw-r--r-- | src/xine-engine/nvtv/backend.h | 124 | ||||
-rw-r--r-- | src/xine-engine/nvtv/debug.h | 220 | ||||
-rw-r--r-- | src/xine-engine/nvtv/libnvclient_dummy.c | 1 | ||||
-rw-r--r-- | src/xine-engine/nvtv/local.h | 57 | ||||
-rw-r--r-- | src/xine-engine/nvtv/miscstruct.h | 93 | ||||
-rw-r--r-- | src/xine-engine/nvtv/pipe.c | 251 | ||||
-rw-r--r-- | src/xine-engine/nvtv/pipe.h | 82 | ||||
-rw-r--r-- | src/xine-engine/nvtv/tv_chip.h | 639 | ||||
-rw-r--r-- | src/xine-engine/nvtv/tv_common.h | 80 | ||||
-rw-r--r-- | src/xine-engine/nvtv/xf86i2c.h | 90 | ||||
-rw-r--r-- | src/xine-engine/nvtv/xfree.h | 338 |
14 files changed, 2492 insertions, 0 deletions
diff --git a/src/xine-engine/nvtv/Makefile.am b/src/xine-engine/nvtv/Makefile.am new file mode 100644 index 000000000..d4a146ff7 --- /dev/null +++ b/src/xine-engine/nvtv/Makefile.am @@ -0,0 +1,37 @@ +## Process this file with automake to produce Makefile.in + +AM_CFLAGS = $(X_CFLAGS) + +noinst_LTLIBRARIES= libnvclient.la + +libnvclient_sources = back_client.c pipe.c + +libnvclient_dummy = libnvclient_dummy.c + +EXTRA_DIST = $(libnvclient_sources) $(libnvclient_dummy) + +if HAVE_NVTV +nvtv_modules = $(libnvclient_sources) +endif + +libnvclient_la_SOURCES = $(nvtv_modules) $(libnvclient_dummy) + + +noinst_HEADERS = backend.h local.h tv_chip.h xf86i2c.h back_client.h debug.h \ + miscstruct.h pipe.h tv_common.h xfree.h + +libnvclient_la_LIBADD = $(X_LIBS) + +debug: + @$(MAKE) CFLAGS="$(DEBUG_CFLAGS) $(X_CFLAGS)" + +install-debug: debug + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +mostlyclean-generic: + -rm -f *~ \#* .*~ .\#* + +maintainer-clean-generic: + -@echo "This command is intended for maintainers to use;" + -@echo "it deletes files that may require special tools to rebuild." + -rm -f Makefile.in diff --git a/src/xine-engine/nvtv/back_client.c b/src/xine-engine/nvtv/back_client.c new file mode 100644 index 000000000..e984a6974 --- /dev/null +++ b/src/xine-engine/nvtv/back_client.c @@ -0,0 +1,414 @@ +/* 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: back_client.c,v 1.1 2003/01/18 15:29:22 miguelfreitas Exp $ + * + * Contents: + * + * Client backend for accessing the server + * + */ + +#include <string.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> + +#include "debug.h" +#include "backend.h" +#include "back_client.h" +#include "pipe.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_getHeadDev (int head, int *devFlags) +{ + DPRINTF ("bcl_getHeadDev\n"); + pipeWriteCmd (pipe_out, PCmd_GetHeadDev); + pipeWriteArgs (pipe_out, 1, sizeof (head), &head); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 1, sizeof(int), devFlags); +} + +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 (TVRegs *regs) +{ + DPRINTF ("bcl_setMode\n"); + pipeWriteCmd (pipe_out, PCmd_SetMode); + pipeWriteArgs (pipe_out, 1, sizeof(TVRegs), regs); +} + +void bcl_getMode (TVRegs *regs) +{ + DPRINTF ("bcl_getMode\n"); + pipeWriteCmd (pipe_out, PCmd_GetMode); + pipeWriteArgs (pipe_out, 0); + pipeReadCmd (pipe_in); + pipeReadArgs (pipe_in, 1, sizeof(TVRegs), regs); +} + +void bcl_setModeSettings (TVRegs *regs, TVSettings *set) +{ + DPRINTF ("bcl_setModeSettings\n"); + pipeWriteCmd (pipe_out, PCmd_SetModeSettings); + pipeWriteArgs (pipe_out, 2, sizeof(TVRegs), regs, sizeof(TVSettings), set); +} + +void bcl_setTestImage (TVEncoderRegs *tv, TVSettings *set) +{ + DPRINTF ("bcl_setTestImage\n"); + pipeWriteCmd (pipe_out, PCmd_SetTestImage); + pipeWriteArgs (pipe_out, 2, sizeof(TVEncoderRegs), 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) +{ + 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, 1, sizeof(TVMode), mode); + return (n >= 1); +} + +Bool bcl_findByOverscan (TVSystem system, int xres, int yres, + double hoc, double voc, TVMode *mode) +{ + 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, 1, sizeof(TVMode), mode); + 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; +} + +/* We cannot reuse the bnull functions here, because that would require + * the client library to include a lot more files. + */ + +#ifdef DEBUG_PROBE +void bcl_probeSystem (CardPtr card_list) +{ + DPRINTF ("bcl_probeSystem\n"); +} + +void bcl_probeCard (void) +{ + DPRINTF ("bcl_probeCard\n"); +} + +I2CChainPtr bcl_probeBus (void) +{ + DPRINTF ("bcl_probeBus\n"); + return NULL; +} +#endif + +BackAccessRec bcl_access_func = { + openCard: bcl_openCard, + closeCard: bcl_closeCard, +#ifdef DEBUG_PROBE + probeSystem: bcl_probeSystem, +#endif +}; + +BackCardRec bcl_card_func = { + openCard: bcl_openCard, + closeCard: bcl_closeCard, +#ifdef DEBUG_PROBE + probeCard: bcl_probeCard, + probeBus: bcl_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 TODO: 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 (); + if (version != PIPE_VERSION) + ERROR ("Server protocol version mismatch\n"); + 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->dev = ""; + card->arch = ""; + card->chips = NULL; + card->dev = NULL; + } + return bcl_root; +} + diff --git a/src/xine-engine/nvtv/back_client.h b/src/xine-engine/nvtv/back_client.h new file mode 100644 index 000000000..c2dada5c4 --- /dev/null +++ b/src/xine-engine/nvtv/back_client.h @@ -0,0 +1,66 @@ +/* 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: back_client.h,v 1.1 2003/01/18 15:29:22 miguelfreitas Exp $ + * + * Contents: + * + * Header for client backend + */ + +#ifndef _BACK_CLIENT_H +#define _BACK_CLIENT_H + +#include "debug.h" +#include "backend.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 (TVRegs *r); +void bcl_getMode (TVRegs *r); +void bcl_setModeSettings (TVRegs *r, TVSettings *set); +void bcl_setTestImage (TVEncoderRegs *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); +Bool bcl_findByOverscan (TVSystem system, int xres, int yres, + double hoc, double voc, TVMode *mode); + +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/nvtv/backend.h b/src/xine-engine/nvtv/backend.h new file mode 100644 index 000000000..2bcf2629e --- /dev/null +++ b/src/xine-engine/nvtv/backend.h @@ -0,0 +1,124 @@ +/* NVTV 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: backend.h,v 1.1 2003/01/18 15:29:22 miguelfreitas Exp $ + * + * Contents: + * + * Common header for all backends + */ + +#ifndef _BACKEND_H +#define _BACKEND_H + +#include "debug.h" +#include "tv_chip.h" + +#ifdef DEBUG_PROBE +#include "tv_common.h" +#endif + +#include "local.h" /* for Bool, after xfree.h */ + +/* 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 */ + int bus, addr; /* I2C bus and address */ + 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 (not via pipe) */ + char *arch; /* architecture (not via pipe) */ + CardType type; + unsigned long reg_base; + unsigned long pio_base; + int addr_bus, addr_slot, addr_func; + 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 (*getHeadDev) (int head, int *devFlags); + void (*setChip) (ChipPtr chip, Bool init); + void (*setSettings) (TVSettings *set); + void (*getSettings) (TVSettings *set); + void (*setMode) (TVRegs *r); + void (*getMode) (TVRegs *r); + void (*setModeSettings) (TVRegs *r, TVSettings *set); + void (*setTestImage) (TVEncoderRegs *tv, TVSettings *set); + long (*getStatus) (int index); + TVConnect (*getConnection) (void); + Bool (*findBySize) (TVSystem system, int xres, int yres, char *size, + TVMode *mode); + Bool (*findByOverscan) (TVSystem system, int xres, int yres, + double hoc, double voc, TVMode *mode); + 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 */ diff --git a/src/xine-engine/nvtv/debug.h b/src/xine-engine/nvtv/debug.h new file mode 100644 index 000000000..e5b116558 --- /dev/null +++ b/src/xine-engine/nvtv/debug.h @@ -0,0 +1,220 @@ +/* NVTV debug -- Dirk Thierbach <dthierbach@gmx.de> + * + * This is open software protected by the GPL. See GPL.txt for details. + * + * Debug definitions. + * + */ + +#ifndef _DEBUG_H +#define _DEBUG_H + +#include <stdio.h> + +/* -------- Config defines -------- */ + +/* Chrontel slave sync modes (normally not necessary) */ +/* #define CONFIG_SLAVE_CH */ + +/* Brooktree async modes (test) */ +/* #define CONFIG_ASYNC_BT */ + +/* Setup BlankEnd for Voodoo cards */ +#define CONFIG_TDFX_SETUP_BLANK + +/* Allow GeForce2Go */ +#define CONFIG_GEFORCEGO_OK + +/* Allow overlay modes */ +/* #define CONFIG_OVERLAY_NV */ + +/* -------- Debugging defines -------- */ + +/* Temporary define for philips 7104 test modes */ +/* #define TEST_PHILIPS */ + +/* Enable DPRINTF messages */ +/* #define NVTV_DEBUG */ + +/* Disable timeout procs */ +/* #define DISABLE_TIMEOUT */ + +/* Enable probe/debug routines */ +#define DEBUG_PROBE + +/* Scan all unknown chips of no known tv chip is found (nv_tv.c) */ +#define PROBE_ALL_UNKNOWN + +/* The EEPROM on the XBox bus might cause problems when probed. */ +#ifdef XBOX_SUPPORT +#undef PROBE_ALL_UNKOWN +#endif + +/* -------- Meta */ + +/* Fake XBox (Meta) */ +/* #define FAKE_XBOX */ + +/* Fake GeForce3 (Meta) */ +/* #define FAKE_GEFORCE3 */ + +/* Fake Voodoo3 (Meta) */ +/* #define FAKE_VOODOO */ + +/* Fake Intel i810 (Meta) */ +/* #define FAKE_I810 */ + +/* Fake Brooktree chip (Meta) */ +/* #define FAKE_BROOKTREE */ + +/* Fake Conexant chip (Meta) */ +/* #define FAKE_CONEXANT */ + +/* Fake Chrontel chip (Meta) */ +/* #define FAKE_CHRONTEL */ + +/* Fake Philips chip (Meta) */ +/* #define FAKE_PHILIPS */ + +/* Fake TV mode (Meta) */ +/* #define FAKE_TV */ + +/* -------- Assertions */ + +/* Check MMIO when faking it */ +/* #define CHECK_MMIO */ + +/* Base and range for check */ +/* #define CHECK_MMIO_BASE 0x601 */ +/* #define CHECK_MMIO_MIN 0x2000 */ +/* #define CHECK_MMIO_MAX 0x4000 */ +/* #define CHECK_MMIO_ABORT */ + +/* -------- */ + +/* Fake successful probing of all tv chips (nv_tv.c) */ +/* #define FAKE_PROBE_ALL */ + +/* Fake successful probing of this addr on all busses (nv_tv.c) */ +/* #define FAKE_PROBE_ADDR 0xEA */ + +/* Fake Brooktree chip identification */ +/* #define FAKE_PROBE_BROOKTREE */ + +/* Fake Conexant chip identification */ +/* #define FAKE_PROBE_CONEXANT */ + +/* Fake Chrontel chip identification */ +/* #define FAKE_PROBE_CHRONTEL */ + +/* Fake Philips chip identification */ +/* #define FAKE_PROBE_PHILIPS */ + +/* Fake id to return on identification */ +/* #define FAKE_PROBE_ID TV_PHILIPS_7104 */ + +/* Fake I2C Bus reads and writes (nv_tv.c) */ +/* #define FAKE_I2C */ + +/* Fake CRTC register writes (nv_tv.c) */ +/* #define FAKE_CRTC */ + +/* Fake mmapped register writes (tv_nv.c) */ +/* #define FAKE_MMIO */ + +/* Fake pci card in root backend */ +/* #define FAKE_CARD */ + +/* Fake memory mapping */ +/* #define FAKE_CARD_MMAP */ + +/* Fake vendor id of pci card. */ +/* #define FAKE_CARD_VENDOR PCI_VENDOR_3DFX */ + +/* Fake device id of pci card */ +/* #define FAKE_CARD_DEVICE PCI_CHIP_VOODOO3 */ + +/* -------- */ + +#ifdef FAKE_XBOX +#define FAKE_CARD +#define FAKE_CARD_MMAP +#define FAKE_MMIO +#define FAKE_CRTC +#define FAKE_I2C +#define FAKE_CARD_VENDOR PCI_VENDOR_NVIDIA +#define FAKE_CARD_DEVICE PCI_CHIP_GEFORCE3_MCPX +#endif + +#ifdef FAKE_GEFORCE3 +#define FAKE_CARD +#define FAKE_CARD_MMAP +#define FAKE_MMIO +#define FAKE_CARD_VENDOR PCI_VENDOR_NVIDIA +#define FAKE_CARD_DEVICE PCI_CHIP_GEFORCE3 +#endif + +#ifdef FAKE_VOODOO +#define FAKE_CARD +#define FAKE_CARD_MMAP +#define FAKE_CARD_VENDOR PCI_VENDOR_3DFX +#define FAKE_CARD_DEVICE PCI_CHIP_VOODOO3 +#endif + +#ifdef FAKE_I810 +#define FAKE_CARD +#define FAKE_CARD_MMAP +#define FAKE_CARD_VENDOR PCI_VENDOR_INTEL +#define FAKE_CARD_DEVICE PCI_CHIP_I810 +#endif + +#ifdef FAKE_BROOKTREE +#define FAKE_MMIO +#define FAKE_CRTC +#define FAKE_I2C +#define FAKE_PROBE_ADDR 0x8A +#define FAKE_PROBE_BROOKTREE +#endif + +#ifdef FAKE_CONEXANT +#define FAKE_MMIO +#define FAKE_CRTC +#define FAKE_I2C +#define FAKE_PROBE_ADDR 0x8A +#define FAKE_PROBE_CONEXANT +#endif + +#ifdef FAKE_CHRONTEL +#define FAKE_MMIO +#define FAKE_CRTC +#define FAKE_I2C +#define FAKE_PROBE_ADDR 0xEA +#define FAKE_PROBE_CHRONTEL +#endif + +#ifdef FAKE_PHILIPS +#define FAKE_MMIO +#define FAKE_CRTC +#define FAKE_I2C +#define FAKE_PROBE_ADDR 0x88 +#define FAKE_PROBE_PHILIPS +#endif + +#ifdef FAKE_TV +#define FAKE_MMIO +#define FAKE_CRTC +#endif + +#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 + +#endif diff --git a/src/xine-engine/nvtv/libnvclient_dummy.c b/src/xine-engine/nvtv/libnvclient_dummy.c new file mode 100644 index 000000000..d0a6912b8 --- /dev/null +++ b/src/xine-engine/nvtv/libnvclient_dummy.c @@ -0,0 +1 @@ +char libnvclient_dummy; diff --git a/src/xine-engine/nvtv/local.h b/src/xine-engine/nvtv/local.h new file mode 100644 index 000000000..518553337 --- /dev/null +++ b/src/xine-engine/nvtv/local.h @@ -0,0 +1,57 @@ +/* NVTV Local 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: local.h,v 1.1 2003/01/18 15:29:22 miguelfreitas Exp $ + * + * Contents: + * + * Header: Local declarations. + * + * - Defines for GTK2 vs. GTK. + * - Define for Bool (must be included after xfree.h for this reason) + * + */ + +#ifndef _LOCAL_H +#define _LOCAL_H + +#ifdef HAVE_GTK + +#if GTK_MAJOR_VERSION >= 2 + +#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) + +#endif +#endif /* HAVE_GTK */ + +#ifndef _XDEFS_H +typedef int Bool; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#endif /* _XDEFS_H */ + +#endif /* _LOCAL_H */ diff --git a/src/xine-engine/nvtv/miscstruct.h b/src/xine-engine/nvtv/miscstruct.h new file mode 100644 index 000000000..538d9ac62 --- /dev/null +++ b/src/xine-engine/nvtv/miscstruct.h @@ -0,0 +1,93 @@ +/* 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 + +#ifdef HAVE_X + +#include <X11/Xdefs.h> + +#else + +typedef unsigned char CARD8; +typedef unsigned short CARD16; +typedef unsigned long CARD32; +typedef long INT32; +typedef void* pointer; + +#ifndef Bool +#define Bool int +#endif + +#endif /* HAVE_X */ + +/**** 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 */ + diff --git a/src/xine-engine/nvtv/pipe.c b/src/xine-engine/nvtv/pipe.c new file mode 100644 index 000000000..b12dc3bd1 --- /dev/null +++ b/src/xine-engine/nvtv/pipe.c @@ -0,0 +1,251 @@ +/* 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: pipe.c,v 1.1 2003/01/18 15:29:22 miguelfreitas Exp $ + * + * Contents: + * + * Routines to access the named pipe for server/client communication + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#include "debug.h" +#include "pipe.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/nvtv/pipe.h b/src/xine-engine/nvtv/pipe.h new file mode 100644 index 000000000..dbb012d95 --- /dev/null +++ b/src/xine-engine/nvtv/pipe.h @@ -0,0 +1,82 @@ +/* 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: pipe.h,v 1.1 2003/01/18 15:29:22 miguelfreitas Exp $ + * + * Contents: + * + * Routine prototypes to access the named pipe for server/client + * communication, and communication protocol constants. + * + */ + +#ifndef _PIPE_H +#define _PIPE_H + +#include <stdio.h> + +#ifndef CONFIG_PIPE_PATH +#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_VERSION 0x000403 /* 0.4.3 */ + +/* even numbered commands expect no return, odd numbered 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: Regs */ + PCmd_GetMode = 17, /* In: None; Out: Regs */ + PCmd_SetModeSettings = 18, /* In: Regs, Settings; */ + PCmd_SetTestImage = 20, /* In: EncRegs, Setttings; */ + 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_GetHeadDev = 43, /* In: Head; Out: Dev Flags */ + 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 */ diff --git a/src/xine-engine/nvtv/tv_chip.h b/src/xine-engine/nvtv/tv_chip.h new file mode 100644 index 000000000..e8110a566 --- /dev/null +++ b/src/xine-engine/nvtv/tv_chip.h @@ -0,0 +1,639 @@ +/* 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: tv_chip.h,v 1.1 2003/01/18 15:29:22 miguelfreitas 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_FIRST = 1, + CARD_NVIDIA = 1, + CARD_TDFX = 2, + CARD_I810 = 3, + CARD_XBOX = 4, + CARD_LAST = 4, +} 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_CHIP_BY_ADDR = -1, + TV_NO_CHIP = 0, + TV_CHRONTEL = 0x1000, + TV_BROOKTREE = 0x2000, + TV_CONEXANT = 0x2100, + 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, +} TVChip; + +#define TV_PHILIPS_MODEL 0x00f0 +#define TV_PHILIPS_MODEL1 0x0010 +#define TV_PHILIPS_MODEL2 0x0020 + +#define TV_ENCODER 0xff00 /* mask for principal encoder type */ + +/* -------- Host interface flags, all chips -------- */ + +/* These constants are used both for the host port and the encoder port. + Direction is seen in both cases from the encoder, so "in" means + "to encoder", "out" means "to host" */ + +#define PORT_SYNC_DIR (1 << 0) +#define PORT_SYNC_OUT (0 << 0) +#define PORT_SYNC_IN (1 << 0) + +#define PORT_SYNC_MASTER PORT_SYNC_OUT +#define PORT_SYNC_SLAVE PORT_SYNC_IN + +#define PORT_BLANK_MODE (1 << 1) +#define PORT_BLANK_REGION (0 << 1) +#define PORT_BLANK_DOTCLK (1 << 1) + +#define PORT_BLANK_DIR (1 << 2) +#define PORT_BLANK_OUT (0 << 2) +#define PORT_BLANK_IN (1 << 2) + +#define PORT_PCLK_MODE (1 << 3) +#define PORT_PCLK_MASTER (0 << 3) +#define PORT_PCLK_SLAVE (1 << 3) + +#define PORT_VSYNC_POLARITY (1 << 4) +#define PORT_VSYNC_LOW (0 << 4) +#define PORT_VSYNC_HIGH (1 << 4) + +#define PORT_HSYNC_POLARITY (1 << 5) +#define PORT_HSYNC_LOW (0 << 5) +#define PORT_HSYNC_HIGH (1 << 5) + +#define PORT_BLANK_POLARITY (1 << 6) +#define PORT_BLANK_LOW (0 << 6) +#define PORT_BLANK_HIGH (1 << 6) + +#define PORT_PCLK_POLARITY (1 << 7) +#define PORT_PCLK_LOW (0 << 7) +#define PORT_PCLK_HIGH (1 << 7) + +#define PORT_FORMAT_MASK (3 << 8) +#define PORT_FORMAT_MASK_COLOR (1 << 8) +#define PORT_FORMAT_MASK_ALT (2 << 8) +#define PORT_FORMAT_RGB (0 << 8) +#define PORT_FORMAT_YCRCB (1 << 8) +#define PORT_FORMAT_ALT_RGB (2 << 8) +#define PORT_FORMAT_ALT_YCRCB (3 << 8) + +#define PORT_XBOX \ + (PORT_VSYNC_HIGH | PORT_HSYNC_HIGH | PORT_SYNC_IN | \ + PORT_BLANK_LOW | PORT_BLANK_OUT | PORT_PCLK_HIGH | PORT_PCLK_MASTER | \ + PORT_FORMAT_ALT_YCRCB) + +#define PORT_NVIDIA \ + (PORT_VSYNC_HIGH | PORT_HSYNC_HIGH | PORT_SYNC_OUT | \ + PORT_BLANK_LOW | PORT_BLANK_OUT | PORT_PCLK_HIGH | PORT_PCLK_MASTER | \ + PORT_FORMAT_RGB) + +#define PORT_NVIDIA_SYNC_SLAVE \ + (PORT_VSYNC_HIGH | PORT_HSYNC_HIGH | PORT_SYNC_IN | \ + PORT_BLANK_LOW | PORT_BLANK_OUT | PORT_PCLK_HIGH | PORT_PCLK_MASTER | \ + PORT_FORMAT_RGB) + +#define PORT_NVIDIA_PCLK_SLAVE \ + (PORT_VSYNC_HIGH | PORT_HSYNC_HIGH | PORT_SYNC_OUT | \ + PORT_BLANK_LOW | PORT_BLANK_OUT | PORT_PCLK_HIGH | PORT_PCLK_SLAVE | \ + PORT_FORMAT_RGB) + +#define PORT_TDFX \ + (PORT_VSYNC_HIGH | PORT_HSYNC_HIGH | PORT_SYNC_OUT | \ + PORT_BLANK_LOW | PORT_BLANK_IN | PORT_BLANK_REGION | \ + PORT_PCLK_HIGH | PORT_PCLK_MASTER | PORT_FORMAT_RGB) + +#define PORT_I810 \ + (PORT_VSYNC_LOW | PORT_HSYNC_LOW | PORT_SYNC_IN | \ + PORT_BLANK_LOW | PORT_BLANK_OUT | PORT_PCLK_HIGH | PORT_PCLK_MASTER | \ + PORT_FORMAT_RGB) + +/* -------- 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_SYSTEM (BT_FLAG1_VSYNC_DUR | BT_FLAG1_SETUP | \ + BT_FLAG1_PAL_MD | BT_FLAG1_625LINE) +#define BT_FLAG1_NTSC (BT_FLAG1_VSYNC_DUR | BT_FLAG1_SETUP) +#define BT_FLAG1_NTSC_J (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 + +#define CH_FLAG_ACIV (1 << 4) +#define CH_FLAG_CFRB (1 << 5) +#define CH_FLAG_CVBW (1 << 6) + +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_cbw; /* func */ + int vbw_ypeak; /* func */ /* flag */ + int vbw_ysv; /* func */ + int vbw_ycv; /* func */ /* flag */ + int dacg; /* level(system) */ /* flag */ + int civh; /* func */ + int sav; /* time */ + int blr; /* level(system) */ + int hpr; /* func/time */ + int vpr; /* func/time */ + int ce; /* func */ + int te; /* func, CH7009 only */ + 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_EDGE (1 << 9) + +#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 + +#define PH_FLAG3_DOUBLE (1 << 0) + +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 flags3; + int macro; +} TVPhRegs; + +/* -------- CRT -------- */ + +/* Flags for devices */ + +#define DEV_MONITOR (1 << 0) +#define DEV_TELEVISION (1 << 1) +#define DEV_FLATPANEL (1 << 2) +#define DEV_OVERLAY (1 << 3) + +/* Flags that describe the mode, capabilities and defaults + (in TVMode.descFlags). TODO: Get rid of Dualview, etc. */ + +#define TV_DESC_DUALVIEW (1 << 2) /* Default dualview */ +#define TV_DESC_MACROVISION (1 << 3) /* Default macrovision */ +#define TV_DESC_NONINTERLACED (1 << 4) /* Default noninterlace */ +#define TV_DESC_MONOCHROME (1 << 5) /* Default monochrome */ +#define TV_DESC_CARRIER_LOCK (1 << 6) /* Default carrier lock */ +#define TV_DESC_COLORFIX (1 << 7) /* Default color fix */ + +#define TV_CAP_DUALVIEW (1 << 10) /* Has dualview */ +#define TV_CAP_MACROVISION (1 << 11) /* Has macrovision choice */ +#define TV_CAP_NONINTERLACED (1 << 12) /* Has noninterlace */ +#define TV_CAP_MONOCHROME (1 << 13) /* Has monochrome */ +#define TV_CAP_CARRIER_LOCK (1 << 14) /* Has carrier lock */ +#define TV_CAP_COLORFIX (1 << 15) /* Has color fix */ + +#define TV_CAP_OVERLAY (1 << 24) /* Is overlay mode */ + +#define TV_CAP_BIT 8 /* Bit shift for DESC -> CAP */ + +#define TV_CAP_MASK (TV_CAP_DUALVIEW | TV_CAP_MACROVISION | \ + TV_CAP_MONOCHROME | TV_CAP_NONINTERLACED | \ + TV_CAP_COLORFIX) + +#define TV_DEF_DUALVIEW (TV_CAP_DUALVIEW | TV_DESC_DUALVIEW) + +#define NV_FLAG_DOUBLE_SCAN (1 << 0) +#define NV_FLAG_DOUBLE_PIX (1 << 1) + +typedef struct { + int HSyncStart; + int HSyncEnd; + int HTotal; + int VSyncStart; + int VSyncEnd; + int VTotal; + int Unknown; +} TVNvSlaveRegs; + +typedef struct { + int HDisplay; + int HSyncStart; + int HSyncEnd; + int HTotal; + int HValidStart; + int HValidEnd; + int HCrtc; + int VDisplay; + int VSyncStart; + int VSyncEnd; + int VTotal; + int VValidStart; + int VValidEnd; + int VCrtc; +} TVNvFpRegs; + +typedef struct { + long clock; /* Pixel clock in kHz, 0 = ignore */ + int HDisplay; /* horizontal timing */ + int HBlankStart; + int HSyncStart; + int HSyncEnd; + int HBlankEnd; + int HTotal; + int VDisplay; /* vertical timing */ + int VBlankStart; + int VSyncStart; + int VSyncEnd; + int VBlankEnd; + int VTotal; + int latency; /* internal TV clock delay */ + int flags; + TVNvSlaveRegs slave; + TVNvFpRegs fp; +} TVNvRegs; + +typedef struct { + int tvHDisplay; /* horizontal timing */ + int tvHBlankStart; + int tvHSyncStart; + int tvHSyncEnd; + int tvHBlankEnd; + int tvHTotal; + int tvVDisplay; /* vertical timing */ + int tvVBlankStart; + int tvVSyncStart; + int tvVSyncEnd; + int tvVBlankEnd; + int tvVTotal; + int borderRed; + int borderGreen; + int borderBlue; +} TVI810Regs; + +#define TDFX_FLAG_CLOCK2X (1 << 0) +#define TDFX_FLAG_DOUBLE_PIX (1 << 1) +#define TDFX_FLAG_HALF_MODE (1 << 2) + +typedef struct { + long clock; /* Pixel clock in kHz, 0 = ignore */ + int HDisplay; /* horizontal timing */ + int HBlankStart; + int HSyncStart; + int HSyncEnd; + int HBlankEnd; + int HTotal; + int VDisplay; /* vertical timing */ + int VBlankStart; + int VSyncStart; + int VSyncEnd; + int VBlankEnd; + int VTotal; + int HScreenSize; + int VScreenSize; + int tvHBlankStart; + int tvHBlankEnd; + int tvVBlankStart; + int tvVBlankEnd; + int tvBlankDelay; + int tvSyncDelay; + int tvLatency; /* internal TV clock delay */ + int flags; +} TVTdfxRegs; + +/* -------- Common -------- */ + +typedef union { + TVBtRegs bt; + TVCxRegs cx; + TVChRegs ch; + TVPhRegs ph; +} TVEncoderRegs; + +typedef union { + TVNvRegs nv; + TVI810Regs i810; + TVTdfxRegs tdfx; +} TVCrtcRegs; + +typedef struct { + int devFlags; /* device(s) used for this mode */ + TVCrtcRegs crtc; + TVEncoderRegs enc; + int portHost; + int portEnc; +} TVRegs; + +/* External mode specification. TODO: Change this into x, y, and list + of attributes */ + +typedef struct { + TVSystem system; + int res_x; + int res_y; + char *size; + char *aspect; + double hoc; + double voc; +} TVModeSpec; + +typedef struct { + TVModeSpec spec; + TVRegs regs; + int descFlags; /* capabilities and defaults */ +} TVMode; + +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 */ + +#endif /* _TV_CHIP */ diff --git a/src/xine-engine/nvtv/tv_common.h b/src/xine-engine/nvtv/tv_common.h new file mode 100644 index 000000000..bd441f147 --- /dev/null +++ b/src/xine-engine/nvtv/tv_common.h @@ -0,0 +1,80 @@ +/* NVTV TV types 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: tv_common.h,v 1.1 2003/01/18 15:29:22 miguelfreitas Exp $ + * + * Contents: + * + * Header: Common tv-related data types and defines. + * + */ + +#ifndef _TV_COMMON_H +#define _TV_COMMON_H + +#include "xfree.h" +#include "xf86i2c.h" +#include "tv_chip.h" + +typedef struct _I2CChainRec *I2CChainPtr; +typedef struct _I2CChainRec { + char *name; + I2CDevPtr dev; + I2CChainPtr next; + TVChip chip; +} I2CChainRec; + +typedef struct _TvEncoderObj TVEncoderObj; + +struct _TvEncoderObj { + TVChip chip; + I2CDevPtr dev; + long minClock, maxClock; /* in kHz */ + int hwconfig; + int hwstate; + void (*Create) (TVEncoderObj *this, TVChip chip, I2CDevPtr dev); + void (*InitRegs) (TVEncoderObj *this, int port); + void (*SetRegs) (TVEncoderObj *this, TVEncoderRegs *r, TVState state); + void (*SetPort) (TVEncoderObj *this, int port); + void (*SetState) (TVEncoderObj *this, TVEncoderRegs *r, TVState state); + TVConnect (*GetConnect) (TVEncoderObj *this); + long (*GetStatus) (TVEncoderObj *this, int index); +}; + +/* I2C Id of device for use in (s)printf */ +#define I2C_ID(dev) dev->pI2CBus->BusName+2,dev->SlaveAddr + +I2CChainPtr TVFindDevice (I2CChainPtr root, TVChip chip); +I2CChainPtr TVCreateChain (I2CBusPtr busses[], int nbus, Bool all); + +void TVDestroyChain (I2CChainPtr root); +void TVDestroyDevices (I2CBusPtr busses[], int nbus); +void TVDestroyBusses (I2CBusPtr busses[], int nbus); + +void TVProbeDevice (I2CBusPtr bus, I2CSlaveAddr addr, char *format, ...); +void TVProbeCreateKnown (I2CBusPtr busses[], int nbus, I2CChainPtr *chain); +void TVProbeCreateAll (I2CBusPtr busses[], int nbus, I2CChainPtr *chain); + +void TVSetTvEncoder (TVEncoderObj *encoder, I2CChainPtr chain); + +TVChip TVDetectDeviceA (I2CDevPtr dev); /* for 0x88/0x8A */ +TVChip TVDetectDeviceB (I2CDevPtr dev); /* for 0xEA/0xEC */ + +extern TVState tvState; + +#endif /* _TV_COMMON_H */ diff --git a/src/xine-engine/nvtv/xf86i2c.h b/src/xine-engine/nvtv/xf86i2c.h new file mode 100644 index 000000000..2c41d9fd4 --- /dev/null +++ b/src/xine-engine/nvtv/xf86i2c.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 1998 Itai Nahshon, Michael Schimek + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.4 1999/04/11 13:11:01 dawes Exp $ */ +#ifndef _XF86I2C_H +#define _XF86I2C_H + +#include "miscstruct.h" + +typedef unsigned char I2CByte; +typedef unsigned short I2CSlaveAddr; + +typedef struct _I2CBusRec *I2CBusPtr; +typedef struct _I2CDevRec *I2CDevPtr; + +/* I2C masters have to register themselves */ + +typedef struct _I2CBusRec { + char * BusName; + int scrnIndex; + + void (*I2CUDelay) (I2CBusPtr b, int usec); + + void (*I2CPutBits)(I2CBusPtr b, int scl, int sda); + void (*I2CGetBits)(I2CBusPtr b, int *scl, int *sda); + + /* Look at the generic routines to see how these functions should behave. */ + + Bool (*I2CAddress)(I2CDevPtr d, I2CSlaveAddr); + void (*I2CStop) (I2CDevPtr d); + Bool (*I2CPutByte)(I2CDevPtr d, I2CByte data); + Bool (*I2CGetByte)(I2CDevPtr d, I2CByte *data, Bool); + + DevUnion DriverPrivate; + + int HoldTime; /* 1 / bus clock frequency, 5 or 2 usec */ + + int BitTimeout; /* usec */ + int ByteTimeout; /* usec */ + int AcknTimeout; /* usec */ + int StartTimeout; /* usec */ + int RiseFallTime; /* usec */ + + I2CDevPtr FirstDev; + I2CBusPtr NextBus; +} I2CBusRec; + +I2CBusPtr xf86CreateI2CBusRec(void); +void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc, Bool devs_too); +Bool xf86I2CBusInit(I2CBusPtr pI2CBus); +I2CBusPtr xf86I2CFindBus(int scrnIndex, char *name); + +/* I2C slave devices */ + +typedef struct _I2CDevRec { + char * DevName; + + int BitTimeout; /* usec */ + int ByteTimeout; /* usec */ + int AcknTimeout; /* usec */ + int StartTimeout; /* usec */ + + I2CSlaveAddr SlaveAddr; + I2CBusPtr pI2CBus; + I2CDevPtr NextDev; +} I2CDevRec; + +I2CDevPtr xf86CreateI2CDevRec(void); +void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev, Bool unalloc); +Bool xf86I2CDevInit(I2CDevPtr pI2CDev); +I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr); + +/* See descriptions of these functions in xf86i2c.c */ + +Bool xf86I2CProbeAddress(I2CBusPtr pI2CBus, I2CSlaveAddr); +Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite, + I2CByte *ReadBuffer, int nRead); +#define xf86I2CRead(d, rb, nr) xf86I2CWriteRead(d, NULL, 0, rb, nr) +Bool xf86I2CReadStatus(I2CDevPtr d, I2CByte *pbyte); +Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte); +Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte, int n); +Bool xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword); +#define xf86I2CWrite(d, wb, nw) xf86I2CWriteRead(d, wb, nw, NULL, 0) +Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte); +Bool xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *WriteBuffer, int nWrite); +Bool xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word); +Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte *vec, int nValues); + +#endif /*_XF86I2C_H */ diff --git a/src/xine-engine/nvtv/xfree.h b/src/xine-engine/nvtv/xfree.h new file mode 100644 index 000000000..426a60c54 --- /dev/null +++ b/src/xine-engine/nvtv/xfree.h @@ -0,0 +1,338 @@ +/* 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> + +#ifdef HAVE_X +#include <X11/Xmd.h> +#endif + +#include "miscstruct.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 |