bktr_reg.h revision 65049
1/* 2 * $FreeBSD: head/sys/dev/bktr/bktr_reg.h 65049 2000-08-24 14:17:06Z roger $ 3 * 4 * Copyright (c) 1999 Roger Hardiman 5 * Copyright (c) 1998 Amancio Hasty 6 * Copyright (c) 1995 Mark Tinguely and Jim Lowe 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Mark Tinguely and Jim Lowe 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 */ 36 37#ifdef __FreeBSD__ 38# if (__FreeBSD_version >= 310000) 39# include <sys/bus.h> 40# include "smbus.h" 41# else 42# define NSMBUS 0 /* FreeBSD before 3.1 does not have SMBUS */ 43# endif 44#else 45# define NSMBUS 0 /* Non FreeBSD systems do not have SMBUS */ 46#endif 47 48#ifdef __NetBSD__ 49#include <machine/bus.h> /* struct device */ 50#include <sys/device.h> 51#include <sys/select.h> /* struct selinfo */ 52# ifdef DEBUG 53# define bootverbose 1 54# else 55# define bootverbose 0 56# endif 57#endif 58 59/* 60 * The kernel options for the driver now all begin with BKTR. 61 * Support the older kernel options on FreeBSD and OpenBSD. 62 * 63 */ 64#if defined(__FreeBSD__) || defined(__OpenBSD__) 65#if defined(BROOKTREE_SYSTEM_DEFAULT) 66#define BKTR_SYSTEM_DEFAULT BROOKTREE_SYSTEM_DEFAULT 67#endif 68 69#if defined(OVERRIDE_CARD) 70#define BKTR_OVERRIDE_CARD OVERRIDE_CARD 71#endif 72 73#if defined(OVERRIDE_TUNER) 74#define BKTR_OVERRIDE_TUNER OVERRIDE_TUNER 75#endif 76 77#if defined(OVERRIDE_DBX) 78#define BKTR_OVERRIDE_DBX OVERRIDE_DBX 79#endif 80 81#if defined(OVERRIDE_MSP) 82#define BKTR_OVERRIDE_MSP OVERRIDE_MSP 83#endif 84 85#endif 86 87 88#ifndef PCI_LATENCY_TIMER 89#define PCI_LATENCY_TIMER 0x0c /* pci timer register */ 90#endif 91 92/* 93 * Definitions for the Brooktree 848/878 video capture to pci interface. 94 */ 95#define BROOKTREE_848_PCI_ID 0x0350109E 96#define BROOKTREE_849_PCI_ID 0x0351109E 97#define BROOKTREE_878_PCI_ID 0x036E109E 98#define BROOKTREE_879_PCI_ID 0x036F109E 99 100#define BROOKTREE_848 1 101#define BROOKTREE_848A 2 102#define BROOKTREE_849A 3 103#define BROOKTREE_878 4 104#define BROOKTREE_879 5 105 106typedef volatile u_int bregister_t; 107/* 108 * if other persuasion endian, then compiler will probably require that 109 * these next 110 * macros be reversed 111 */ 112#define BTBYTE(what) bregister_t what:8; int :24 113#define BTWORD(what) bregister_t what:16; int: 16 114#define BTLONG(what) bregister_t what:32 115 116struct bt848_registers { 117 BTBYTE (dstatus); /* 0, 1,2,3 */ 118#define BT848_DSTATUS_PRES (1<<7) 119#define BT848_DSTATUS_HLOC (1<<6) 120#define BT848_DSTATUS_FIELD (1<<5) 121#define BT848_DSTATUS_NUML (1<<4) 122#define BT848_DSTATUS_CSEL (1<<3) 123#define BT848_DSTATUS_PLOCK (1<<2) 124#define BT848_DSTATUS_LOF (1<<1) 125#define BT848_DSTATUS_COF (1<<0) 126 BTBYTE (iform); /* 4, 5,6,7 */ 127#define BT848_IFORM_MUXSEL (0x3<<5) 128# define BT848_IFORM_M_MUX1 (0x03<<5) 129# define BT848_IFORM_M_MUX0 (0x02<<5) 130# define BT848_IFORM_M_MUX2 (0x01<<5) 131# define BT848_IFORM_M_MUX3 (0x0) 132# define BT848_IFORM_M_RSVD (0x00<<5) 133#define BT848_IFORM_XTSEL (0x3<<3) 134# define BT848_IFORM_X_AUTO (0x03<<3) 135# define BT848_IFORM_X_XT1 (0x02<<3) 136# define BT848_IFORM_X_XT0 (0x01<<3) 137# define BT848_IFORM_X_RSVD (0x00<<3) 138 BTBYTE (tdec); /* 8, 9,a,b */ 139 BTBYTE (e_crop); /* c, d,e,f */ 140 BTBYTE (e_vdelay_lo); /* 10, 11,12,13 */ 141 BTBYTE (e_vactive_lo); /* 14, 15,16,17 */ 142 BTBYTE (e_delay_lo); /* 18, 19,1a,1b */ 143 BTBYTE (e_hactive_lo); /* 1c, 1d,1e,1f */ 144 BTBYTE (e_hscale_hi); /* 20, 21,22,23 */ 145 BTBYTE (e_hscale_lo); /* 24, 25,26,27 */ 146 BTBYTE (bright); /* 28, 29,2a,2b */ 147 BTBYTE (e_control); /* 2c, 2d,2e,2f */ 148#define BT848_E_CONTROL_LNOTCH (1<<7) 149#define BT848_E_CONTROL_COMP (1<<6) 150#define BT848_E_CONTROL_LDEC (1<<5) 151#define BT848_E_CONTROL_CBSENSE (1<<4) 152#define BT848_E_CONTROL_RSVD (1<<3) 153#define BT848_E_CONTROL_CON_MSB (1<<2) 154#define BT848_E_CONTROL_SAT_U_MSB (1<<1) 155#define BT848_E_CONTROL_SAT_V_MSB (1<<0) 156 BTBYTE (contrast_lo); /* 30, 31,32,33 */ 157 BTBYTE (sat_u_lo); /* 34, 35,36,37 */ 158 BTBYTE (sat_v_lo); /* 38, 39,3a,3b */ 159 BTBYTE (hue); /* 3c, 3d,3e,3f */ 160 BTBYTE (e_scloop); /* 40, 41,42,43 */ 161#define BT848_E_SCLOOP_RSVD1 (1<<7) 162#define BT848_E_SCLOOP_CAGC (1<<6) 163#define BT848_E_SCLOOP_CKILL (1<<5) 164#define BT848_E_SCLOOP_HFILT (0x3<<3) 165# define BT848_E_SCLOOP_HFILT_ICON (0x3<<3) 166# define BT848_E_SCLOOP_HFILT_QCIF (0x2<<3) 167# define BT848_E_SCLOOP_HFILT_CIF (0x1<<3) 168# define BT848_E_SCLOOP_HFILT_AUTO (0x0<<3) 169#define BT848_E_SCLOOP_RSVD0 (0x7<<0) 170 int :32; /* 44, 45,46,47 */ 171 BTBYTE (oform); /* 48, 49,4a,4b */ 172 BTBYTE (e_vscale_hi); /* 4c, 4d,4e,4f */ 173 BTBYTE (e_vscale_lo); /* 50, 51,52,53 */ 174 BTBYTE (test); /* 54, 55,56,57 */ 175 int :32; /* 58, 59,5a,5b */ 176 int :32; /* 5c, 5d,5e,5f */ 177 BTLONG (adelay); /* 60, 61,62,63 */ 178 BTBYTE (bdelay); /* 64, 65,66,67 */ 179 BTBYTE (adc); /* 68, 69,6a,6b */ 180#define BT848_ADC_RESERVED (0x80) /* required pattern */ 181#define BT848_ADC_SYNC_T (1<<5) 182#define BT848_ADC_AGC_EN (1<<4) 183#define BT848_ADC_CLK_SLEEP (1<<3) 184#define BT848_ADC_Y_SLEEP (1<<2) 185#define BT848_ADC_C_SLEEP (1<<1) 186#define BT848_ADC_CRUSH (1<<0) 187 BTBYTE (e_vtc); /* 6c, 6d,6e,6f */ 188 int :32; /* 70, 71,72,73 */ 189 int :32; /* 74, 75,76,77 */ 190 int :32; /* 78, 79,7a,7b */ 191 BTLONG (sreset); /* 7c, 7d,7e,7f */ 192 u_char filler1[0x84-0x80]; 193 BTBYTE (tgctrl); /* 84, 85,86,87 */ 194#define BT848_TGCTRL_TGCKI (3<<3) 195#define BT848_TGCTRL_TGCKI_XTAL (0<<3) 196#define BT848_TGCTRL_TGCKI_PLL (1<<3) 197#define BT848_TGCTRL_TGCKI_GPCLK (2<<3) 198#define BT848_TGCTRL_TGCKI_GPCLK_I (3<<3) 199 u_char filler[0x8c-0x88]; 200 BTBYTE (o_crop); /* 8c, 8d,8e,8f */ 201 BTBYTE (o_vdelay_lo); /* 90, 91,92,93 */ 202 BTBYTE (o_vactive_lo); /* 94, 95,96,97 */ 203 BTBYTE (o_delay_lo); /* 98, 99,9a,9b */ 204 BTBYTE (o_hactive_lo); /* 9c, 9d,9e,9f */ 205 BTBYTE (o_hscale_hi); /* a0, a1,a2,a3 */ 206 BTBYTE (o_hscale_lo); /* a4, a5,a6,a7 */ 207 int :32; /* a8, a9,aa,ab */ 208 BTBYTE (o_control); /* ac, ad,ae,af */ 209#define BT848_O_CONTROL_LNOTCH (1<<7) 210#define BT848_O_CONTROL_COMP (1<<6) 211#define BT848_O_CONTROL_LDEC (1<<5) 212#define BT848_O_CONTROL_CBSENSE (1<<4) 213#define BT848_O_CONTROL_RSVD (1<<3) 214#define BT848_O_CONTROL_CON_MSB (1<<2) 215#define BT848_O_CONTROL_SAT_U_MSB (1<<1) 216#define BT848_O_CONTROL_SAT_V_MSB (1<<0) 217 u_char fillter4[16]; 218 BTBYTE (o_scloop); /* c0, c1,c2,c3 */ 219#define BT848_O_SCLOOP_RSVD1 (1<<7) 220#define BT848_O_SCLOOP_CAGC (1<<6) 221#define BT848_O_SCLOOP_CKILL (1<<5) 222#define BT848_O_SCLOOP_HFILT (0x3<<3) 223#define BT848_O_SCLOOP_HFILT_ICON (0x3<<3) 224#define BT848_O_SCLOOP_HFILT_QCIF (0x2<<3) 225#define BT848_O_SCLOOP_HFILT_CIF (0x1<<3) 226#define BT848_O_SCLOOP_HFILT_AUTO (0x0<<3) 227#define BT848_O_SCLOOP_RSVD0 (0x7<<0) 228 int :32; /* c4, c5,c6,c7 */ 229 int :32; /* c8, c9,ca,cb */ 230 BTBYTE (o_vscale_hi); /* cc, cd,ce,cf */ 231 BTBYTE (o_vscale_lo); /* d0, d1,d2,d3 */ 232 BTBYTE (color_fmt); /* d4, d5,d6,d7 */ 233 bregister_t color_ctl_swap :4; /* d8 */ 234#define BT848_COLOR_CTL_WSWAP_ODD (1<<3) 235#define BT848_COLOR_CTL_WSWAP_EVEN (1<<2) 236#define BT848_COLOR_CTL_BSWAP_ODD (1<<1) 237#define BT848_COLOR_CTL_BSWAP_EVEN (1<<0) 238 bregister_t color_ctl_gamma :1; 239 bregister_t color_ctl_rgb_ded :1; 240 bregister_t color_ctl_color_bars :1; 241 bregister_t color_ctl_ext_frmrate :1; 242#define BT848_COLOR_CTL_GAMMA (1<<4) 243#define BT848_COLOR_CTL_RGB_DED (1<<5) 244#define BT848_COLOR_CTL_COLOR_BARS (1<<6) 245#define BT848_COLOR_CTL_EXT_FRMRATE (1<<7) 246 int :24; /* d9,da,db */ 247 BTBYTE (cap_ctl); /* dc, dd,de,df */ 248#define BT848_CAP_CTL_DITH_FRAME (1<<4) 249#define BT848_CAP_CTL_VBI_ODD (1<<3) 250#define BT848_CAP_CTL_VBI_EVEN (1<<2) 251#define BT848_CAP_CTL_ODD (1<<1) 252#define BT848_CAP_CTL_EVEN (1<<0) 253 BTBYTE (vbi_pack_size); /* e0, e1,e2,e3 */ 254 BTBYTE (vbi_pack_del); /* e4, e5,e6,e7 */ 255 int :32; /* e8, e9,ea,eb */ 256 BTBYTE (o_vtc); /* ec, ed,ee,ef */ 257 BTBYTE (pll_f_lo); /* f0, f1,f2,f3 */ 258 BTBYTE (pll_f_hi); /* f4, f5,f6,f7 */ 259 BTBYTE (pll_f_xci); /* f8, f9,fa,fb */ 260#define BT848_PLL_F_C (1<<6) 261#define BT848_PLL_F_X (1<<7) 262 u_char filler2[0x100-0xfc]; 263 BTLONG (int_stat); /* 100, 101,102,103 */ 264 BTLONG (int_mask); /* 104, 105,106,107 */ 265#define BT848_INT_RISCS (0xf<<28) 266#define BT848_INT_RISC_EN (1<<27) 267#define BT848_INT_RACK (1<<25) 268#define BT848_INT_FIELD (1<<24) 269#define BT848_INT_MYSTERYBIT (1<<23) 270#define BT848_INT_SCERR (1<<19) 271#define BT848_INT_OCERR (1<<18) 272#define BT848_INT_PABORT (1<<17) 273#define BT848_INT_RIPERR (1<<16) 274#define BT848_INT_PPERR (1<<15) 275#define BT848_INT_FDSR (1<<14) 276#define BT848_INT_FTRGT (1<<13) 277#define BT848_INT_FBUS (1<<12) 278#define BT848_INT_RISCI (1<<11) 279#define BT848_INT_GPINT (1<<9) 280#define BT848_INT_I2CDONE (1<<8) 281#define BT848_INT_RSV1 (1<<7) 282#define BT848_INT_RSV0 (1<<6) 283#define BT848_INT_VPRES (1<<5) 284#define BT848_INT_HLOCK (1<<4) 285#define BT848_INT_OFLOW (1<<3) 286#define BT848_INT_HSYNC (1<<2) 287#define BT848_INT_VSYNC (1<<1) 288#define BT848_INT_FMTCHG (1<<0) 289 int :32; /* 108, 109,10a,10b */ 290 BTWORD (gpio_dma_ctl); /* 10c, 10d,10e,10f */ 291#define BT848_DMA_CTL_PL23TP4 (0<<6) /* planar1 trigger 4 */ 292#define BT848_DMA_CTL_PL23TP8 (1<<6) /* planar1 trigger 8 */ 293#define BT848_DMA_CTL_PL23TP16 (2<<6) /* planar1 trigger 16 */ 294#define BT848_DMA_CTL_PL23TP32 (3<<6) /* planar1 trigger 32 */ 295#define BT848_DMA_CTL_PL1TP4 (0<<4) /* planar1 trigger 4 */ 296#define BT848_DMA_CTL_PL1TP8 (1<<4) /* planar1 trigger 8 */ 297#define BT848_DMA_CTL_PL1TP16 (2<<4) /* planar1 trigger 16 */ 298#define BT848_DMA_CTL_PL1TP32 (3<<4) /* planar1 trigger 32 */ 299#define BT848_DMA_CTL_PKTP4 (0<<2) /* packed trigger 4 */ 300#define BT848_DMA_CTL_PKTP8 (1<<2) /* packed trigger 8 */ 301#define BT848_DMA_CTL_PKTP16 (2<<2) /* packed trigger 16 */ 302#define BT848_DMA_CTL_PKTP32 (3<<2) /* packed trigger 32 */ 303#define BT848_DMA_CTL_RISC_EN (1<<1) 304#define BT848_DMA_CTL_FIFO_EN (1<<0) 305 BTLONG (i2c_data_ctl); /* 110, 111,112,113 */ 306#define BT848_DATA_CTL_I2CDIV (0xf<<4) 307#define BT848_DATA_CTL_I2CSYNC (1<<3) 308#define BT848_DATA_CTL_I2CW3B (1<<2) 309#define BT848_DATA_CTL_I2CSCL (1<<1) 310#define BT848_DATA_CTL_I2CSDA (1<<0) 311 BTLONG (risc_strt_add); /* 114, 115,116,117 */ 312 BTLONG (gpio_out_en); /* 118, 119,11a,11b */ /* really 24 bits */ 313 BTLONG (gpio_reg_inp); /* 11c, 11d,11e,11f */ /* really 24 bits */ 314 BTLONG (risc_count); /* 120, 121,122,123 */ 315 u_char filler3[0x200-0x124]; 316 BTLONG (gpio_data); /* 200, 201,202,203 */ /* really 24 bits */ 317}; 318 319 320#define BKTR_DSTATUS 0x000 321#define BKTR_IFORM 0x004 322#define BKTR_TDEC 0x008 323#define BKTR_E_CROP 0x00C 324#define BKTR_O_CROP 0x08C 325#define BKTR_E_VDELAY_LO 0x010 326#define BKTR_O_VDELAY_LO 0x090 327#define BKTR_E_VACTIVE_LO 0x014 328#define BKTR_O_VACTIVE_LO 0x094 329#define BKTR_E_DELAY_LO 0x018 330#define BKTR_O_DELAY_LO 0x098 331#define BKTR_E_HACTIVE_LO 0x01C 332#define BKTR_O_HACTIVE_LO 0x09C 333#define BKTR_E_HSCALE_HI 0x020 334#define BKTR_O_HSCALE_HI 0x0A0 335#define BKTR_E_HSCALE_LO 0x024 336#define BKTR_O_HSCALE_LO 0x0A4 337#define BKTR_BRIGHT 0x028 338#define BKTR_E_CONTROL 0x02C 339#define BKTR_O_CONTROL 0x0AC 340#define BKTR_CONTRAST_LO 0x030 341#define BKTR_SAT_U_LO 0x034 342#define BKTR_SAT_V_LO 0x038 343#define BKTR_HUE 0x03C 344#define BKTR_E_SCLOOP 0x040 345#define BKTR_O_SCLOOP 0x0C0 346#define BKTR_OFORM 0x048 347#define BKTR_E_VSCALE_HI 0x04C 348#define BKTR_O_VSCALE_HI 0x0CC 349#define BKTR_E_VSCALE_LO 0x050 350#define BKTR_O_VSCALE_LO 0x0D0 351#define BKTR_TEST 0x054 352#define BKTR_ADELAY 0x060 353#define BKTR_BDELAY 0x064 354#define BKTR_ADC 0x068 355#define BKTR_E_VTC 0x06C 356#define BKTR_O_VTC 0x0EC 357#define BKTR_SRESET 0x07C 358#define BKTR_COLOR_FMT 0x0D4 359#define BKTR_COLOR_CTL 0x0D8 360#define BKTR_CAP_CTL 0x0DC 361#define BKTR_VBI_PACK_SIZE 0x0E0 362#define BKTR_VBI_PACK_DEL 0x0E4 363#define BKTR_INT_STAT 0x100 364#define BKTR_INT_MASK 0x104 365#define BKTR_RISC_COUNT 0x120 366#define BKTR_RISC_STRT_ADD 0x114 367#define BKTR_GPIO_DMA_CTL 0x10C 368#define BKTR_GPIO_OUT_EN 0x118 369#define BKTR_GPIO_REG_INP 0x11C 370#define BKTR_GPIO_DATA 0x200 371#define BKTR_I2C_DATA_CTL 0x110 372#define BKTR_TGCTRL 0x084 373#define BKTR_PLL_F_LO 0x0F0 374#define BKTR_PLL_F_HI 0x0F4 375#define BKTR_PLL_F_XCI 0x0F8 376 377/* 378 * device support for onboard tv tuners 379 */ 380 381/* description of the LOGICAL tuner */ 382struct TVTUNER { 383 int frequency; 384 u_char chnlset; 385 u_char channel; 386 u_char band; 387 u_char afc; 388 u_char radio_mode; /* current mode of the radio mode */ 389}; 390 391/* description of the PHYSICAL tuner */ 392struct TUNER { 393 char* name; 394 u_char type; 395 u_char pllControl[4]; 396 u_char bandLimits[ 2 ]; 397 u_char bandAddrs[ 4 ]; /* 3 first for the 3 TV 398 ** bands. Last for radio 399 ** band (0x00=NoRadio). 400 */ 401 402}; 403 404/* description of the card */ 405#define EEPROMBLOCKSIZE 32 406struct CARDTYPE { 407 unsigned int card_id; /* card id (from #define's) */ 408 char* name; 409 const struct TUNER* tuner; /* Tuner details */ 410 u_char tuner_pllAddr; /* Tuner i2c address */ 411 u_char dbx; /* Has DBX chip? */ 412 u_char msp3400c; /* Has msp3400c chip? */ 413 u_char dpl3518a; /* Has dpl3518a chip? */ 414 u_char eepromAddr; 415 u_char eepromSize; /* bytes / EEPROMBLOCKSIZE */ 416 u_int audiomuxs[ 5 ]; /* tuner, ext (line-in) */ 417 /* int/unused (radio) */ 418 /* mute, present */ 419 u_int gpio_mux_bits; /* GPIO mask for audio mux */ 420}; 421 422struct format_params { 423 /* Total lines, lines before image, image lines */ 424 int vtotal, vdelay, vactive; 425 /* Total unscaled horizontal pixels, pixels before image, image pixels */ 426 int htotal, hdelay, hactive; 427 /* Scaled horizontal image pixels, Total Scaled horizontal pixels */ 428 int scaled_hactive, scaled_htotal; 429 /* frame rate . for ntsc is 30 frames per second */ 430 int frame_rate; 431 /* A-delay and B-delay */ 432 u_char adelay, bdelay; 433 /* Iform XTSEL value */ 434 int iform_xtsel; 435 /* VBI number of lines per field, and number of samples per line */ 436 int vbi_num_lines, vbi_num_samples; 437}; 438 439#if ((defined(__FreeBSD__)) && (NSMBUS > 0)) 440struct bktr_i2c_softc { 441 device_t iicbus; 442 device_t smbus; 443}; 444#endif 445 446 447/* Bt848/878 register access 448 * The registers can either be access via a memory mapped structure 449 * or accessed via bus_space. 450 * bus_0pace access allows cross platform support, where as the 451 * memory mapped structure method only works on 32 bit processors 452 * with the right type of endianness. 453 */ 454#if defined(__NetBSD__) || ( defined(__FreeBSD__) && (__FreeBSD_version >=300000) ) 455#define INB(bktr,offset) bus_space_read_1((bktr)->memt,(bktr)->memh,(offset)) 456#define INW(bktr,offset) bus_space_read_2((bktr)->memt,(bktr)->memh,(offset)) 457#define INL(bktr,offset) bus_space_read_4((bktr)->memt,(bktr)->memh,(offset)) 458#define OUTB(bktr,offset,value) bus_space_write_1((bktr)->memt,(bktr)->memh,(offset),(value)) 459#define OUTW(bktr,offset,value) bus_space_write_2((bktr)->memt,(bktr)->memh,(offset),(value)) 460#define OUTL(bktr,offset,value) bus_space_write_4((bktr)->memt,(bktr)->memh,(offset),(value)) 461#else 462#define INB(bktr,offset) *(volatile unsigned char*) ((int)((bktr)->memh)+(offset)) 463#define INW(bktr,offset) *(volatile unsigned short*)((int)((bktr)->memh)+(offset)) 464#define INL(bktr,offset) *(volatile unsigned int*) ((int)((bktr)->memh)+(offset)) 465#define OUTB(bktr,offset,value) *(volatile unsigned char*) ((int)((bktr)->memh)+(offset)) = (value) 466#define OUTW(bktr,offset,value) *(volatile unsigned short*)((int)((bktr)->memh)+(offset)) = (value) 467#define OUTL(bktr,offset,value) *(volatile unsigned int*) ((int)((bktr)->memh)+(offset)) = (value) 468#endif 469 470 471typedef struct bktr_clip bktr_clip_t; 472 473/* 474 * NetBSD >= 1.3H uses vaddr_t instead of vm_offset_t 475 */ 476#if defined(__NetBSD__) && __NetBSD_Version__ >= 103080000 477typedef void * vm_offset_t; 478#endif 479 480/* 481 * BrookTree 848 info structure, one per bt848 card installed. 482 */ 483struct bktr_softc { 484 485#if defined (__bsdi__) 486 struct device bktr_dev; /* base device */ 487 struct isadev bktr_id; /* ISA device */ 488 struct intrhand bktr_ih; /* interrupt vectoring */ 489 #define pcici_t pci_devaddr_t 490#endif 491 492#if defined(__NetBSD__) 493 struct device bktr_dev; /* base device */ 494 bus_dma_tag_t dmat; /* DMA tag */ 495 bus_space_tag_t memt; 496 bus_space_handle_t memh; 497 bus_size_t obmemsz; /* size of en card (bytes) */ 498 void *ih; 499 bus_dmamap_t dm_prog; 500 bus_dmamap_t dm_oprog; 501 bus_dmamap_t dm_mem; 502 bus_dmamap_t dm_vbidata; 503 bus_dmamap_t dm_vbibuffer; 504#endif 505 506#if defined(__OpenBSD__) 507 struct device bktr_dev; /* base device */ 508 bus_dma_tag_t dmat; /* DMA tag */ 509 bus_space_tag_t memt; 510 bus_space_handle_t memh; 511 bus_size_t obmemsz; /* size of en card (bytes) */ 512 void *ih; 513 bus_dmamap_t dm_prog; 514 bus_dmamap_t dm_oprog; 515 bus_dmamap_t dm_mem; 516 bus_dmamap_t dm_vbidata; 517 bus_dmamap_t dm_vbibuffer; 518 size_t dm_mapsize; 519 pci_chipset_tag_t pc; /* Opaque PCI chipset tag */ 520 pcitag_t tag; /* PCI tag, for doing PCI commands */ 521 vm_offset_t phys_base; /* Bt848 register physical address */ 522#endif 523 524#if defined (__FreeBSD__) 525 #if (__FreeBSD_version < 400000) 526 vm_offset_t phys_base; /* 2.x Bt848 register physical address */ 527 pcici_t tag; /* 2.x PCI tag, for doing PCI commands */ 528 #endif 529 #if (__FreeBSD_version >= 400000) 530 int mem_rid; /* 4.x resource id */ 531 struct resource *res_mem; /* 4.x resource descriptor for registers */ 532 int irq_rid; /* 4.x resource id */ 533 struct resource *res_irq; /* 4.x resource descriptor for interrupt */ 534 void *res_ih; /* 4.x newbus interrupt handler cookie */ 535 #endif 536 #if (__FreeBSD_version >= 310000) 537 bus_space_tag_t memt; /* Bus space register access functions */ 538 bus_space_handle_t memh; /* Bus space register access functions */ 539 bus_size_t obmemsz;/* Size of card (bytes) */ 540 #endif 541 #if (NSMBUS > 0) 542 struct bktr_i2c_softc i2c_sc; /* bt848_i2c device */ 543 #endif 544 char bktr_xname[7]; /* device name and unit number */ 545#endif 546 547 /* the following definitions are common over all platforms */ 548 vm_offset_t bigbuf; /* buffer that holds the captured image */ 549 int alloc_pages; /* number of pages in bigbuf */ 550 551 vm_offset_t vbidata; /* RISC program puts VBI data from the current frame here */ 552 vm_offset_t vbibuffer; /* Circular buffer holding VBI data for the user */ 553 int vbiinsert; /* Position for next write into circular buffer */ 554 int vbistart; /* Position of last read from circular buffer */ 555 int vbisize; /* Number of bytes in the circular buffer */ 556 u_long vbi_sequence_number; /* sequence number for VBI */ 557 int vbi_read_blocked; /* user process blocked on read() from /dev/vbi */ 558 struct selinfo vbi_select; /* Data used by select() on /dev/vbi */ 559 560 561 struct proc *proc; /* process to receive raised signal */ 562 int signal; /* signal to send to process */ 563 int clr_on_start; /* clear cap buf on capture start? */ 564#define METEOR_SIG_MODE_MASK 0xffff0000 565#define METEOR_SIG_FIELD_MODE 0x00010000 566#define METEOR_SIG_FRAME_MODE 0x00000000 567 vm_offset_t dma_prog; 568 vm_offset_t odd_dma_prog; 569 char dma_prog_loaded; 570 struct meteor_mem *mem; /* used to control sync. multi-frame output */ 571 u_long synch_wait; /* wait for free buffer before continuing */ 572 short current; /* frame number in buffer (1-frames) */ 573 short rows; /* number of rows in a frame */ 574 short cols; /* number of columns in a frame */ 575 int capture_area_x_offset; /* Usually the full 640x480(NTSC) image is */ 576 int capture_area_y_offset; /* captured. The capture area allows for */ 577 int capture_area_x_size; /* example 320x200 pixels from the centre */ 578 int capture_area_y_size; /* of the video image to be captured. */ 579 char capture_area_enabled; /* When TRUE use user's capture area. */ 580 int pixfmt; /* active pixel format (idx into fmt tbl) */ 581 int pixfmt_compat; /* Y/N - in meteor pix fmt compat mode */ 582 u_long format; /* frame format rgb, yuv, etc.. */ 583 short frames; /* number of frames allocated */ 584 int frame_size; /* number of bytes in a frame */ 585 u_long fifo_errors; /* number of fifo capture errors since open */ 586 u_long dma_errors; /* number of DMA capture errors since open */ 587 u_long frames_captured;/* number of frames captured since open */ 588 u_long even_fields_captured; /* number of even fields captured */ 589 u_long odd_fields_captured; /* number of odd fields captured */ 590 u_long range_enable; /* enable range checking ?? */ 591 u_short capcontrol; /* reg 0xdc capture control */ 592 u_short bktr_cap_ctl; 593 volatile u_int flags; 594#define METEOR_INITALIZED 0x00000001 595#define METEOR_OPEN 0x00000002 596#define METEOR_MMAP 0x00000004 597#define METEOR_INTR 0x00000008 598#define METEOR_READ 0x00000010 /* XXX never gets referenced */ 599#define METEOR_SINGLE 0x00000020 /* get single frame */ 600#define METEOR_CONTIN 0x00000040 /* continuously get frames */ 601#define METEOR_SYNCAP 0x00000080 /* synchronously get frames */ 602#define METEOR_CAP_MASK 0x000000f0 603#define METEOR_NTSC 0x00000100 604#define METEOR_PAL 0x00000200 605#define METEOR_SECAM 0x00000400 606#define BROOKTREE_NTSC 0x00000100 /* used in video open() and */ 607#define BROOKTREE_PAL 0x00000200 /* in the kernel config */ 608#define BROOKTREE_SECAM 0x00000400 /* file */ 609#define METEOR_AUTOMODE 0x00000800 610#define METEOR_FORM_MASK 0x00000f00 611#define METEOR_DEV0 0x00001000 612#define METEOR_DEV1 0x00002000 613#define METEOR_DEV2 0x00004000 614#define METEOR_DEV3 0x00008000 615#define METEOR_DEV_SVIDEO 0x00006000 616#define METEOR_DEV_RGB 0x0000a000 617#define METEOR_DEV_MASK 0x0000f000 618#define METEOR_RGB16 0x00010000 619#define METEOR_RGB24 0x00020000 620#define METEOR_YUV_PACKED 0x00040000 621#define METEOR_YUV_PLANAR 0x00080000 622#define METEOR_WANT_EVEN 0x00100000 /* want even frame */ 623#define METEOR_WANT_ODD 0x00200000 /* want odd frame */ 624#define METEOR_WANT_MASK 0x00300000 625#define METEOR_ONLY_EVEN_FIELDS 0x01000000 626#define METEOR_ONLY_ODD_FIELDS 0x02000000 627#define METEOR_ONLY_FIELDS_MASK 0x03000000 628#define METEOR_YUV_422 0x04000000 629#define METEOR_OUTPUT_FMT_MASK 0x040f0000 630#define METEOR_WANT_TS 0x08000000 /* time-stamp a frame */ 631#define METEOR_RGB 0x20000000 /* meteor rgb unit */ 632#define METEOR_FIELD_MODE 0x80000000 633 u_char tflags; /* Tuner flags (/dev/tuner) */ 634#define TUNER_INITALIZED 0x00000001 635#define TUNER_OPEN 0x00000002 636 u_char vbiflags; /* VBI flags (/dev/vbi) */ 637#define VBI_INITALIZED 0x00000001 638#define VBI_OPEN 0x00000002 639#define VBI_CAPTURE 0x00000004 640 u_short fps; /* frames per second */ 641 struct meteor_video video; 642 struct TVTUNER tuner; 643 struct CARDTYPE card; 644 u_char audio_mux_select; /* current mode of the audio */ 645 u_char audio_mute_state; /* mute state of the audio */ 646 u_char format_params; 647 u_long current_sol; 648 u_long current_col; 649 int clip_start; 650 int line_length; 651 int last_y; 652 int y; 653 int y2; 654 int yclip; 655 int yclip2; 656 int max_clip_node; 657 bktr_clip_t clip_list[100]; 658 int reverse_mute; /* Swap the GPIO values for Mute and TV Audio */ 659 int bt848_tuner; 660 int bt848_card; 661 u_long id; 662#define BT848_USE_XTALS 0 663#define BT848_USE_PLL 1 664 int xtal_pll_mode; /* Use XTAL or PLL mode for PAL/SECAM */ 665 int remote_control; /* remote control detected */ 666 int remote_control_addr; /* remote control i2c address */ 667 char msp_version_string[9]; /* MSP version string 34xxx-xx */ 668 int msp_addr; /* MSP i2c address */ 669 char dpl_version_string[9]; /* DPL version string 35xxx-xx */ 670 int dpl_addr; /* DPL i2c address */ 671 int slow_msp_audio; /* 0 = use fast MSP3410/3415 programming sequence */ 672 /* 1 = use slow MSP3410/3415 programming sequence */ 673 674}; 675 676typedef struct bktr_softc bktr_reg_t; 677typedef struct bktr_softc* bktr_ptr_t; 678 679#define Bt848_MAX_SIGN 16 680 681struct bt848_card_sig { 682 int card; 683 int tuner; 684 u_char signature[Bt848_MAX_SIGN]; 685}; 686 687 688/***********************************************************/ 689/* ioctl_cmd_t int on old versions, u_long on new versions */ 690/***********************************************************/ 691 692#if (__FreeBSD__ == 2) 693typedef int ioctl_cmd_t; 694#endif 695 696#if defined(__FreeBSD__) 697#if (__FreeBSD_version >= 300000) 698typedef u_long ioctl_cmd_t; 699#endif 700#endif 701 702#if defined(__NetBSD__) || defined(__OpenBSD__) 703typedef u_long ioctl_cmd_t; 704#endif 705 706 707