bktr_core.c (50548) | bktr_core.c (50693) |
---|---|
1/* $FreeBSD: head/sys/dev/bktr/bktr_core.c 50548 1999-08-29 09:03:58Z bde $ */ | 1/* $Id: brooktree848.c,v 1.85 1999/06/12 14:54:54 roger Exp $ */ |
2/* BT848 Driver for Brooktree's Bt848, Bt848A, Bt849A, Bt878, Bt879 based cards. 3 The Brooktree BT848 Driver driver is based upon Mark Tinguely and 4 Jim Lowe's driver for the Matrox Meteor PCI card . The 5 Philips SAA 7116 and SAA 7196 are very different chipsets than 6 the BT848. For starters, the BT848 is a one chipset solution and 7 it incorporates a RISC engine to control the DMA transfers -- 8 that is it the actual dma process is control by a program which 9 resides in the hosts memory also the register definitions between --- 424 unchanged lines hidden (view full) --- 434 Make the driver compile on FreeBSD 2.2.x systems again. 435 Change number of VBI lines from 16 to 12 for NTSC formats. 436 Changes to probeCard() for better eeprom identification. 437 Added STB Bt878 card identification. 438 Add Hauppauge model identification to probeCard(). 439 Added TDA9850 initialisation code taken from Linux bttv. 440 Juha.Nurmela@quicknet.inet.fi found/fixed bug in VBI_SLEEP. 441 Matt Brown <matt@dqc.org> added MSP3430G DBX initialisation. | 2/* BT848 Driver for Brooktree's Bt848, Bt848A, Bt849A, Bt878, Bt879 based cards. 3 The Brooktree BT848 Driver driver is based upon Mark Tinguely and 4 Jim Lowe's driver for the Matrox Meteor PCI card . The 5 Philips SAA 7116 and SAA 7196 are very different chipsets than 6 the BT848. For starters, the BT848 is a one chipset solution and 7 it incorporates a RISC engine to control the DMA transfers -- 8 that is it the actual dma process is control by a program which 9 resides in the hosts memory also the register definitions between --- 424 unchanged lines hidden (view full) --- 434 Make the driver compile on FreeBSD 2.2.x systems again. 435 Change number of VBI lines from 16 to 12 for NTSC formats. 436 Changes to probeCard() for better eeprom identification. 437 Added STB Bt878 card identification. 438 Add Hauppauge model identification to probeCard(). 439 Added TDA9850 initialisation code taken from Linux bttv. 440 Juha.Nurmela@quicknet.inet.fi found/fixed bug in VBI_SLEEP. 441 Matt Brown <matt@dqc.org> added MSP3430G DBX initialisation. |
442 4431.71 30 Aug 1999 Roger Hardiman <roger@freebsd.org> 444 Small cleanup of OS dependant code. Remove NPCI usage. 445 Fix bug in AVerMedia detection. 446 Update VBI support for the AleVT Teletext package. Parts 447 from Juha Nurmela's driver <Juha.Nurmela@quicknet.inet.fi> 448 Add support for Hauppauge 627 and Temic 4006 submitted 449 by Maurice Castro <maurice@atum.castro.aus.net> 450 Tom Jansen <tom@unhooked.net> added BSDi support again. 451 |
|
442*/ 443 444#ifdef __FreeBSD__ 445#include "bktr.h" 446#include "opt_bktr.h" | 452*/ 453 454#ifdef __FreeBSD__ 455#include "bktr.h" 456#include "opt_bktr.h" |
447#include "pci.h" | 457#include "opt_devfs.h" |
448#endif /* __FreeBSD__ */ 449 450#if defined(__NetBSD__) || defined(__OpenBSD__) 451#include "bktr.h" 452#include "pci.h" 453#endif /* __NetBSD__ || __OpenBSD__ */ 454 455#if ( \ | 458#endif /* __FreeBSD__ */ 459 460#if defined(__NetBSD__) || defined(__OpenBSD__) 461#include "bktr.h" 462#include "pci.h" 463#endif /* __NetBSD__ || __OpenBSD__ */ 464 465#if ( \ |
456 ( (defined(__FreeBSD__)) && (NBKTR > 0) && (NPCI > 0) ) \ | 466 (defined(__FreeBSD__) && (NBKTR > 0)) \ |
457 || (defined(__bsdi__)) \ 458 || (defined(__OpenBSD__)) \ 459 || (defined(__NetBSD__)) \ 460 ) 461 462#include <sys/param.h> 463#include <sys/systm.h> 464#include <sys/conf.h> 465#include <sys/uio.h> 466#include <sys/kernel.h> 467#include <sys/signalvar.h> 468#include <sys/mman.h> | 467 || (defined(__bsdi__)) \ 468 || (defined(__OpenBSD__)) \ 469 || (defined(__NetBSD__)) \ 470 ) 471 472#include <sys/param.h> 473#include <sys/systm.h> 474#include <sys/conf.h> 475#include <sys/uio.h> 476#include <sys/kernel.h> 477#include <sys/signalvar.h> 478#include <sys/mman.h> |
479#include <sys/poll.h> 480#include <sys/select.h> 481#include <sys/vnode.h> |
|
469 470#include <vm/vm.h> 471#include <vm/vm_kern.h> 472#include <vm/pmap.h> 473#include <vm/vm_extern.h> 474 475/*******************/ 476/* *** FreeBSD *** */ 477/*******************/ 478#ifdef __FreeBSD__ 479 480/* Read NSMBUS on FreeBSD 3.1 or later */ 481#if (__FreeBSD_version >= 310000) | 482 483#include <vm/vm.h> 484#include <vm/vm_kern.h> 485#include <vm/pmap.h> 486#include <vm/vm_extern.h> 487 488/*******************/ 489/* *** FreeBSD *** */ 490/*******************/ 491#ifdef __FreeBSD__ 492 493/* Read NSMBUS on FreeBSD 3.1 or later */ 494#if (__FreeBSD_version >= 310000) |
482 #include "smbus.h" | 495#include "smbus.h" |
483#else | 496#else |
484 #define NSMBUS 0 | 497#define NSMBUS 0 |
485#endif 486 | 498#endif 499 |
500#if (__FreeBSD_version < 400000) 501#ifdef DEVFS 502#include <sys/devfsext.h> 503#endif /* DEVFS */ 504#endif 505 |
|
487#if (__FreeBSD_version >=400000) || (NSMBUS > 0) | 506#if (__FreeBSD_version >=400000) || (NSMBUS > 0) |
488 #include <sys/bus.h> /* used by smbus and newbus */ | 507#include |
489#endif 490 491#if (__FreeBSD_version >=400000) | 508#endif 509 510#if (__FreeBSD_version >=400000) |
492 #include <machine/bus.h> /* used by newbus */ 493 #include <sys/rman.h> /* used by newbus */ 494 #include <machine/resource.h> /* used by newbus */ | 511#include 512#include 513#include |
495#endif 496 497#include <machine/clock.h> /* for DELAY */ 498#include <pci/pcivar.h> 499#include <pci/pcireg.h> 500 501#include <machine/ioctl_meteor.h> 502#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */ 503#include <pci/brktree_reg.h> 504 505#if (NSMBUS > 0) | 514#endif 515 516#include <machine/clock.h> /* for DELAY */ 517#include <pci/pcivar.h> 518#include <pci/pcireg.h> 519 520#include <machine/ioctl_meteor.h> 521#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */ 522#include <pci/brktree_reg.h> 523 524#if (NSMBUS > 0) |
506 #include <pci/bt848_i2c.h> 507 #include <dev/smbus/smbconf.h> 508 #include <dev/iicbus/iiconf.h> 509 #include "smbus_if.h" 510 #include "iicbus_if.h" | 525#include 526#include 527#include 528#include "smbus_if.h" 529#include "iicbus_if.h" |
511#endif 512 513#include <sys/sysctl.h> 514static int bt848_card = -1; 515static int bt848_tuner = -1; 516static int bt848_reverse_mute = -1; 517static int bt848_format = -1; 518 519SYSCTL_NODE(_hw, OID_AUTO, bt848, CTLFLAG_RW, 0, "Bt848 Driver mgmt"); 520SYSCTL_INT(_hw_bt848, OID_AUTO, card, CTLFLAG_RW, &bt848_card, -1, ""); 521SYSCTL_INT(_hw_bt848, OID_AUTO, tuner, CTLFLAG_RW, &bt848_tuner, -1, ""); 522SYSCTL_INT(_hw_bt848, OID_AUTO, reverse_mute, CTLFLAG_RW, &bt848_reverse_mute, -1, ""); 523SYSCTL_INT(_hw_bt848, OID_AUTO, format, CTLFLAG_RW, &bt848_format, -1, ""); 524 525#if (__FreeBSD_version >= 300000) 526 typedef u_long ioctl_cmd_t; 527#endif 528 529#if (__FreeBSD__ == 2) | 530#endif 531 532#include <sys/sysctl.h> 533static int bt848_card = -1; 534static int bt848_tuner = -1; 535static int bt848_reverse_mute = -1; 536static int bt848_format = -1; 537 538SYSCTL_NODE(_hw, OID_AUTO, bt848, CTLFLAG_RW, 0, "Bt848 Driver mgmt"); 539SYSCTL_INT(_hw_bt848, OID_AUTO, card, CTLFLAG_RW, &bt848_card, -1, ""); 540SYSCTL_INT(_hw_bt848, OID_AUTO, tuner, CTLFLAG_RW, &bt848_tuner, -1, ""); 541SYSCTL_INT(_hw_bt848, OID_AUTO, reverse_mute, CTLFLAG_RW, &bt848_reverse_mute, -1, ""); 542SYSCTL_INT(_hw_bt848, OID_AUTO, format, CTLFLAG_RW, &bt848_format, -1, ""); 543 544#if (__FreeBSD_version >= 300000) 545 typedef u_long ioctl_cmd_t; 546#endif 547 548#if (__FreeBSD__ == 2) |
530 typedef int ioctl_cmd_t; 531 typedef unsigned int uintptr_t; 532 #define PCIR_REVID PCI_CLASS_REG | 549typedef int ioctl_cmd_t; 550typedef unsigned int uintptr_t; 551#define PCIR_REVID PCI_CLASS_REG |
533#endif 534#endif /* __FreeBSD__ */ 535 536 | 552#endif 553#endif /* __FreeBSD__ */ 554 555 |
556/****************/ 557/* *** BSDI *** */ 558/****************/ 559#ifdef __bsdi__ 560#endif /* __bsdi__ */ 561 562 563/**************************/ 564/* *** OpenBSD/NetBSD *** */ 565/**************************/ 566#if defined(__NetBSD__) || defined(__OpenBSD__) 567#endif /* __NetBSD__ || __OpenBSD__ */ 568 569 570 |
|
537typedef u_char bool_t; 538 539#define BKTRPRI (PZERO+8)|PCATCH | 571typedef u_char bool_t; 572 573#define BKTRPRI (PZERO+8)|PCATCH |
574#define VBIPRI (PZERO-4)|PCATCH |
|
540 541 542/* 543 * memory allocated for DMA programs 544 */ 545#define DMA_PROG_ALLOC (8 * PAGE_SIZE) 546 547/* When to split a dma transfer , the bt848 has timing as well as --- 382 unchanged lines hidden (view full) --- 930 TTYPE_PAL, /* input type */ 931 { TSA552x_SCONTROL, /* control byte for Tuner PLL */ 932 TSA552x_SCONTROL, 933 TSA552x_SCONTROL, 934 0x00 }, 935 { 0x00, 0x00 }, /* band-switch crosspoints */ 936 { 0x02, 0x04, 0x01,0x00 } }, /* the band-switch values */ 937 | 575 576 577/* 578 * memory allocated for DMA programs 579 */ 580#define DMA_PROG_ALLOC (8 * PAGE_SIZE) 581 582/* When to split a dma transfer , the bt848 has timing as well as --- 382 unchanged lines hidden (view full) --- 965 TTYPE_PAL, /* input type */ 966 { TSA552x_SCONTROL, /* control byte for Tuner PLL */ 967 TSA552x_SCONTROL, 968 TSA552x_SCONTROL, 969 0x00 }, 970 { 0x00, 0x00 }, /* band-switch crosspoints */ 971 { 0x02, 0x04, 0x01,0x00 } }, /* the band-switch values */ 972 |
938 /* PHILIPS_PAL */ | 973 /* PHILIPS_PALI */ |
939 { "Philips PAL I", /* the 'name' */ 940 TTYPE_PAL, /* input type */ 941 { TSA552x_SCONTROL, /* control byte for Tuner PLL */ 942 TSA552x_SCONTROL, 943 TSA552x_SCONTROL, 944 0x00 }, 945 { 0x00, 0x00 }, /* band-switch crosspoints */ 946 { 0xa0, 0x90, 0x30,0x00 } }, /* the band-switch values */ --- 262 unchanged lines hidden (view full) --- 1209#define TDEC_BITS (BT848_INT_FDSR | BT848_INT_FBUS) 1210 1211 1212/* 1213 * misc. support routines. 1214 */ 1215static int signCard( bktr_ptr_t bktr, int offset, 1216 int count, u_char* sig ); | 974 { "Philips PAL I", /* the 'name' */ 975 TTYPE_PAL, /* input type */ 976 { TSA552x_SCONTROL, /* control byte for Tuner PLL */ 977 TSA552x_SCONTROL, 978 TSA552x_SCONTROL, 979 0x00 }, 980 { 0x00, 0x00 }, /* band-switch crosspoints */ 981 { 0xa0, 0x90, 0x30,0x00 } }, /* the band-switch values */ --- 262 unchanged lines hidden (view full) --- 1244#define TDEC_BITS (BT848_INT_FDSR | BT848_INT_FBUS) 1245 1246 1247/* 1248 * misc. support routines. 1249 */ 1250static int signCard( bktr_ptr_t bktr, int offset, 1251 int count, u_char* sig ); |
1217static void probeCard( bktr_ptr_t bktr, int verbose ); | 1252static void probeCard( bktr_ptr_t bktr, int verbose, int unit); |
1218 1219static void common_bktr_attach( bktr_ptr_t bktr, int unit, 1220 u_long pci_id, u_int rev ); 1221 1222/**************************************************/ 1223/* *** Memory Allocation is still OS specific *** */ 1224/**************************************************/ 1225#if (defined(__FreeBSD__) || defined(__bsdi__)) --- 62 unchanged lines hidden (view full) --- 1288static int do_afc( bktr_ptr_t bktr, int addr, int frequency ); 1289#endif /* TUNER_AFC */ 1290 1291/* 1292 * vbi specific functions. 1293 */ 1294static int vbi_open( bktr_ptr_t bktr ); 1295static int vbi_close( bktr_ptr_t bktr ); | 1253 1254static void common_bktr_attach( bktr_ptr_t bktr, int unit, 1255 u_long pci_id, u_int rev ); 1256 1257/**************************************************/ 1258/* *** Memory Allocation is still OS specific *** */ 1259/**************************************************/ 1260#if (defined(__FreeBSD__) || defined(__bsdi__)) --- 62 unchanged lines hidden (view full) --- 1323static int do_afc( bktr_ptr_t bktr, int addr, int frequency ); 1324#endif /* TUNER_AFC */ 1325 1326/* 1327 * vbi specific functions. 1328 */ 1329static int vbi_open( bktr_ptr_t bktr ); 1330static int vbi_close( bktr_ptr_t bktr ); |
1296static int vbi_read( bktr_ptr_t bktr, dev_t dev, struct uio *uio ); | 1331static int vbi_read( bktr_ptr_t bktr, struct uio *uio, int ioflag ); |
1297 1298/* 1299 * audio specific functions. 1300 */ 1301static int set_audio( bktr_ptr_t bktr, int mode ); 1302static void temp_mute( bktr_ptr_t bktr, int flag ); 1303 1304static void init_BTSC( bktr_ptr_t bktr ); 1305static int set_BTSC( bktr_ptr_t bktr, int control ); 1306 1307static void msp_autodetect( bktr_ptr_t bktr ); | 1332 1333/* 1334 * audio specific functions. 1335 */ 1336static int set_audio( bktr_ptr_t bktr, int mode ); 1337static void temp_mute( bktr_ptr_t bktr, int flag ); 1338 1339static void init_BTSC( bktr_ptr_t bktr ); 1340static int set_BTSC( bktr_ptr_t bktr, int control ); 1341 1342static void msp_autodetect( bktr_ptr_t bktr ); |
1308static void msp_read_id( bktr_ptr_t bktr ); | 1343static void msp_read_id( bktr_ptr_t bktr, int unit ); |
1309static void msp_reset( bktr_ptr_t bktr ); 1310static unsigned int msp_read(bktr_ptr_t bktr, unsigned char dev, 1311 unsigned int addr); 1312static void msp_write( bktr_ptr_t bktr, unsigned char dev, 1313 unsigned int addr, unsigned int data); 1314 1315/* 1316 * Remote Control Functions --- 32 unchanged lines hidden (view full) --- 1349 * CARD_GV_BCTV specific functions. 1350 */ 1351static void set_bctv_audio( bktr_ptr_t bktr ); 1352static void bctv_gpio_write( bktr_ptr_t bktr, int port, int val ); 1353/*static int bctv_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */ 1354 1355 1356/* | 1344static void msp_reset( bktr_ptr_t bktr ); 1345static unsigned int msp_read(bktr_ptr_t bktr, unsigned char dev, 1346 unsigned int addr); 1347static void msp_write( bktr_ptr_t bktr, unsigned char dev, 1348 unsigned int addr, unsigned int data); 1349 1350/* 1351 * Remote Control Functions --- 32 unchanged lines hidden (view full) --- 1384 * CARD_GV_BCTV specific functions. 1385 */ 1386static void set_bctv_audio( bktr_ptr_t bktr ); 1387static void bctv_gpio_write( bktr_ptr_t bktr, int port, int val ); 1388/*static int bctv_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */ 1389 1390 1391/* |
1357 * the common attarch code, used by all OS versions. | 1392 * the common attach code, used by all OS versions. |
1358 */ 1359static void 1360common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev ) 1361{ 1362 bt848_ptr_t bt848; 1363 vm_offset_t buf; 1364 1365 bt848 = bktr->base; 1366 1367/***************************************/ 1368/* *** OS Specific memory routines *** */ 1369/***************************************/ 1370#if defined(__NetBSD__) || defined(__OpenBSD__) 1371 /* allocate space for dma program */ | 1393 */ 1394static void 1395common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev ) 1396{ 1397 bt848_ptr_t bt848; 1398 vm_offset_t buf; 1399 1400 bt848 = bktr->base; 1401 1402/***************************************/ 1403/* *** OS Specific memory routines *** */ 1404/***************************************/ 1405#if defined(__NetBSD__) || defined(__OpenBSD__) 1406 /* allocate space for dma program */ |
1372 bktr->dmat = pa->pa_dmat; | |
1373 bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, DMA_PROG_ALLOC); 1374 bktr->odd_dma_prog = get_bktr_mem(bktr, &bktr->dm_oprog, DMA_PROG_ALLOC) 1375; 1376 /* allocte space for the VBI buffer */ | 1407 bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, DMA_PROG_ALLOC); 1408 bktr->odd_dma_prog = get_bktr_mem(bktr, &bktr->dm_oprog, DMA_PROG_ALLOC) 1409; 1410 /* allocte space for the VBI buffer */ |
1377 bktr->vbidata = get_bktr_mem(bktr, &bktr->vbidata, VBI_DATA_SIZE); 1378 bktr->vbibuffer = get_bktr_mem(bktr, &bktr->vbibuffer, VBI_BUFFER_SIZE); | 1411 bktr->vbidata = get_bktr_mem(bktr, &bktr->dm_vbidata, VBI_DATA_SIZE); 1412 bktr->vbibuffer = get_bktr_mem(bktr, &bktr->dm_vbibuffer, VBI_BUFFER_SIZE); |
1379 1380 /* allocate space for pixel buffer */ 1381 if ( BROOKTREE_ALLOC ) 1382 buf = get_bktr_mem(bktr, &bktr->dm_mem, BROOKTREE_ALLOC); 1383 else 1384 buf = 0; 1385#endif 1386 --- 70 unchanged lines hidden (view full) --- 1457 bktr->tuner.channel = 0; 1458 bktr->tuner.chnlset = DEFAULT_CHNLSET; 1459 bktr->audio_mux_select = 0; 1460 bktr->audio_mute_state = FALSE; 1461 bktr->bt848_card = -1; 1462 bktr->bt848_tuner = -1; 1463 bktr->reverse_mute = -1; 1464 | 1413 1414 /* allocate space for pixel buffer */ 1415 if ( BROOKTREE_ALLOC ) 1416 buf = get_bktr_mem(bktr, &bktr->dm_mem, BROOKTREE_ALLOC); 1417 else 1418 buf = 0; 1419#endif 1420 --- 70 unchanged lines hidden (view full) --- 1491 bktr->tuner.channel = 0; 1492 bktr->tuner.chnlset = DEFAULT_CHNLSET; 1493 bktr->audio_mux_select = 0; 1494 bktr->audio_mute_state = FALSE; 1495 bktr->bt848_card = -1; 1496 bktr->bt848_tuner = -1; 1497 bktr->reverse_mute = -1; 1498 |
1465 probeCard( bktr, TRUE ); | 1499 probeCard( bktr, TRUE, unit ); |
1466 1467 /* If there is an MSP Audio device, reset it and display the model */ 1468 if (bktr->card.msp3400c)msp_reset(bktr); | 1500 1501 /* If there is an MSP Audio device, reset it and display the model */ 1502 if (bktr->card.msp3400c)msp_reset(bktr); |
1469 if (bktr->card.msp3400c)msp_read_id(bktr); | 1503 if (bktr->card.msp3400c)msp_read_id(bktr, unit); |
1470 1471} 1472 1473 1474/* Copy the vbi lines from 'vbidata' into the circular buffer, 'vbibuffer'. 1475 * The circular buffer holds 'n' fixed size data blocks. 1476 * vbisize is the number of bytes in the circular buffer 1477 * vbiread is the point we reading data out of the circular buffer 1478 * vbiinsert is the point we insert data into the circular buffer 1479 */ 1480static void vbidecode(bktr_ptr_t bktr) { 1481 unsigned char *dest; | 1504 1505} 1506 1507 1508/* Copy the vbi lines from 'vbidata' into the circular buffer, 'vbibuffer'. 1509 * The circular buffer holds 'n' fixed size data blocks. 1510 * vbisize is the number of bytes in the circular buffer 1511 * vbiread is the point we reading data out of the circular buffer 1512 * vbiinsert is the point we insert data into the circular buffer 1513 */ 1514static void vbidecode(bktr_ptr_t bktr) { 1515 unsigned char *dest; |
1516 unsigned int *seq_dest; |
|
1482 1483 /* Check if there is room in the buffer to insert the data. */ 1484 if (bktr->vbisize + VBI_DATA_SIZE > VBI_BUFFER_SIZE) return; 1485 1486 /* Copy the VBI data into the next free slot in the buffer. */ 1487 /* 'dest' is the point in vbibuffer where we want to insert new data */ 1488 dest = (unsigned char *)bktr->vbibuffer + bktr->vbiinsert; | 1517 1518 /* Check if there is room in the buffer to insert the data. */ 1519 if (bktr->vbisize + VBI_DATA_SIZE > VBI_BUFFER_SIZE) return; 1520 1521 /* Copy the VBI data into the next free slot in the buffer. */ 1522 /* 'dest' is the point in vbibuffer where we want to insert new data */ 1523 dest = (unsigned char *)bktr->vbibuffer + bktr->vbiinsert; |
1489 1490 /* block copy the vbi data into the buffer */ | |
1491 memcpy(dest, (unsigned char*)bktr->vbidata, VBI_DATA_SIZE); 1492 | 1524 memcpy(dest, (unsigned char*)bktr->vbidata, VBI_DATA_SIZE); 1525 |
1526 /* Write the VBI sequence number to the end of the vbi data */ 1527 /* This is used by the AleVT teletext program */ 1528 seq_dest = (unsigned int *)((unsigned char *)bktr->vbibuffer + bktr->vbiinsert 1529 + (VBI_DATA_SIZE - sizeof(bktr->vbi_sequence_number))); 1530 *seq_dest = bktr->vbi_sequence_number; 1531 1532 /* And increase the VBI sequence number */ 1533 /* This can wrap around */ 1534 bktr->vbi_sequence_number++; 1535 1536 |
|
1493 /* Increment the vbiinsert pointer */ 1494 /* This can wrap around */ 1495 bktr->vbiinsert += VBI_DATA_SIZE; 1496 bktr->vbiinsert = (bktr->vbiinsert % VBI_BUFFER_SIZE); 1497 1498 /* And increase the amount of vbi data in the buffer */ 1499 bktr->vbisize = bktr->vbisize + VBI_DATA_SIZE; | 1537 /* Increment the vbiinsert pointer */ 1538 /* This can wrap around */ 1539 bktr->vbiinsert += VBI_DATA_SIZE; 1540 bktr->vbiinsert = (bktr->vbiinsert % VBI_BUFFER_SIZE); 1541 1542 /* And increase the amount of vbi data in the buffer */ 1543 bktr->vbisize = bktr->vbisize + VBI_DATA_SIZE; |
1544 |
|
1500} 1501 1502 1503/* 1504 * the common interrupt handler. 1505 * Returns a 0 or 1 depending on whether the interrupt has handled. 1506 * In the OS specific section, bktr_intr() is defined which calls this 1507 * common interrupt handler. --- 41 unchanged lines hidden (view full) --- 1549 status_sum |= ((dstatus & (BT848_DSTATUS_COF|BT848_DSTATUS_LOF)) << 6); 1550#endif /* STATUS_SUM */ 1551 /* printf( " STATUS %x %x %x \n", 1552 dstatus, bktr_status, bt848->risc_count ); 1553 */ 1554 1555 1556 /* if risc was disabled re-start process again */ | 1545} 1546 1547 1548/* 1549 * the common interrupt handler. 1550 * Returns a 0 or 1 depending on whether the interrupt has handled. 1551 * In the OS specific section, bktr_intr() is defined which calls this 1552 * common interrupt handler. --- 41 unchanged lines hidden (view full) --- 1594 status_sum |= ((dstatus & (BT848_DSTATUS_COF|BT848_DSTATUS_LOF)) << 6); 1595#endif /* STATUS_SUM */ 1596 /* printf( " STATUS %x %x %x \n", 1597 dstatus, bktr_status, bt848->risc_count ); 1598 */ 1599 1600 1601 /* if risc was disabled re-start process again */ |
1602 /* if there was one of the following errors re-start again */ |
|
1557 if ( !(bktr_status & BT848_INT_RISC_EN) || | 1603 if ( !(bktr_status & BT848_INT_RISC_EN) || |
1558 ((bktr_status &(BT848_INT_FBUS | 1559 BT848_INT_FTRGT | 1560 BT848_INT_FDSR | | 1604 ((bktr_status &(/* BT848_INT_FBUS | */ 1605 /* BT848_INT_FTRGT | */ 1606 /* BT848_INT_FDSR | */ |
1561 BT848_INT_PPERR | | 1607 BT848_INT_PPERR | |
1562 BT848_INT_RIPERR | 1563 BT848_INT_PABORT | 1564 BT848_INT_OCERR | 1565 BT848_INT_SCERR) ) != 0) || 1566 ((bt848->tdec == 0) && (bktr_status & TDEC_BITS)) ) { | 1608 BT848_INT_RIPERR | BT848_INT_PABORT | 1609 BT848_INT_OCERR | BT848_INT_SCERR) ) != 0) 1610 || ((bt848->tdec == 0) && (bktr_status & TDEC_BITS)) ) { |
1567 1568 u_short tdec_save = bt848->tdec; 1569 1570 bt848->gpio_dma_ctl = FIFO_RISC_DISABLED; 1571 1572 bt848->int_mask = ALL_INTS_DISABLED; 1573 1574 /* Reset temporal decimation ctr */ --- 41 unchanged lines hidden (view full) --- 1616 /* 1617 * Disable future interrupts if a capture mode is not selected. 1618 * This can happen when we are in the process of closing or 1619 * changing capture modes, otherwise it shouldn't happen. 1620 */ 1621 if (!(bktr->flags & METEOR_CAP_MASK)) 1622 bt848->cap_ctl = CAPTURE_OFF; 1623 | 1611 1612 u_short tdec_save = bt848->tdec; 1613 1614 bt848->gpio_dma_ctl = FIFO_RISC_DISABLED; 1615 1616 bt848->int_mask = ALL_INTS_DISABLED; 1617 1618 /* Reset temporal decimation ctr */ --- 41 unchanged lines hidden (view full) --- 1660 /* 1661 * Disable future interrupts if a capture mode is not selected. 1662 * This can happen when we are in the process of closing or 1663 * changing capture modes, otherwise it shouldn't happen. 1664 */ 1665 if (!(bktr->flags & METEOR_CAP_MASK)) 1666 bt848->cap_ctl = CAPTURE_OFF; 1667 |
1668 1669 /* Determine which field generated this interrupt */ 1670 field = ( bktr_status & BT848_INT_FIELD ) ? EVEN_F : ODD_F; 1671 1672 |
|
1624 /* | 1673 /* |
1674 * Process the VBI data if it is being captured. We do this once 1675 * both Odd and Even VBI data is captured. Therefore we do this 1676 * in the Even field interrupt handler. 1677 */ 1678 if ((bktr->vbiflags & VBI_CAPTURE)&&(field==EVEN_F)) { 1679 /* Put VBI data into circular buffer */ 1680 vbidecode(bktr); 1681 1682 /* If someone is blocked on reading from /dev/vbi, wake them */ 1683 if (bktr->vbi_read_blocked) { 1684 bktr->vbi_read_blocked = FALSE; 1685 wakeup(VBI_SLEEP); 1686 } 1687 1688 /* If someone has a select() on /dev/vbi, inform them */ 1689 if (bktr->vbi_select.si_pid) { 1690 selwakeup(&bktr->vbi_select); 1691 } 1692 1693 1694 } 1695 1696 1697 /* |
|
1625 * Register the completed field 1626 * (For dual-field mode, require fields from the same frame) 1627 */ | 1698 * Register the completed field 1699 * (For dual-field mode, require fields from the same frame) 1700 */ |
1628 field = ( bktr_status & BT848_INT_FIELD ) ? EVEN_F : ODD_F; | |
1629 switch ( bktr->flags & METEOR_WANT_MASK ) { 1630 case METEOR_WANT_ODD : w_field = ODD_F ; break; 1631 case METEOR_WANT_EVEN : w_field = EVEN_F ; break; 1632 default : w_field = (ODD_F|EVEN_F); break; 1633 } 1634 switch ( bktr->flags & METEOR_ONLY_FIELDS_MASK ) { 1635 case METEOR_ONLY_ODD_FIELDS : req_field = ODD_F ; break; 1636 case METEOR_ONLY_EVEN_FIELDS : req_field = EVEN_F ; break; --- 49 unchanged lines hidden (view full) --- 1686 bktr->frame_size; 1687 /* doesn't work in synch mode except 1688 * for first frame */ 1689 /* XXX */ 1690 microtime(ts); 1691 } 1692 } 1693 | 1701 switch ( bktr->flags & METEOR_WANT_MASK ) { 1702 case METEOR_WANT_ODD : w_field = ODD_F ; break; 1703 case METEOR_WANT_EVEN : w_field = EVEN_F ; break; 1704 default : w_field = (ODD_F|EVEN_F); break; 1705 } 1706 switch ( bktr->flags & METEOR_ONLY_FIELDS_MASK ) { 1707 case METEOR_ONLY_ODD_FIELDS : req_field = ODD_F ; break; 1708 case METEOR_ONLY_EVEN_FIELDS : req_field = EVEN_F ; break; --- 49 unchanged lines hidden (view full) --- 1758 bktr->frame_size; 1759 /* doesn't work in synch mode except 1760 * for first frame */ 1761 /* XXX */ 1762 microtime(ts); 1763 } 1764 } 1765 |
1694 /* 1695 * Process the VBI data if it is being captured 1696 */ 1697 if (bktr->vbiflags & VBI_CAPTURE) { 1698 vbidecode(bktr); 1699 wakeup(VBI_SLEEP); 1700 } | |
1701 1702 /* 1703 * Wake up the user in single capture mode. 1704 */ 1705 if (bktr->flags & METEOR_SINGLE) { 1706 1707 /* stop dma */ 1708 bt848->int_mask = ALL_INTS_DISABLED; --- 167 unchanged lines hidden (view full) --- 1876 return( EBUSY ); 1877 1878 bktr->vbiflags |= VBI_OPEN; 1879 1880 /* reset the VBI circular buffer pointers and clear the buffers */ 1881 bktr->vbiinsert = 0; 1882 bktr->vbistart = 0; 1883 bktr->vbisize = 0; | 1766 1767 /* 1768 * Wake up the user in single capture mode. 1769 */ 1770 if (bktr->flags & METEOR_SINGLE) { 1771 1772 /* stop dma */ 1773 bt848->int_mask = ALL_INTS_DISABLED; --- 167 unchanged lines hidden (view full) --- 1941 return( EBUSY ); 1942 1943 bktr->vbiflags |= VBI_OPEN; 1944 1945 /* reset the VBI circular buffer pointers and clear the buffers */ 1946 bktr->vbiinsert = 0; 1947 bktr->vbistart = 0; 1948 bktr->vbisize = 0; |
1949 bktr->vbi_sequence_number = 0; 1950 bktr->vbi_read_blocked = FALSE; |
|
1884 1885 bzero((caddr_t) bktr->vbibuffer, VBI_BUFFER_SIZE); 1886 bzero((caddr_t) bktr->vbidata, VBI_DATA_SIZE); 1887 1888 return( 0 ); 1889} 1890 1891/* --- 143 unchanged lines hidden (view full) --- 2035/* 2036 * Read VBI data from the vbi circular buffer 2037 * The buffer holds vbi data blocks which are the same size 2038 * vbiinsert is the position we will insert the next item into the buffer 2039 * vbistart is the actual position in the buffer we want to read from 2040 * vbisize is the exact number of bytes in the buffer left to read 2041 */ 2042static int | 1951 1952 bzero((caddr_t) bktr->vbibuffer, VBI_BUFFER_SIZE); 1953 bzero((caddr_t) bktr->vbidata, VBI_DATA_SIZE); 1954 1955 return( 0 ); 1956} 1957 1958/* --- 143 unchanged lines hidden (view full) --- 2102/* 2103 * Read VBI data from the vbi circular buffer 2104 * The buffer holds vbi data blocks which are the same size 2105 * vbiinsert is the position we will insert the next item into the buffer 2106 * vbistart is the actual position in the buffer we want to read from 2107 * vbisize is the exact number of bytes in the buffer left to read 2108 */ 2109static int |
2043vbi_read(bktr_ptr_t bktr, dev_t dev, struct uio *uio) | 2110vbi_read(bktr_ptr_t bktr, struct uio *uio, int ioflag) |
2044{ 2045 int readsize, readsize2; 2046 int status; 2047 | 2111{ 2112 int readsize, readsize2; 2113 int status; 2114 |
2048 if(bktr->vbisize == 0) 2049 status = tsleep(VBI_SLEEP, BKTRPRI, "vbi", 0); | |
2050 | 2115 |
2116 while(bktr->vbisize == 0) { 2117 if (ioflag & IO_NDELAY) { 2118 return EWOULDBLOCK; 2119 } 2120 2121 bktr->vbi_read_blocked = TRUE; 2122 if ((status = tsleep(VBI_SLEEP, VBIPRI, "vbi", 0))) { 2123 return status; 2124 } 2125 } 2126 2127 /* Now we have some data to give to the user */ 2128 2129 /* We cannot read more bytes than there are in 2130 * the circular buffer 2131 */ |
|
2051 readsize = (int)uio->uio_iov->iov_len; 2052 | 2132 readsize = (int)uio->uio_iov->iov_len; 2133 |
2053 /* We cannot read more bytes than there are in the circular buffer */ | |
2054 if (readsize > bktr->vbisize) readsize = bktr->vbisize; 2055 | 2134 if (readsize > bktr->vbisize) readsize = bktr->vbisize; 2135 |
2056 /* Check if we can read this number of bytes without having to wrap around the circular buffer */ | 2136 /* Check if we can read this number of bytes without having 2137 * to wrap around the circular buffer */ |
2057 if((bktr->vbistart + readsize) >= VBI_BUFFER_SIZE) { 2058 /* We need to wrap around */ 2059 | 2138 if((bktr->vbistart + readsize) >= VBI_BUFFER_SIZE) { 2139 /* We need to wrap around */ 2140 |
2060 readsize2 = VBI_BUFFER_SIZE - bktr->vbistart; 2061 status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize2, uio); 2062 status += uiomove((caddr_t)bktr->vbibuffer, (readsize - readsize2), uio); 2063 } else { | 2141 readsize2 = VBI_BUFFER_SIZE - bktr->vbistart; 2142 status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize2, uio); 2143 status += uiomove((caddr_t)bktr->vbibuffer, (readsize - readsize2), uio); 2144 } else { |
2064 /* We do not need to wrap around */ | 2145 /* We do not need to wrap around */ |
2065 status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize, uio); 2066 } | 2146 status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize, uio); 2147 } |
2067 2068 /* Update the number of bytes left to read */ | 2148 2149 /* Update the number of bytes left to read */ |
2069 bktr->vbisize -= readsize; | 2150 bktr->vbisize -= readsize; |
2070 2071 /* Update vbistart */ | 2151 2152 /* Update vbistart */ |
2072 bktr->vbistart += readsize; | 2153 bktr->vbistart += readsize; |
2073 bktr->vbistart = bktr->vbistart % VBI_BUFFER_SIZE; /* wrap around if needed */ 2074 | 2154 bktr->vbistart = bktr->vbistart % VBI_BUFFER_SIZE; /* wrap around if needed */ 2155 |
2075 return( status ); | 2156return( status ); |
2076 2077} 2078 2079 2080 2081/* 2082 * video ioctls 2083 */ 2084static int 2085video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr ) 2086{ 2087 bt848_ptr_t bt848; 2088 volatile u_char c_temp; 2089 unsigned int temp; 2090 unsigned int temp_iform; 2091 unsigned int error; 2092 struct meteor_geomet *geo; | 2157 2158} 2159 2160 2161 2162/* 2163 * video ioctls 2164 */ 2165static int 2166video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr ) 2167{ 2168 bt848_ptr_t bt848; 2169 volatile u_char c_temp; 2170 unsigned int temp; 2171 unsigned int temp_iform; 2172 unsigned int error; 2173 struct meteor_geomet *geo; |
2093 struct meteor_counts *cnt; | 2174 struct meteor_counts *counts; |
2094 struct meteor_video *video; 2095 struct bktr_capture_area *cap_area; 2096 vm_offset_t buf; 2097 int i; 2098 char char_temp; 2099 2100 bt848 = bktr->base; 2101 --- 146 unchanged lines hidden (view full) --- 2248 break; 2249 2250 2251 case BT848GFMT: /* get input format */ 2252 *(u_long *)arg = bt848->iform & BT848_IFORM_FORMAT; 2253 break; 2254 2255 case METEORSCOUNT: /* (re)set error counts */ | 2175 struct meteor_video *video; 2176 struct bktr_capture_area *cap_area; 2177 vm_offset_t buf; 2178 int i; 2179 char char_temp; 2180 2181 bt848 = bktr->base; 2182 --- 146 unchanged lines hidden (view full) --- 2329 break; 2330 2331 2332 case BT848GFMT: /* get input format */ 2333 *(u_long *)arg = bt848->iform & BT848_IFORM_FORMAT; 2334 break; 2335 2336 case METEORSCOUNT: /* (re)set error counts */ |
2256 cnt = (struct meteor_counts *) arg; 2257 bktr->fifo_errors = cnt->fifo_errors; 2258 bktr->dma_errors = cnt->dma_errors; 2259 bktr->frames_captured = cnt->frames_captured; 2260 bktr->even_fields_captured = cnt->even_fields_captured; 2261 bktr->odd_fields_captured = cnt->odd_fields_captured; | 2337 counts = (struct meteor_counts *) arg; 2338 bktr->fifo_errors = counts->fifo_errors; 2339 bktr->dma_errors = counts->dma_errors; 2340 bktr->frames_captured = counts->frames_captured; 2341 bktr->even_fields_captured = counts->even_fields_captured; 2342 bktr->odd_fields_captured = counts->odd_fields_captured; |
2262 break; 2263 2264 case METEORGCOUNT: /* get error counts */ | 2343 break; 2344 2345 case METEORGCOUNT: /* get error counts */ |
2265 cnt = (struct meteor_counts *) arg; 2266 cnt->fifo_errors = bktr->fifo_errors; 2267 cnt->dma_errors = bktr->dma_errors; 2268 cnt->frames_captured = bktr->frames_captured; 2269 cnt->even_fields_captured = bktr->even_fields_captured; 2270 cnt->odd_fields_captured = bktr->odd_fields_captured; | 2346 counts = (struct meteor_counts *) arg; 2347 counts->fifo_errors = bktr->fifo_errors; 2348 counts->dma_errors = bktr->dma_errors; 2349 counts->frames_captured = bktr->frames_captured; 2350 counts->even_fields_captured = bktr->even_fields_captured; 2351 counts->odd_fields_captured = bktr->odd_fields_captured; |
2271 break; 2272 2273 case METEORGVIDEO: 2274 video = (struct meteor_video *)arg; 2275 video->addr = bktr->video.addr; 2276 video->width = bktr->video.width; 2277 video->banksize = bktr->video.banksize; 2278 video->ramsize = bktr->video.ramsize; --- 1198 unchanged lines hidden (view full) --- 3477static void 3478rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) 3479{ 3480 int i; 3481 bt848_ptr_t bt848; 3482 volatile u_long target_buffer, buffer, target,width; 3483 volatile u_long pitch; 3484 volatile u_long *dma_prog; | 2352 break; 2353 2354 case METEORGVIDEO: 2355 video = (struct meteor_video *)arg; 2356 video->addr = bktr->video.addr; 2357 video->width = bktr->video.width; 2358 video->banksize = bktr->video.banksize; 2359 video->ramsize = bktr->video.ramsize; --- 1198 unchanged lines hidden (view full) --- 3558static void 3559rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) 3560{ 3561 int i; 3562 bt848_ptr_t bt848; 3563 volatile u_long target_buffer, buffer, target,width; 3564 volatile u_long pitch; 3565 volatile u_long *dma_prog; |
3566 vm_offset_t loop_point; |
|
3485 struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; 3486 u_int Bpp = pf_int->public.Bpp; 3487 unsigned int vbisamples; /* VBI samples per line */ 3488 unsigned int vbilines; /* VBI lines per field */ 3489 unsigned int num_dwords; /* DWORDS per line */ 3490 3491 vbisamples = format_params[bktr->format_params].vbi_num_samples; 3492 vbilines = format_params[bktr->format_params].vbi_num_lines; --- 37 unchanged lines hidden (view full) --- 3530 } 3531 else { 3532 target_buffer = (u_long) vtophys(bktr->bigbuf); 3533 pitch = cols*Bpp; 3534 } 3535 3536 buffer = target_buffer; 3537 | 3567 struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; 3568 u_int Bpp = pf_int->public.Bpp; 3569 unsigned int vbisamples; /* VBI samples per line */ 3570 unsigned int vbilines; /* VBI lines per field */ 3571 unsigned int num_dwords; /* DWORDS per line */ 3572 3573 vbisamples = format_params[bktr->format_params].vbi_num_samples; 3574 vbilines = format_params[bktr->format_params].vbi_num_lines; --- 37 unchanged lines hidden (view full) --- 3612 } 3613 else { 3614 target_buffer = (u_long) vtophys(bktr->bigbuf); 3615 pitch = cols*Bpp; 3616 } 3617 3618 buffer = target_buffer; 3619 |
3620 /* Wait for the VRE sync marking the end of the Even and 3621 * the start of the Odd field. Resync here. 3622 */ 3623 *dma_prog++ = OP_SYNC | BKTR_RESYNC |BKTR_VRE; 3624 *dma_prog++ = 0; |
|
3538 | 3625 |
3626 loop_point = dma_prog; 3627 |
|
3539 /* store the VBI data */ 3540 /* look for sync with packed data */ | 3628 /* store the VBI data */ 3629 /* look for sync with packed data */ |
3541 *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1; | 3630 *dma_prog++ = OP_SYNC | BKTR_FM1; |
3542 *dma_prog++ = 0; 3543 for(i = 0; i < vbilines; i++) { 3544 *dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples; 3545 *dma_prog++ = (u_long) vtophys(bktr->vbidata + 3546 (i * VBI_LINE_SIZE)); 3547 } 3548 | 3631 *dma_prog++ = 0; 3632 for(i = 0; i < vbilines; i++) { 3633 *dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples; 3634 *dma_prog++ = (u_long) vtophys(bktr->vbidata + 3635 (i * VBI_LINE_SIZE)); 3636 } 3637 |
3549 /* store the video image */ 3550 /* look for sync with packed data */ 3551 *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1; 3552 *dma_prog++ = 0; /* NULL WORD */ 3553 width = cols; 3554 for (i = 0; i < (rows/interlace); i++) { 3555 target = target_buffer; 3556 if ( notclipped(bktr, i, width)) { 3557 split(bktr, (volatile u_long **) &dma_prog, 3558 bktr->y2 - bktr->y, OP_WRITE, 3559 Bpp, (volatile u_char **) &target, cols); 3560 3561 } else { 3562 while(getline(bktr, i)) { 3563 if (bktr->y != bktr->y2 ) { | 3638 if ( (i_flag == 2/*Odd*/) || (i_flag==3) /*interlaced*/ ) { 3639 /* store the Odd field video image */ 3640 /* look for sync with packed data */ 3641 *dma_prog++ = OP_SYNC | BKTR_FM1; 3642 *dma_prog++ = 0; /* NULL WORD */ 3643 width = cols; 3644 for (i = 0; i < (rows/interlace); i++) { 3645 target = target_buffer; 3646 if ( notclipped(bktr, i, width)) { |
3564 split(bktr, (volatile u_long **) &dma_prog, 3565 bktr->y2 - bktr->y, OP_WRITE, | 3647 split(bktr, (volatile u_long **) &dma_prog, 3648 bktr->y2 - bktr->y, OP_WRITE, |
3566 Bpp, (volatile u_char **) &target, cols); 3567 } 3568 if (bktr->yclip != bktr->yclip2 ) { 3569 split(bktr,(volatile u_long **) &dma_prog, 3570 bktr->yclip2 - bktr->yclip, 3571 OP_SKIP, | |
3572 Bpp, (volatile u_char **) &target, cols); | 3649 Bpp, (volatile u_char **) &target, cols); |
3650 3651 } else { 3652 while(getline(bktr, i)) { 3653 if (bktr->y != bktr->y2 ) { 3654 split(bktr, (volatile u_long **) &dma_prog, 3655 bktr->y2 - bktr->y, OP_WRITE, 3656 Bpp, (volatile u_char **) &target, cols); 3657 } 3658 if (bktr->yclip != bktr->yclip2 ) { 3659 split(bktr,(volatile u_long **) &dma_prog, 3660 bktr->yclip2 - bktr->yclip, 3661 OP_SKIP, 3662 Bpp, (volatile u_char **) &target, cols); 3663 } 3664 } 3665 |
|
3573 } | 3666 } |
3667 3668 target_buffer += interlace * pitch; 3669 |
|
3574 } 3575 | 3670 } 3671 |
3576 } | 3672 } /* end if */ |
3577 | 3673 |
3578 target_buffer += interlace * pitch; | 3674 /* Grab the Even field */ 3675 /* Look for the VRO, end of Odd field, marker */ 3676 *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO; 3677 *dma_prog++ = 0; /* NULL WORD */ |
3579 | 3678 |
3679 /* store the VBI data */ 3680 /* look for sync with packed data */ 3681 *dma_prog++ = OP_SYNC | BKTR_FM1; 3682 *dma_prog++ = 0; 3683 for(i = 0; i < vbilines; i++) { 3684 *dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples; 3685 *dma_prog++ = (u_long) vtophys(bktr->vbidata + 3686 ((i+MAX_VBI_LINES) * VBI_LINE_SIZE)); |
|
3580 } 3581 | 3687 } 3688 |
3582 switch (i_flag) { 3583 case 1: 3584 /* EVEN field grabs. Look for end of 'Even Field' Marker 3585 * We cannot look for VRO, because we have not enabled ODD 3586 * field capture 3587 */ 3588 *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE; 3589 *dma_prog++ = 0; /* NULL WORD */ | 3689 /* store the video image */ 3690 if (i_flag == 1) /*Even Only*/ 3691 target_buffer = buffer; 3692 if (i_flag == 3) /*interlaced*/ 3693 target_buffer = buffer+pitch; |
3590 | 3694 |
3591 *dma_prog++ = OP_JUMP; 3592 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 3593 return; | |
3594 | 3695 |
3595 case 2: 3596 /* ODD field grabs. Look for end of 'Odd Field' Marker 3597 * We cannot look for VRE, because we have not enabled EVEN 3598 * field capture 3599 */ 3600 *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO; 3601 *dma_prog++ = 0; /* NULL WORD */ 3602 3603 *dma_prog++ = OP_JUMP; 3604 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 3605 return; 3606 3607 case 3: 3608 /* INTERLACED grabs (ODD then EVEN). We have read the old field 3609 * so look for the end of 'Odd Field' Marker. 3610 * Then jump to the 'odd_dma_prog' which actually captures 3611 * the EVEN field! 3612 */ 3613 *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO; 3614 *dma_prog++ = 0; /* NULL WORD */ 3615 3616 *dma_prog++ = OP_JUMP; 3617 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); 3618 break; 3619 } 3620 3621 if (interlace == 2) { 3622 3623 target_buffer = buffer + pitch; 3624 3625 dma_prog = (u_long *) bktr->odd_dma_prog; 3626 3627 /* store the VBI data */ | 3696 if ((i_flag == 1) /*Even Only*/ || (i_flag==3) /*interlaced*/) { |
3628 /* look for sync with packed data */ | 3697 /* look for sync with packed data */ |
3629 *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1; 3630 *dma_prog++ = 0; 3631 for(i = 0; i < vbilines; i++) { 3632 *dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples; 3633 *dma_prog++ = (u_long) vtophys(bktr->vbidata + 3634 ((i+MAX_VBI_LINES) * VBI_LINE_SIZE)); 3635 } 3636 3637 /* store the video image */ 3638 /* look for sync with packed data */ 3639 *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1; | 3698 *dma_prog++ = OP_SYNC | BKTR_FM1; |
3640 *dma_prog++ = 0; /* NULL WORD */ 3641 width = cols; 3642 for (i = 0; i < (rows/interlace); i++) { 3643 target = target_buffer; 3644 if ( notclipped(bktr, i, width)) { 3645 split(bktr, (volatile u_long **) &dma_prog, 3646 bktr->y2 - bktr->y, OP_WRITE, 3647 Bpp, (volatile u_char **) &target, cols); --- 20 unchanged lines hidden (view full) --- 3668 } 3669 } 3670 3671 /* Look for end of 'Even Field' */ 3672 *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE; 3673 *dma_prog++ = 0; /* NULL WORD */ 3674 3675 *dma_prog++ = OP_JUMP ; | 3699 *dma_prog++ = 0; /* NULL WORD */ 3700 width = cols; 3701 for (i = 0; i < (rows/interlace); i++) { 3702 target = target_buffer; 3703 if ( notclipped(bktr, i, width)) { 3704 split(bktr, (volatile u_long **) &dma_prog, 3705 bktr->y2 - bktr->y, OP_WRITE, 3706 Bpp, (volatile u_char **) &target, cols); --- 20 unchanged lines hidden (view full) --- 3727 } 3728 } 3729 3730 /* Look for end of 'Even Field' */ 3731 *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE; 3732 *dma_prog++ = 0; /* NULL WORD */ 3733 3734 *dma_prog++ = OP_JUMP ; |
3676 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog) ; | 3735 *dma_prog++ = (u_long ) vtophys(loop_point) ; |
3677 *dma_prog++ = 0; /* NULL WORD */ 3678 3679} 3680 3681 3682 3683 3684static void --- 673 unchanged lines hidden (view full) --- 4358 4359 /* If /dev/vbi is already open, then use the rgb_vbi RISC program */ 4360 if ( (pf_int->public.type == METEOR_PIXTYPE_RGB) 4361 &&(bktr->vbiflags & VBI_OPEN) ) { 4362 if (i_flag==1) bktr->bktr_cap_ctl |= BT848_CAP_CTL_VBI_EVEN; 4363 if (i_flag==2) bktr->bktr_cap_ctl |= BT848_CAP_CTL_VBI_ODD; 4364 if (i_flag==3) bktr->bktr_cap_ctl |= 4365 BT848_CAP_CTL_VBI_EVEN | BT848_CAP_CTL_VBI_ODD; | 3736 *dma_prog++ = 0; /* NULL WORD */ 3737 3738} 3739 3740 3741 3742 3743static void --- 673 unchanged lines hidden (view full) --- 4417 4418 /* If /dev/vbi is already open, then use the rgb_vbi RISC program */ 4419 if ( (pf_int->public.type == METEOR_PIXTYPE_RGB) 4420 &&(bktr->vbiflags & VBI_OPEN) ) { 4421 if (i_flag==1) bktr->bktr_cap_ctl |= BT848_CAP_CTL_VBI_EVEN; 4422 if (i_flag==2) bktr->bktr_cap_ctl |= BT848_CAP_CTL_VBI_ODD; 4423 if (i_flag==3) bktr->bktr_cap_ctl |= 4424 BT848_CAP_CTL_VBI_EVEN | BT848_CAP_CTL_VBI_ODD; |
4425 bktr->bktr_cap_ctl |= 4426 BT848_CAP_CTL_VBI_EVEN | BT848_CAP_CTL_VBI_ODD; |
|
4366 bktr->vbiflags |= VBI_CAPTURE; 4367 rgb_vbi_prog(bktr, i_flag, cols, rows, interlace); 4368 return; 4369 } 4370 4371 if ( pf_int->public.type == METEOR_PIXTYPE_RGB ) { 4372 rgb_prog(bktr, i_flag, cols, rows, interlace); 4373 return; --- 869 unchanged lines hidden (view full) --- 5243 * different I2C addresses, so an i2c bus probe can help, but it is 5244 * really just a guess. 5245 * 5246 * 6) After determining the Tuner Type, we probe the i2c bus for other 5247 * devices at known locations, eg IR-Remote Control, MSP34xx and TDA 5248 * stereo chips. 5249 */ 5250 | 4427 bktr->vbiflags |= VBI_CAPTURE; 4428 rgb_vbi_prog(bktr, i_flag, cols, rows, interlace); 4429 return; 4430 } 4431 4432 if ( pf_int->public.type == METEOR_PIXTYPE_RGB ) { 4433 rgb_prog(bktr, i_flag, cols, rows, interlace); 4434 return; --- 869 unchanged lines hidden (view full) --- 5304 * different I2C addresses, so an i2c bus probe can help, but it is 5305 * really just a guess. 5306 * 5307 * 6) After determining the Tuner Type, we probe the i2c bus for other 5308 * devices at known locations, eg IR-Remote Control, MSP34xx and TDA 5309 * stereo chips. 5310 */ 5311 |
5251#define VENDOR_AVER_MEDIA 0x1431 | 5312#define VENDOR_AVER_MEDIA 0x1461 |
5252#define VENDOR_HAUPPAUGE 0x0070 5253#define VENDOR_FLYVIDEO 0x1851 5254#define VENDOR_STB 0x10B4 5255 5256static void | 5313#define VENDOR_HAUPPAUGE 0x0070 5314#define VENDOR_FLYVIDEO 0x1851 5315#define VENDOR_STB 0x10B4 5316 5317static void |
5257probeCard( bktr_ptr_t bktr, int verbose ) | 5318probeCard( bktr_ptr_t bktr, int verbose, int unit ) |
5258{ 5259 int card, i,j, card_found; 5260 int status; 5261 bt848_ptr_t bt848; 5262 u_char probe_signature[128], *probe_temp; 5263 int any_i2c_devices; 5264 u_char eeprom[256]; 5265 u_char tuner_code = 0; --- 296 unchanged lines hidden (view full) --- 5562 15 Philips FM1216 BG PHILIPS_FR1216_PAL 5563 16 Philips FM1216MF BGLL' 5564 17 Philips FM1236 MN PHILIPS_FR1236_NTSC 5565 18 Philips FM1246 I 5566 19 Philips FM1256 DK 5567 1a Temic 4036FY5 MN - FI1236 MK2 clone 5568 1b Samsung TCPN9082D MN 5569 1c Samsung TCPM9092P Pal BG/I/DK | 5319{ 5320 int card, i,j, card_found; 5321 int status; 5322 bt848_ptr_t bt848; 5323 u_char probe_signature[128], *probe_temp; 5324 int any_i2c_devices; 5325 u_char eeprom[256]; 5326 u_char tuner_code = 0; --- 296 unchanged lines hidden (view full) --- 5623 15 Philips FM1216 BG PHILIPS_FR1216_PAL 5624 16 Philips FM1216MF BGLL' 5625 17 Philips FM1236 MN PHILIPS_FR1236_NTSC 5626 18 Philips FM1246 I 5627 19 Philips FM1256 DK 5628 1a Temic 4036FY5 MN - FI1236 MK2 clone 5629 1b Samsung TCPN9082D MN 5630 1c Samsung TCPM9092P Pal BG/I/DK |
5570 1d Temic 4006FH5 BG | 5631 1d Temic 4006FH5 BG PHILIPS_PALI clone |
5571 1e Samsung TCPN9085D MN/Radio 5572 1f Samsung TCPB9085P Pal BG/I/DK / Radio 5573 20 Samsung TCPL9091P Pal BG & Secam L/L' 5574 21 Temic 4039FY5 NTSC Radio 5575 5576 */ 5577 5578 readEEProm(bktr, 0, 128, (u_char *) &eeprom ); 5579 5580 5581 /* Determine the model number from the eeprom */ 5582 { 5583 u_int model; 5584 u_int revision; 5585 model = (eeprom[12] << 8 | eeprom[11]); 5586 revision = (eeprom[15] << 16 | eeprom[14] << 8 | eeprom[13]); 5587 if (verbose) | 5632 1e Samsung TCPN9085D MN/Radio 5633 1f Samsung TCPB9085P Pal BG/I/DK / Radio 5634 20 Samsung TCPL9091P Pal BG & Secam L/L' 5635 21 Temic 4039FY5 NTSC Radio 5636 5637 */ 5638 5639 readEEProm(bktr, 0, 128, (u_char *) &eeprom ); 5640 5641 5642 /* Determine the model number from the eeprom */ 5643 { 5644 u_int model; 5645 u_int revision; 5646 model = (eeprom[12] << 8 | eeprom[11]); 5647 revision = (eeprom[15] << 16 | eeprom[14] << 8 | eeprom[13]); 5648 if (verbose) |
5588 printf("Hauppauge Model %d %c%c%c%c\n", | 5649 printf("bktr%d: Hauppauge Model %d %c%c%c%c\n", 5650 unit, |
5589 model, 5590 ((revision >> 18) & 0x3f) + 32, 5591 ((revision >> 12) & 0x3f) + 32, 5592 ((revision >> 6) & 0x3f) + 32, 5593 ((revision >> 0) & 0x3f) + 32 ); 5594 } 5595 5596 /* Determine the tuner type from the eeprom */ --- 8 unchanged lines hidden (view full) --- 5605 5606 case 0x12: 5607 case 0x17: 5608 bktr->card.tuner = &tuners[ PHILIPS_FR1236_NTSC ]; 5609 goto checkDBX; 5610 5611 case 0x8: 5612 case 0xb: | 5651 model, 5652 ((revision >> 18) & 0x3f) + 32, 5653 ((revision >> 12) & 0x3f) + 32, 5654 ((revision >> 6) & 0x3f) + 32, 5655 ((revision >> 0) & 0x3f) + 32 ); 5656 } 5657 5658 /* Determine the tuner type from the eeprom */ --- 8 unchanged lines hidden (view full) --- 5667 5668 case 0x12: 5669 case 0x17: 5670 bktr->card.tuner = &tuners[ PHILIPS_FR1236_NTSC ]; 5671 goto checkDBX; 5672 5673 case 0x8: 5674 case 0xb: |
5675 case 0x1d: |
|
5613 bktr->card.tuner = &tuners[ PHILIPS_PALI ]; 5614 goto checkDBX; 5615 5616 case 0xd: 5617 bktr->card.tuner = &tuners[ TEMIC_NTSC ]; 5618 goto checkDBX; 5619 5620 case 0xe: --- 1051 unchanged lines hidden (view full) --- 6672 * setup the MSP34xx Stereo Audio Chip 6673 * This uses the Auto Configuration Option on MSP3410D and MSP3415D chips 6674 * and DBX mode selection for MSP3430G chips. 6675 * For MSP3400C support, the full programming sequence is required and is 6676 * not yet supported. 6677 */ 6678 6679/* Read the MSP version string */ | 5676 bktr->card.tuner = &tuners[ PHILIPS_PALI ]; 5677 goto checkDBX; 5678 5679 case 0xd: 5680 bktr->card.tuner = &tuners[ TEMIC_NTSC ]; 5681 goto checkDBX; 5682 5683 case 0xe: --- 1051 unchanged lines hidden (view full) --- 6735 * setup the MSP34xx Stereo Audio Chip 6736 * This uses the Auto Configuration Option on MSP3410D and MSP3415D chips 6737 * and DBX mode selection for MSP3430G chips. 6738 * For MSP3400C support, the full programming sequence is required and is 6739 * not yet supported. 6740 */ 6741 6742/* Read the MSP version string */ |
6680static void msp_read_id( bktr_ptr_t bktr ){ | 6743static void msp_read_id( bktr_ptr_t bktr, int unit ){ |
6681 int rev1=0, rev2=0; 6682 rev1 = msp_read(bktr, 0x12, 0x001e); 6683 rev2 = msp_read(bktr, 0x12, 0x001f); 6684 6685 sprintf(bktr->msp_version_string, "34%02d%c-%c%d", 6686 (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f); 6687 | 6744 int rev1=0, rev2=0; 6745 rev1 = msp_read(bktr, 0x12, 0x001e); 6746 rev2 = msp_read(bktr, 0x12, 0x001f); 6747 6748 sprintf(bktr->msp_version_string, "34%02d%c-%c%d", 6749 (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f); 6750 |
6688 printf("Detected a MSP%s\n",bktr->msp_version_string); | 6751 printf("bktr%d: Detected a MSP%s\n",unit,bktr->msp_version_string); |
6689} 6690 6691 6692/* Configure the MSP chip to Auto-detect the audio format */ 6693static void msp_autodetect( bktr_ptr_t bktr ) { 6694 6695 if (strncmp("3430G", bktr->msp_version_string, 5) == 0){ 6696 --- 58 unchanged lines hidden (view full) --- 6755static devclass_t bktr_devclass; 6756 6757static d_open_t bktr_open; 6758static d_close_t bktr_close; 6759static d_read_t bktr_read; 6760static d_write_t bktr_write; 6761static d_ioctl_t bktr_ioctl; 6762static d_mmap_t bktr_mmap; | 6752} 6753 6754 6755/* Configure the MSP chip to Auto-detect the audio format */ 6756static void msp_autodetect( bktr_ptr_t bktr ) { 6757 6758 if (strncmp("3430G", bktr->msp_version_string, 5) == 0){ 6759 --- 58 unchanged lines hidden (view full) --- 6818static devclass_t bktr_devclass; 6819 6820static d_open_t bktr_open; 6821static d_close_t bktr_close; 6822static d_read_t bktr_read; 6823static d_write_t bktr_write; 6824static d_ioctl_t bktr_ioctl; 6825static d_mmap_t bktr_mmap; |
6826static d_poll_t bktr_poll; |
|
6763 6764#define CDEV_MAJOR 92 6765static struct cdevsw bktr_cdevsw = { 6766 /* open */ bktr_open, 6767 /* close */ bktr_close, 6768 /* read */ bktr_read, 6769 /* write */ bktr_write, 6770 /* ioctl */ bktr_ioctl, 6771 /* stop */ nostop, 6772 /* reset */ noreset, 6773 /* devtotty */ nodevtotty, | 6827 6828#define CDEV_MAJOR 92 6829static struct cdevsw bktr_cdevsw = { 6830 /* open */ bktr_open, 6831 /* close */ bktr_close, 6832 /* read */ bktr_read, 6833 /* write */ bktr_write, 6834 /* ioctl */ bktr_ioctl, 6835 /* stop */ nostop, 6836 /* reset */ noreset, 6837 /* devtotty */ nodevtotty, |
6774 /* poll */ nopoll, | 6838 /* poll */ bktr_poll, |
6775 /* mmap */ bktr_mmap, 6776 /* strategy */ nostrategy, 6777 /* name */ "bktr", 6778 /* parms */ noparms, 6779 /* maj */ CDEV_MAJOR, 6780 /* dump */ nodump, 6781 /* psize */ nopsize, 6782 /* flags */ 0, --- 288 unchanged lines hidden (view full) --- 7071 device_busy(devclass_get_device(bktr_devclass, unit)); 7072 7073 7074 if (bt848_card != -1) { 7075 if ((bt848_card >> 8 == unit ) && 7076 ( (bt848_card & 0xff) < Bt848_MAX_CARD )) { 7077 if ( bktr->bt848_card != (bt848_card & 0xff) ) { 7078 bktr->bt848_card = (bt848_card & 0xff); | 6839 /* mmap */ bktr_mmap, 6840 /* strategy */ nostrategy, 6841 /* name */ "bktr", 6842 /* parms */ noparms, 6843 /* maj */ CDEV_MAJOR, 6844 /* dump */ nodump, 6845 /* psize */ nopsize, 6846 /* flags */ 0, --- 288 unchanged lines hidden (view full) --- 7135 device_busy(devclass_get_device(bktr_devclass, unit)); 7136 7137 7138 if (bt848_card != -1) { 7139 if ((bt848_card >> 8 == unit ) && 7140 ( (bt848_card & 0xff) < Bt848_MAX_CARD )) { 7141 if ( bktr->bt848_card != (bt848_card & 0xff) ) { 7142 bktr->bt848_card = (bt848_card & 0xff); |
7079 probeCard(bktr, FALSE); | 7143 probeCard(bktr, FALSE, unit); |
7080 } 7081 } 7082 } 7083 7084 if (bt848_tuner != -1) { 7085 if ((bt848_tuner >> 8 == unit ) && 7086 ( (bt848_tuner & 0xff) < Bt848_MAX_TUNER )) { 7087 if ( bktr->bt848_tuner != (bt848_tuner & 0xff) ) { 7088 bktr->bt848_tuner = (bt848_tuner & 0xff); | 7144 } 7145 } 7146 } 7147 7148 if (bt848_tuner != -1) { 7149 if ((bt848_tuner >> 8 == unit ) && 7150 ( (bt848_tuner & 0xff) < Bt848_MAX_TUNER )) { 7151 if ( bktr->bt848_tuner != (bt848_tuner & 0xff) ) { 7152 bktr->bt848_tuner = (bt848_tuner & 0xff); |
7089 probeCard(bktr, FALSE); | 7153 probeCard(bktr, FALSE, unit); |
7090 } 7091 } 7092 } 7093 7094 if (bt848_reverse_mute != -1) { 7095 if (((bt848_reverse_mute >> 8) == unit ) && 7096 ((bt848_reverse_mute & 0xff) < Bt848_MAX_TUNER) ) { 7097 bktr->reverse_mute = bt848_reverse_mute & 0xff; --- 79 unchanged lines hidden (view full) --- 7177 /* the device is no longer valid/functioning */ 7178 return (ENXIO); 7179 } 7180 7181 switch ( FUNCTION( minor(dev) ) ) { 7182 case VIDEO_DEV: 7183 return( video_read( bktr, unit, dev, uio ) ); 7184 case VBI_DEV: | 7154 } 7155 } 7156 } 7157 7158 if (bt848_reverse_mute != -1) { 7159 if (((bt848_reverse_mute >> 8) == unit ) && 7160 ((bt848_reverse_mute & 0xff) < Bt848_MAX_TUNER) ) { 7161 bktr->reverse_mute = bt848_reverse_mute & 0xff; --- 79 unchanged lines hidden (view full) --- 7241 /* the device is no longer valid/functioning */ 7242 return (ENXIO); 7243 } 7244 7245 switch ( FUNCTION( minor(dev) ) ) { 7246 case VIDEO_DEV: 7247 return( video_read( bktr, unit, dev, uio ) ); 7248 case VBI_DEV: |
7185 return( vbi_read( bktr, dev, uio ) ); | 7249 return( vbi_read( bktr, uio, ioflag ) ); |
7186 } 7187 return( ENXIO ); 7188} 7189 7190 7191/* 7192 * 7193 */ --- 64 unchanged lines hidden (view full) --- 7258 return( -1 ); 7259 7260 if (offset >= bktr->alloc_pages * PAGE_SIZE) 7261 return( -1 ); 7262 7263 return( i386_btop(vtophys(bktr->bigbuf) + offset) ); 7264} 7265 | 7250 } 7251 return( ENXIO ); 7252} 7253 7254 7255/* 7256 * 7257 */ --- 64 unchanged lines hidden (view full) --- 7322 return( -1 ); 7323 7324 if (offset >= bktr->alloc_pages * PAGE_SIZE) 7325 return( -1 ); 7326 7327 return( i386_btop(vtophys(bktr->bigbuf) + offset) ); 7328} 7329 |
7266#endif /* FreeBSD 4.x specific kernel interface routines */ 7267 7268 7269/**********************************/ 7270/* *** FreeBSD 2.2.x and 3.x *** */ 7271/**********************************/ 7272 7273#if ((__FreeBSD__ == 2) || (__FreeBSD__ == 3)) 7274 7275static bktr_reg_t brooktree[ NBKTR ]; 7276 7277static const char* bktr_probe( pcici_t tag, pcidi_t type ); 7278static void bktr_attach( pcici_t tag, int unit ); 7279static void bktr_intr(void *arg) { common_bktr_intr(arg); } 7280 7281static u_long bktr_count; 7282 7283static struct pci_device bktr_device = { 7284 "bktr", 7285 bktr_probe, 7286 bktr_attach, 7287 &bktr_count 7288}; 7289 7290DATA_SET (pcidevice_set, bktr_device); 7291 7292static d_open_t bktr_open; 7293static d_close_t bktr_close; 7294static d_read_t bktr_read; 7295static d_write_t bktr_write; 7296static d_ioctl_t bktr_ioctl; 7297static d_mmap_t bktr_mmap; 7298 7299#define CDEV_MAJOR 92 7300static struct cdevsw bktr_cdevsw = | 7330int bktr_poll( dev_t dev, int events, struct proc *p) |
7301{ | 7331{ |
7302 bktr_open, bktr_close, bktr_read, bktr_write, 7303 bktr_ioctl, nostop, nullreset, nodevtotty, 7304 seltrue, bktr_mmap, NULL, "bktr", 7305 NULL, -1 7306}; 7307 7308static int bktr_devsw_installed; 7309 7310static void 7311bktr_drvinit( void *unused ) 7312{ 7313 dev_t dev; 7314 7315 if ( ! bktr_devsw_installed ) { 7316 dev = makedev(CDEV_MAJOR, 0); 7317 cdevsw_add(&dev,&bktr_cdevsw, NULL); 7318 bktr_devsw_installed = 1; 7319 } 7320} 7321 7322SYSINIT(bktrdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bktr_drvinit,NULL) 7323 7324/* 7325 * the boot time probe routine. 7326 */ 7327static const char* 7328bktr_probe( pcici_t tag, pcidi_t type ) 7329{ 7330 unsigned int rev = pci_conf_read( tag, PCIR_REVID) & 0x000000ff; 7331 7332 switch (type) { 7333 case BROOKTREE_848_PCI_ID: 7334 if (rev == 0x12) return("BrookTree 848A"); 7335 else return("BrookTree 848"); 7336 case BROOKTREE_849_PCI_ID: 7337 return("BrookTree 849A"); 7338 case BROOKTREE_878_PCI_ID: 7339 return("BrookTree 878"); 7340 case BROOKTREE_879_PCI_ID: 7341 return("BrookTree 879"); 7342 }; 7343 7344 return ((char *)0); 7345} 7346 7347/* 7348 * the attach routine. 7349 */ 7350static void 7351bktr_attach( pcici_t tag, int unit ) 7352{ 7353 bktr_ptr_t bktr; 7354 bt848_ptr_t bt848; 7355 u_long latency; 7356 u_long fun; 7357 unsigned int rev; 7358#ifdef BROOKTREE_IRQ 7359 u_long old_irq, new_irq; 7360#endif 7361 7362 bktr = &brooktree[unit]; 7363 7364 if (unit >= NBKTR) { 7365 printf("brooktree%d: attach: only %d units configured.\n", 7366 unit, NBKTR); 7367 printf("brooktree%d: attach: invalid unit number.\n", unit); 7368 return; 7369 } 7370 7371 /* Enable Memory Mapping */ 7372 fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG); 7373 pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 2); 7374 7375 /* Enable Bus Mastering */ 7376 fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG); 7377 pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 4); 7378 7379 bktr->tag = tag; 7380 7381 7382 /* 7383 * Map control/status registers 7384 */ 7385 pci_map_mem( tag, PCI_MAP_REG_START, (vm_offset_t *) &bktr->base, 7386 &bktr->phys_base ); 7387 7388 /* 7389 * Disable the brooktree device 7390 */ 7391 bt848 = bktr->base; 7392 bt848->int_mask = ALL_INTS_DISABLED; 7393 bt848->gpio_dma_ctl = FIFO_RISC_DISABLED; 7394 7395#ifdef BROOKTREE_IRQ /* from the configuration file */ 7396 old_irq = pci_conf_read(tag, PCI_INTERRUPT_REG); 7397 pci_conf_write(tag, PCI_INTERRUPT_REG, BROOKTREE_IRQ); 7398 new_irq = pci_conf_read(tag, PCI_INTERRUPT_REG); 7399 printf("bktr%d: attach: irq changed from %d to %d\n", 7400 unit, (old_irq & 0xff), (new_irq & 0xff)); 7401#endif 7402 7403 /* 7404 * setup the interrupt handling routine 7405 */ 7406 pci_map_int(tag, bktr_intr, (void*) bktr, &net_imask); 7407 7408 7409 /* Update the Device Control Register */ 7410 /* on Bt878 and Bt879 cards */ 7411 fun = pci_conf_read(tag, 0x40); 7412 fun = fun | 1; /* Enable writes to the sub-system vendor ID */ 7413 7414#if defined( BKTR_430_FX_MODE ) 7415 if (bootverbose) printf("Using 430 FX chipset compatibilty mode\n"); 7416 fun = fun | 2; /* Enable Intel 430 FX compatibility mode */ 7417#endif 7418 7419#if defined( BKTR_SIS_VIA_MODE ) 7420 if (bootverbose) printf("Using SiS/VIA chipset compatibilty mode\n"); 7421 fun = fun | 4; /* Enable SiS/VIA compatibility mode (usefull for 7422 OPTi chipset motherboards too */ 7423#endif 7424 pci_conf_write(tag, 0x40, fun); 7425 7426 7427 /* XXX call bt848_i2c dependent attach() routine */ 7428#if (NSMBUS > 0) 7429 if (bt848_i2c_attach(unit, bktr->base, &bktr->i2c_sc)) 7430 printf("bktr%d: i2c_attach: can't attach\n", unit); 7431#endif 7432 7433 7434/* 7435 * PCI latency timer. 32 is a good value for 4 bus mastering slots, if 7436 * you have more than four, then 16 would probably be a better value. 7437 */ 7438#ifndef BROOKTREE_DEF_LATENCY_VALUE 7439#define BROOKTREE_DEF_LATENCY_VALUE 10 7440#endif 7441 latency = pci_conf_read(tag, PCI_LATENCY_TIMER); 7442 latency = (latency >> 8) & 0xff; 7443 if ( bootverbose ) { 7444 if (latency) 7445 printf("brooktree%d: PCI bus latency is", unit); 7446 else 7447 printf("brooktree%d: PCI bus latency was 0 changing to", 7448 unit); 7449 } 7450 if ( !latency ) { 7451 latency = BROOKTREE_DEF_LATENCY_VALUE; 7452 pci_conf_write(tag, PCI_LATENCY_TIMER, latency<<8); 7453 } 7454 if ( bootverbose ) { 7455 printf(" %d.\n", (int) latency); 7456 } 7457 7458 7459 /* read the pci device id and revision id */ 7460 fun = pci_conf_read(tag, PCI_ID_REG); 7461 rev = pci_conf_read(tag, PCIR_REVID) & 0x000000ff; 7462 7463 /* call the common attach code */ 7464 common_bktr_attach( bktr, unit, fun, rev ); 7465 7466 make_dev(&bktr_cdevsw, unit, 0, 0, 0444, "bktr%d", unit); 7467 make_dev(&bktr_cdevsw, unit+16, 0, 0, 0444, "tuner%d", unit); 7468 make_dev(&bktr_cdevsw, unit+32, 0, 0, 0444, "vbi%d", unit); 7469 7470} 7471 7472 7473/* 7474 * Special Memory Allocation 7475 */ 7476static vm_offset_t 7477get_bktr_mem( int unit, unsigned size ) 7478{ 7479 vm_offset_t addr = 0; 7480 7481 addr = vm_page_alloc_contig(size, 0, 0xffffffff, 1<<24); 7482 if (addr == 0) 7483 addr = vm_page_alloc_contig(size, 0, 0xffffffff, PAGE_SIZE); 7484 if (addr == 0) { 7485 printf("bktr%d: Unable to allocate %d bytes of memory.\n", 7486 unit, size); 7487 } 7488 7489 return( addr ); 7490} 7491 7492/*--------------------------------------------------------- 7493** 7494** BrookTree 848 character device driver routines 7495** 7496**--------------------------------------------------------- 7497*/ 7498 7499 7500#define VIDEO_DEV 0x00 7501#define TUNER_DEV 0x01 7502#define VBI_DEV 0x02 7503 7504#define UNIT(x) ((x) & 0x0f) 7505#define FUNCTION(x) ((x >> 4) & 0x0f) 7506 7507 7508/* 7509 * 7510 */ 7511int 7512bktr_open( dev_t dev, int flags, int fmt, struct proc *p ) 7513{ 7514 bktr_ptr_t bktr; | |
7515 int unit; | 7332 int unit; |
7516 7517 unit = UNIT( minor(dev) ); 7518 if (unit >= NBKTR) /* unit out of range */ 7519 return( ENXIO ); 7520 7521 bktr = &(brooktree[ unit ]); 7522 7523 if (!(bktr->flags & METEOR_INITALIZED)) /* device not found */ 7524 return( ENXIO ); 7525 7526 7527 if (bt848_card != -1) { 7528 if ((bt848_card >> 8 == unit ) && 7529 ( (bt848_card & 0xff) < Bt848_MAX_CARD )) { 7530 if ( bktr->bt848_card != (bt848_card & 0xff) ) { 7531 bktr->bt848_card = (bt848_card & 0xff); 7532 probeCard(bktr, FALSE); 7533 } 7534 } 7535 } 7536 7537 if (bt848_tuner != -1) { 7538 if ((bt848_tuner >> 8 == unit ) && 7539 ( (bt848_tuner & 0xff) < Bt848_MAX_TUNER )) { 7540 if ( bktr->bt848_tuner != (bt848_tuner & 0xff) ) { 7541 bktr->bt848_tuner = (bt848_tuner & 0xff); 7542 probeCard(bktr, FALSE); 7543 } 7544 } 7545 } 7546 7547 if (bt848_reverse_mute != -1) { 7548 if (((bt848_reverse_mute >> 8) == unit ) && 7549 ((bt848_reverse_mute & 0xff) < Bt848_MAX_TUNER) ) { 7550 bktr->reverse_mute = bt848_reverse_mute & 0xff; 7551 bt848_reverse_mute = -1; 7552 } 7553 } 7554 7555 7556 switch ( FUNCTION( minor(dev) ) ) { 7557 case VIDEO_DEV: 7558 return( video_open( bktr ) ); 7559 case TUNER_DEV: 7560 return( tuner_open( bktr ) ); 7561 case VBI_DEV: 7562 return( vbi_open( bktr ) ); 7563 } 7564 return( ENXIO ); 7565} 7566 7567 7568/* 7569 * 7570 */ 7571int 7572bktr_close( dev_t dev, int flags, int fmt, struct proc *p ) 7573{ | |
7574 bktr_ptr_t bktr; | 7333 bktr_ptr_t bktr; |
7575 int unit; | 7334 int revents = 0; |
7576 | 7335 |
7577 unit = UNIT( minor(dev) ); 7578 if (unit >= NBKTR) /* unit out of range */ 7579 return( ENXIO ); | 7336 unit = UNIT(minor(dev)); |
7580 | 7337 |
7581 bktr = &(brooktree[ unit ]); 7582 7583 switch ( FUNCTION( minor(dev) ) ) { 7584 case VIDEO_DEV: 7585 return( video_close( bktr ) ); 7586 case TUNER_DEV: 7587 return( tuner_close( bktr ) ); 7588 case VBI_DEV: 7589 return( vbi_close( bktr ) ); | 7338 /* Get the device data */ 7339 bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit); 7340 if (bktr == NULL) { 7341 /* the device is no longer valid/functioning */ 7342 return (ENXIO); |
7590 } 7591 | 7343 } 7344 |
7592 return( ENXIO ); 7593} | 7345 disable_intr(); |
7594 | 7346 |
7595/* 7596 * 7597 */ 7598int 7599bktr_read( dev_t dev, struct uio *uio, int ioflag ) 7600{ 7601 bktr_ptr_t bktr; 7602 int unit; 7603 7604 unit = UNIT(minor(dev)); 7605 if (unit >= NBKTR) /* unit out of range */ 7606 return( ENXIO ); | 7347 if (events & (POLLIN | POLLRDNORM)) { |
7607 | 7348 |
7608 bktr = &(brooktree[unit]); 7609 7610 switch ( FUNCTION( minor(dev) ) ) { 7611 case VIDEO_DEV: 7612 return( video_read( bktr, unit, dev, uio ) ); 7613 case VBI_DEV: 7614 return( vbi_read( bktr, dev, uio ) ); | 7349 switch ( FUNCTION( minor(dev) ) ) { 7350 case VBI_DEV: 7351 if(bktr->vbisize == 0) 7352 selrecord(p, &bktr->vbi_select); 7353 else 7354 revents |= events & (POLLIN | POLLRDNORM); 7355 break; 7356 } |
7615 } | 7357 } |
7616 return( ENXIO ); 7617} | |
7618 | 7358 |
7359 enable_intr(); |
|
7619 | 7360 |
7620/* 7621 * 7622 */ 7623int 7624bktr_write( dev_t dev, struct uio *uio, int ioflag ) 7625{ 7626 return( EINVAL ); /* XXX or ENXIO ? */ | 7361 return (revents); |
7627} 7628 | 7362} 7363 |
7629/* 7630 * 7631 */ 7632int 7633bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr ) 7634{ 7635 bktr_ptr_t bktr; 7636 int unit; | 7364#endif /* FreeBSD 4.x specific kernel interface routines */ |
7637 | 7365 |
7638 unit = UNIT(minor(dev)); 7639 if (unit >= NBKTR) /* unit out of range */ 7640 return( ENXIO ); | |
7641 | 7366 |
7642 bktr = &(brooktree[ unit ]); | 7367/**********************************/ 7368/* *** FreeBSD 2.2.x and 3.x *** */ 7369/**********************************/ |
7643 | 7370 |
7644 if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */ 7645 return( ENOMEM ); | 7371#if ((__FreeBSD__ == 2) || (__FreeBSD__ == 3)) 7372#endif /* FreeBSD 2.2.x and 3.x specific kernel interface routines */ |
7646 | 7373 |
7647 switch ( FUNCTION( minor(dev) ) ) { 7648 case VIDEO_DEV: 7649 return( video_ioctl( bktr, unit, cmd, arg, pr ) ); 7650 case TUNER_DEV: 7651 return( tuner_ioctl( bktr, unit, cmd, arg, pr ) ); 7652 } | |
7653 | 7374 |
7654 return( ENXIO ); 7655} | 7375/*****************/ 7376/* *** BSDI *** */ 7377/*****************/ |
7656 | 7378 |
7657/* 7658 * bktr_mmap. 7659 * Note: 2.2.5/2.2.6/2.2.7/3.0 users must manually 7660 * edit the following line and change "vm_offset_t" to "int"" 7661 */ 7662int bktr_mmap( dev_t dev, vm_offset_t offset, int nprot ) | 7379#if defined(__bsdi__) 7380#endif /* __bsdi__ BSDI specific kernel interface routines */ |
7663 | 7381 |
7664{ 7665 int unit; 7666 bktr_ptr_t bktr; | |
7667 | 7382 |
7668 unit = UNIT(minor(dev)); | 7383/*****************************/ 7384/* *** OpenBSD / NetBSD *** */ 7385/*****************************/ 7386#if defined(__NetBSD__) || defined(__OpenBSD__) 7387#endif /* __NetBSD__ || __OpenBSD__ */ |
7669 | 7388 |
7670 if (unit >= NBKTR || FUNCTION(minor(dev)) > 0) 7671 return( -1 ); | |
7672 | 7389 |
7673 bktr = &(brooktree[ unit ]); | |
7674 | 7390 |
7675 if (nprot & PROT_EXEC) 7676 return( -1 ); | 7391#endif /* FreeBSD, BSDI, NetBSD, OpenBSD */ |
7677 | 7392 |
7678 if (offset < 0) 7679 return( -1 ); | |
7680 | 7393 |
7681 if (offset >= bktr->alloc_pages * PAGE_SIZE) 7682 return( -1 ); 7683 7684 return( i386_btop(vtophys(bktr->bigbuf) + offset) ); 7685} 7686 7687#endif /* FreeBSD 2.2.x and 3.x specific kernel interface routines */ 7688 7689 7690 7691#endif /* !defined(__FreeBSD__) || (NBKTR > 0 && NPCI > 0) */ 7692 | |
7693/* Local Variables: */ 7694/* mode: C */ 7695/* c-indent-level: 8 */ 7696/* c-brace-offset: -8 */ 7697/* c-argdecl-indent: 8 */ 7698/* c-label-offset: -8 */ 7699/* c-continued-statement-offset: 8 */ 7700/* c-tab-always-indent: nil */ 7701/* tab-width: 8 */ 7702/* End: */ | 7394/* Local Variables: */ 7395/* mode: C */ 7396/* c-indent-level: 8 */ 7397/* c-brace-offset: -8 */ 7398/* c-argdecl-indent: 8 */ 7399/* c-label-offset: -8 */ 7400/* c-continued-statement-offset: 8 */ 7401/* c-tab-always-indent: nil */ 7402/* tab-width: 8 */ 7403/* End: */ |