📄 brooktree848.c
字号:
#ifdef __bsdi__#include <sys/device.h>#include <i386/isa/isa.h>#include <i386/isa/isavar.h>#include <i386/isa/icu.h>#include <i386/pci/pci.h>#include <i386/isa/dma.h>#include <i386/eisa/eisa.h>#include "ioctl_meteor.h"#include "ioctl_bt848.h"#include "bt848_reg.h"typedef u_long ioctl_cmd_t;#define pci_conf_read(a, r) pci_inl(a, r)#define pci_conf_write(a, r, v) pci_outl(a, r, v)#include <sys/reboot.h>#define bootverbose (autoprint & (AC_VERBOSE|AC_DEBUG))#endif /* __bsdi__ */typedef u_char bool_t;#define BKTRPRI (PZERO+8)|PCATCHstatic void bktr_intr __P((void *arg));/* * memory allocated for DMA programs */#define DMA_PROG_ALLOC (8 * PAGE_SIZE)/* When to split a dma transfer , the bt848 has timing as well as dma transfer size limitations so that we have to split dma transfers into two dma requests */#define DMA_BT848_SPLIT 319*2/* * Allocate enough memory for: * 768x576 RGB 16 or YUV (16 storage bits/pixel) = 884736 = 216 pages * * You may override this using the options "BROOKTREE_ALLOC_PAGES=value" * in your kernel configuration file. */#ifndef BROOKTREE_ALLOC_PAGES#define BROOKTREE_ALLOC_PAGES 217*4#endif#define BROOKTREE_ALLOC (BROOKTREE_ALLOC_PAGES * PAGE_SIZE)/* Defines for fields */#define ODD_F 0x01#define EVEN_F 0x02#ifdef __FreeBSD__static bktr_reg_t brooktree[ NBKTR ];#define BROOKTRE_NUM(mtr) ((bktr - &brooktree[0])/sizeof(bktr_reg_t))#define UNIT(x) ((x) & 0x0f)#define MINOR(x) ((x >> 4) & 0x0f)#define ATTACH_ARGS pcici_t tag, int unitstatic const char* bktr_probe( pcici_t tag, pcidi_t type );static void bktr_attach( ATTACH_ARGS );static u_long bktr_count;static struct pci_device bktr_device = { "bktr", bktr_probe, bktr_attach, &bktr_count};#ifdef COMPAT_PCI_DRIVERCOMPAT_PCI_DRIVER (bktr, bktr_device);#elseDATA_SET (pcidevice_set, bktr_device);#endif /* COMPAT_PCI_DRIVER */static d_open_t bktr_open;static d_close_t bktr_close;static d_read_t bktr_read;static d_write_t bktr_write;static d_ioctl_t bktr_ioctl;static d_mmap_t bktr_mmap;#define CDEV_MAJOR 92 static struct cdevsw bktr_cdevsw = { bktr_open, bktr_close, bktr_read, bktr_write, bktr_ioctl, nostop, nullreset, nodevtotty, seltrue, bktr_mmap, NULL, "bktr", NULL, -1};#endif /* __FreeBSD__ */#ifdef __bsdi__#define UNIT dv_unit#define MINOR dv_subunit#define ATTACH_ARGS \ struct device * const parent, struct device * const self, void * const aux#define PCI_COMMAND_STATUS_REG PCI_COMMANDstatic void bktr_attach( ATTACH_ARGS );#define NBKTR bktrcd.cd_ndevs#define brooktree *((bktr_ptr_t *)bktrcd.cd_devs)static int bktr_spl;static int bktr_intr_returning_1(void *arg) { bktr_intr(arg); return (1);}#define disable_intr() { bktr_spl = splhigh(); }#define enable_intr() { splx(bktr_spl); }static intbktr_pci_match(pci_devaddr_t *pa){ unsigned id; id = pci_inl(pa, PCI_VENDOR_ID); switch (id) { BROOKTREE_848_PCI_ID: BROOKTREE_849_PCI_ID: BROOKTREE_878_PCI_ID: BROOKTREE_879_PCI_ID: return 1; } aprint_debug("bktr_pci_match got %x\n", id); return 0;}pci_devres_t bktr_res; /* XXX only remembers last one, helps debug */static intbktr_probe(struct device *parent, struct cfdata *cf, void *aux){ pci_devaddr_t *pa; pci_devres_t res; struct isa_attach_args *ia = aux; if (ia->ia_bustype != BUS_PCI) return (0); if ((pa = pci_scan(bktr_pci_match)) == NULL) return (0); pci_getres(pa, &bktr_res, 1, ia); if (ia->ia_maddr == 0) { printf("bktr%d: no mem attached\n", cf->cf_unit); return (0); } ia->ia_aux = pa; return 1;}struct cfdriver bktrcd = { 0, "bktr", bktr_probe, bktr_attach, DV_DULL, sizeof(bktr_reg_t) };int bktr_open __P((dev_t, int, int, struct proc *));int bktr_close __P((dev_t, int, int, struct proc *));int bktr_read __P((dev_t, struct uio *, int));int bktr_write __P((dev_t, struct uio *, int));int bktr_ioctl __P((dev_t, ioctl_cmd_t, caddr_t, int, struct proc *));int bktr_mmap __P((dev_t, int, int));struct devsw bktrsw = { &bktrcd, bktr_open, bktr_close, bktr_read, bktr_write, bktr_ioctl, seltrue, bktr_mmap, NULL, nodump, NULL, 0, nostop};#endif /* __bsdi__ *//* * This is for start-up convenience only, NOT mandatory. */#if !defined( DEFAULT_CHNLSET )#define DEFAULT_CHNLSET CHNLSET_WEUROPE#endif/* * Parameters describing size of transmitted image. */static struct format_params format_params[] = {/* # define BT848_IFORM_F_AUTO (0x0) - don't matter. */ { 525, 26, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_AUTO },/* # define BT848_IFORM_F_NTSCM (0x1) */ { 525, 26, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 },/* # define BT848_IFORM_F_NTSCJ (0x2) */ { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 },/* # define BT848_IFORM_F_PALBDGHI (0x3) */ { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT1 },/* # define BT848_IFORM_F_PALM (0x4) */ { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 },/*{ 625, 32, 576, 910, 186, 922, 640, 780, 25, 0x68, 0x5d, BT848_IFORM_X_XT0 }, *//* # define BT848_IFORM_F_PALN (0x5) */ { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT1 },/* # define BT848_IFORM_F_SECAM (0x6) */ { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0xa0, BT848_IFORM_X_XT1 }, /* # define BT848_IFORM_F_RSVD (0x7) - ???? */ { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT0 },};/* * Table of supported Pixel Formats */static struct meteor_pixfmt_internal { struct meteor_pixfmt public; u_int color_fmt;} pixfmt_table[] = {{ { 0, METEOR_PIXTYPE_RGB, 2, { 0x7c00, 0x03e0, 0x001f }, 0,0 }, 0x33 },{ { 0, METEOR_PIXTYPE_RGB, 2, { 0x7c00, 0x03e0, 0x001f }, 1,0 }, 0x33 },{ { 0, METEOR_PIXTYPE_RGB, 2, { 0xf800, 0x07e0, 0x001f }, 0,0 }, 0x22 },{ { 0, METEOR_PIXTYPE_RGB, 2, { 0xf800, 0x07e0, 0x001f }, 1,0 }, 0x22 },{ { 0, METEOR_PIXTYPE_RGB, 3, { 0xff0000,0x00ff00,0x0000ff }, 1,0 }, 0x11 },{ { 0, METEOR_PIXTYPE_RGB, 4, { 0xff0000,0x00ff00,0x0000ff }, 0,0 }, 0x00 },{ { 0, METEOR_PIXTYPE_RGB, 4, { 0xff0000,0x00ff00,0x0000ff }, 0,1 }, 0x00 },{ { 0, METEOR_PIXTYPE_RGB, 4, { 0xff0000,0x00ff00,0x0000ff }, 1,0 }, 0x00 },{ { 0, METEOR_PIXTYPE_RGB, 4, { 0xff0000,0x00ff00,0x0000ff }, 1,1 }, 0x00 },{ { 0, METEOR_PIXTYPE_YUV, 2, { 0xff0000,0x00ff00,0x0000ff }, 1,1 }, 0x88 },{ { 0, METEOR_PIXTYPE_YUV_PACKED, 2, { 0xff0000,0x00ff00,0x0000ff }, 0,1 }, 0x44 },{ { 0, METEOR_PIXTYPE_YUV_12, 2, { 0xff0000,0x00ff00,0x0000ff }, 1,1 }, 0x88 },};#define PIXFMT_TABLE_SIZE ( sizeof(pixfmt_table) / sizeof(pixfmt_table[0]) )/* * Table of Meteor-supported Pixel Formats (for SETGEO compatibility) *//* FIXME: Also add YUV_422 and YUV_PACKED as well */static struct { u_long meteor_format; struct meteor_pixfmt public;} meteor_pixfmt_table[] = { { METEOR_GEO_YUV_12, { 0, METEOR_PIXTYPE_YUV_12, 2, { 0xff0000,0x00ff00,0x0000ff }, 1,1 } }, /* FIXME: Should byte swap flag be on for this one; negative in drvr? */ { METEOR_GEO_YUV_422, { 0, METEOR_PIXTYPE_YUV, 2, { 0xff0000,0x00ff00,0x0000ff }, 1,1 } }, { METEOR_GEO_YUV_PACKED, { 0, METEOR_PIXTYPE_YUV_PACKED, 2, { 0xff0000,0x00ff00,0x0000ff }, 0,1 } }, { METEOR_GEO_RGB16, { 0, METEOR_PIXTYPE_RGB, 2, { 0x7c00, 0x03e0, 0x001f }, 0, 0 } }, { METEOR_GEO_RGB24, { 0, METEOR_PIXTYPE_RGB, 4, { 0xff0000, 0x00ff00, 0x0000ff }, 0, 0 } },};#define METEOR_PIXFMT_TABLE_SIZE ( sizeof(meteor_pixfmt_table) / \ sizeof(meteor_pixfmt_table[0]) )#define BSWAP (BT848_COLOR_CTL_BSWAP_ODD | BT848_COLOR_CTL_BSWAP_EVEN)#define WSWAP (BT848_COLOR_CTL_WSWAP_ODD | BT848_COLOR_CTL_WSWAP_EVEN)/* experimental code for Automatic Frequency Control */#define TUNER_AFC#define TEST_TUNER_AFC_NOT#if defined( TUNER_AFC )#define AFC_DELAY 10000 /* 10 millisend delay */#define AFC_BITS 0x07#define AFC_FREQ_MINUS_125 0x00#define AFC_FREQ_MINUS_62 0x01#define AFC_FREQ_CENTERED 0x02#define AFC_FREQ_PLUS_62 0x03#define AFC_FREQ_PLUS_125 0x04#define AFC_MAX_STEP (5 * FREQFACTOR) /* no more than 5 MHz */#endif /* TUNER_AFC *//* * i2c things: */#define TSA552x_CB_MSB (0x80)#define TSA552x_CB_CP (1<<6)#define TSA552x_CB_T2 (1<<5)#define TSA552x_CB_T1 (1<<4)#define TSA552x_CB_T0 (1<<3)#define TSA552x_CB_RSA (1<<2)#define TSA552x_CB_RSB (1<<1)#define TSA552x_CB_OS (1<<0)#define TSA552x_RADIO (TSA552x_CB_MSB | \ TSA552x_CB_T0)/* Add RADIO_OFFSET to the "frequency" to indicate that we want to tune *//* the radio (if present) not the TV tuner. *//* 20000 is equivalent to 20000MHz/16 = 1.25GHz - this area is unused. */#define RADIO_OFFSET 20000/* address(s) of the Hauppauge Infra-Red Remote Control adapter */#define HAUP_REMOTE_INT_WADDR 0x30#define HAUP_REMOTE_INT_RADDR 0x31 #define HAUP_REMOTE_EXT_WADDR 0x34#define HAUP_REMOTE_EXT_RADDR 0x35/* address of BTSC/SAP decoder chip */#define TDA9850_WADDR 0xb6#define TDA9850_RADDR 0xb7/* address of MSP3400C chip */#define MSP3400C_WADDR 0x80#define MSP3400C_RADDR 0x81/* EEProm (128 * 8) on an STB card */#define X24C01_WADDR 0xae#define X24C01_RADDR 0xaf/* EEProm (256 * 8) on a Hauppauge card *//* and on most BT878s cards to store the sub-system vendor id */#define PFC8582_WADDR 0xa0#define PFC8582_RADDR 0xa1/* registers in the BTSC/dbx chip */#define CON1ADDR 0x04#define CON2ADDR 0x05#define CON3ADDR 0x06#define CON4ADDR 0x07/* raise the charge pump voltage for fast tuning */#define TSA552x_FCONTROL (TSA552x_CB_MSB | \ TSA552x_CB_CP | \ TSA552x_CB_T0 | \ TSA552x_CB_RSA | \ TSA552x_CB_RSB)/* lower the charge pump voltage for better residual oscillator FM */#define TSA552x_SCONTROL (TSA552x_CB_MSB | \ TSA552x_CB_T0 | \ TSA552x_CB_RSA | \ TSA552x_CB_RSB)/* The control value for the ALPS TSCH5 Tuner */#define TSCH5_FCONTROL 0x82/* sync detect threshold */#if 0#define SYNC_LEVEL (BT848_ADC_RESERVED | \ BT848_ADC_CRUSH) /* threshold ~125 mV */#else#define SYNC_LEVEL (BT848_ADC_RESERVED | \ BT848_ADC_SYNC_T) /* threshold ~75 mV */#endif/* the GPIO bits that control the audio MUXes */#define GPIO_AUDIOMUX_BITS 0x0f/* * the data for each type of tuner * * if probeCard() fails to detect the proper tuner on boot you can * override it by setting the following define to the tuner present: *#define OVERRIDE_TUNER <tuner type> * * where <tuner type> is one of the following tuner defines. *//* indexes into tuners[] */#define NO_TUNER 0#define TEMIC_NTSC 1#define TEMIC_PAL 2#define TEMIC_SECAM 3#define PHILIPS_NTSC 4#define PHILIPS_PAL 5#define PHILIPS_SECAM 6#define TEMIC_PALI 7#define PHILIPS_PALI 8#define PHILIPS_FR1236_NTSC 9#define PHILIPS_FR1216_PAL 10#define PHILIPS_FR1236_SECAM 11#define ALPS_TSCH5 12#define Bt848_MAX_TUNER 13/* XXX FIXME: this list is incomplete *//* input types */#define TTYPE_XXX 0#define TTYPE_NTSC 1#define TTYPE_NTSC_J 2#define TTYPE_PAL 3#define TTYPE_PAL_M 4#define TTYPE_PAL_N 5#define TTYPE_SECAM 6/**struct TUNER { char* name; u_char type; u_char pllControl; u_char bandLimits[ 2 ]; u_char bandAddrs[ 3 ];}; */static const struct TUNER tuners[] = {/* XXX FIXME: fill in the band-switch crosspoints */ /* NO_TUNER */ { "<none>", /* the 'name' */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -