bktr_core.c (65374) | bktr_core.c (65692) |
---|---|
1/* $FreeBSD: head/sys/dev/bktr/bktr_core.c 65374 2000-09-02 19:17:34Z phk $ */ | 1/* $FreeBSD: head/sys/dev/bktr/bktr_core.c 65692 2000-09-10 14:34:08Z roger $ */ |
2 3/* 4 * This is part of the Driver for Video Capture Cards (Frame grabbers) 5 * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879 6 * chipset. 7 * Copyright Roger Hardiman and Amancio Hasty. 8 * 9 * bktr_core : This deals with the Bt848/849/878/879 PCI Frame Grabber, --- 130 unchanged lines hidden (view full) --- 140#include <machine/ioctl_meteor.h> 141#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */ 142#include <dev/bktr/bktr_reg.h> 143#include <dev/bktr/bktr_tuner.h> 144#include <dev/bktr/bktr_card.h> 145#include <dev/bktr/bktr_audio.h> 146#include <dev/bktr/bktr_os.h> 147#include <dev/bktr/bktr_core.h> | 2 3/* 4 * This is part of the Driver for Video Capture Cards (Frame grabbers) 5 * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879 6 * chipset. 7 * Copyright Roger Hardiman and Amancio Hasty. 8 * 9 * bktr_core : This deals with the Bt848/849/878/879 PCI Frame Grabber, --- 130 unchanged lines hidden (view full) --- 140#include <machine/ioctl_meteor.h> 141#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */ 142#include <dev/bktr/bktr_reg.h> 143#include <dev/bktr/bktr_tuner.h> 144#include <dev/bktr/bktr_card.h> 145#include <dev/bktr/bktr_audio.h> 146#include <dev/bktr/bktr_os.h> 147#include <dev/bktr/bktr_core.h> |
148#if defined(BKTR_FREEBSD_MODULE) 149#include <dev/bktr/bktr_mem.h> 150#endif |
|
148 | 151 |
149#if (NSMBUS > 0) | 152#if defined(BKTR_USE_FREEBSD_SMBUS) |
150#include <dev/bktr/bktr_i2c.h> 151#include <dev/smbus/smbconf.h> 152#include <dev/iicbus/iiconf.h> 153#include "smbus_if.h" 154#include "iicbus_if.h" 155#endif 156 157const char * --- 279 unchanged lines hidden (view full) --- 437 438 439/* 440 * ioctls common to both video & tuner. 441 */ 442static int common_ioctl( bktr_ptr_t bktr, ioctl_cmd_t cmd, caddr_t arg ); 443 444 | 153#include <dev/bktr/bktr_i2c.h> 154#include <dev/smbus/smbconf.h> 155#include <dev/iicbus/iiconf.h> 156#include "smbus_if.h" 157#include "iicbus_if.h" 158#endif 159 160const char * --- 279 unchanged lines hidden (view full) --- 440 441 442/* 443 * ioctls common to both video & tuner. 444 */ 445static int common_ioctl( bktr_ptr_t bktr, ioctl_cmd_t cmd, caddr_t arg ); 446 447 |
445#if ((!defined(__FreeBSD__)) || (NSMBUS == 0) ) | 448#if !defined(BKTR_USE_FREEBSD_SMBUS) |
446/* 447 * i2c primitives for low level control of i2c bus. Added for MSP34xx control 448 */ 449static void i2c_start( bktr_ptr_t bktr); 450static void i2c_stop( bktr_ptr_t bktr); 451static int i2c_write_byte( bktr_ptr_t bktr, unsigned char data); 452static int i2c_read_byte( bktr_ptr_t bktr, unsigned char *data, int last ); 453#endif 454 455 456 457/* 458 * the common attach code, used by all OS versions. 459 */ 460void 461common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev ) 462{ | 449/* 450 * i2c primitives for low level control of i2c bus. Added for MSP34xx control 451 */ 452static void i2c_start( bktr_ptr_t bktr); 453static void i2c_stop( bktr_ptr_t bktr); 454static int i2c_write_byte( bktr_ptr_t bktr, unsigned char data); 455static int i2c_read_byte( bktr_ptr_t bktr, unsigned char *data, int last ); 456#endif 457 458 459 460/* 461 * the common attach code, used by all OS versions. 462 */ 463void 464common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev ) 465{ |
463 vm_offset_t buf; | 466 vm_offset_t buf = 0; 467 int need_to_allocate_memory = 1; |
464 465/***************************************/ 466/* *** OS Specific memory routines *** */ 467/***************************************/ 468#if defined(__NetBSD__) || defined(__OpenBSD__) 469 /* allocate space for dma program */ 470 bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, 471 DMA_PROG_ALLOC); --- 9 unchanged lines hidden (view full) --- 481 /* allocate space for pixel buffer */ 482 if ( BROOKTREE_ALLOC ) 483 buf = get_bktr_mem(bktr, &bktr->dm_mem, BROOKTREE_ALLOC); 484 else 485 buf = 0; 486#endif 487 488#if defined(__FreeBSD__) || defined(__bsdi__) | 468 469/***************************************/ 470/* *** OS Specific memory routines *** */ 471/***************************************/ 472#if defined(__NetBSD__) || defined(__OpenBSD__) 473 /* allocate space for dma program */ 474 bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, 475 DMA_PROG_ALLOC); --- 9 unchanged lines hidden (view full) --- 485 /* allocate space for pixel buffer */ 486 if ( BROOKTREE_ALLOC ) 487 buf = get_bktr_mem(bktr, &bktr->dm_mem, BROOKTREE_ALLOC); 488 else 489 buf = 0; 490#endif 491 492#if defined(__FreeBSD__) || defined(__bsdi__) |
489 /* allocate space for dma program */ 490 bktr->dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC); 491 bktr->odd_dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC); | |
492 | 493 |
493 /* allocte space for the VBI buffer */ 494 bktr->vbidata = get_bktr_mem(unit, VBI_DATA_SIZE); 495 bktr->vbibuffer = get_bktr_mem(unit, VBI_BUFFER_SIZE); | 494/* If this is a module, check if there is any currently saved contiguous memory */ 495#if defined(BKTR_FREEBSD_MODULE) 496 if (bktr_has_stored_addresses(unit) == 1) { 497 /* recover the addresses */ 498 bktr->dma_prog = bktr_retrieve_address(unit, BKTR_MEM_DMA_PROG); 499 bktr->odd_dma_prog = bktr_retrieve_address(unit, BKTR_MEM_ODD_DMA_PROG); 500 bktr->vbidata = bktr_retrieve_address(unit, BKTR_MEM_VBIDATA); 501 bktr->vbibuffer = bktr_retrieve_address(unit, BKTR_MEM_VBIBUFFER); 502 buf = bktr_retrieve_address(unit, BKTR_MEM_BUF); 503 need_to_allocate_memory = 0; 504 } 505#endif |
496 | 506 |
497 /* allocate space for pixel buffer */ 498 if ( BROOKTREE_ALLOC ) 499 buf = get_bktr_mem(unit, BROOKTREE_ALLOC); 500 else 501 buf = 0; | 507 if (need_to_allocate_memory == 1) { 508 /* allocate space for dma program */ 509 bktr->dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC); 510 bktr->odd_dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC); 511 512 /* allocte space for the VBI buffer */ 513 bktr->vbidata = get_bktr_mem(unit, VBI_DATA_SIZE); 514 bktr->vbibuffer = get_bktr_mem(unit, VBI_BUFFER_SIZE); 515 516 /* allocate space for pixel buffer */ 517 if ( BROOKTREE_ALLOC ) 518 buf = get_bktr_mem(unit, BROOKTREE_ALLOC); 519 else 520 buf = 0; 521 } 522#endif /* FreeBSD or BSDi */ 523 524 525/* If this is a module, save the current contiguous memory */ 526#if defined(BKTR_FREEBSD_MODULE) 527bktr_store_address(unit, BKTR_MEM_DMA_PROG, bktr->dma_prog); 528bktr_store_address(unit, BKTR_MEM_ODD_DMA_PROG, bktr->odd_dma_prog); 529bktr_store_address(unit, BKTR_MEM_VBIDATA, bktr->vbidata); 530bktr_store_address(unit, BKTR_MEM_VBIBUFFER, bktr->vbibuffer); 531bktr_store_address(unit, BKTR_MEM_BUF, buf); |
502#endif 503 | 532#endif 533 |
534 |
|
504 if ( bootverbose ) { 505 printf("%s: buffer size %d, addr 0x%x\n", 506 bktr_name(bktr), BROOKTREE_ALLOC, vtophys(buf)); 507 } 508 509 if ( buf != 0 ) { 510 bktr->bigbuf = buf; 511 bktr->alloc_pages = BROOKTREE_ALLOC_PAGES; --- 3191 unchanged lines hidden (view full) --- 3703 BT848_DATA_CTL_I2CSCL | \ 3704 BT848_DATA_CTL_I2CSDA) 3705 3706#define I2C_COMMAND_878 (I2CBITTIME_878 | \ 3707 BT848_DATA_CTL_I2CSCL | \ 3708 BT848_DATA_CTL_I2CSDA) 3709 3710/* Select between old i2c code and new iicbus / smbus code */ | 535 if ( bootverbose ) { 536 printf("%s: buffer size %d, addr 0x%x\n", 537 bktr_name(bktr), BROOKTREE_ALLOC, vtophys(buf)); 538 } 539 540 if ( buf != 0 ) { 541 bktr->bigbuf = buf; 542 bktr->alloc_pages = BROOKTREE_ALLOC_PAGES; --- 3191 unchanged lines hidden (view full) --- 3734 BT848_DATA_CTL_I2CSCL | \ 3735 BT848_DATA_CTL_I2CSDA) 3736 3737#define I2C_COMMAND_878 (I2CBITTIME_878 | \ 3738 BT848_DATA_CTL_I2CSCL | \ 3739 BT848_DATA_CTL_I2CSDA) 3740 3741/* Select between old i2c code and new iicbus / smbus code */ |
3711#if (defined(__FreeBSD__) && (NSMBUS > 0)) | 3742#if defined(BKTR_USE_FREEBSD_SMBUS) |
3712 3713/* 3714 * The hardware interface is actually SMB commands 3715 */ 3716int 3717i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 ) 3718{ 3719 char cmd; --- 129 unchanged lines hidden (view full) --- 3849 /* XXX errors ignored */ 3850 iicbus_start(IICBUS(bktr), bktr->remote_control_addr, 0 /* no timeout? */); 3851 iicbus_read(IICBUS(bktr), remote->data, 3, &read, IIC_LAST_READ, 0); 3852 iicbus_stop(IICBUS(bktr)); 3853 3854 return; 3855} 3856 | 3743 3744/* 3745 * The hardware interface is actually SMB commands 3746 */ 3747int 3748i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 ) 3749{ 3750 char cmd; --- 129 unchanged lines hidden (view full) --- 3880 /* XXX errors ignored */ 3881 iicbus_start(IICBUS(bktr), bktr->remote_control_addr, 0 /* no timeout? */); 3882 iicbus_read(IICBUS(bktr), remote->data, 3, &read, IIC_LAST_READ, 0); 3883 iicbus_stop(IICBUS(bktr)); 3884 3885 return; 3886} 3887 |
3857#else /* defined(__FreeBSD__) && (NSMBUS > 0) */ | 3888#else /* defined(BKTR_USE_FREEBSD_SMBUS) */ |
3858 3859/* 3860 * Program the i2c bus directly 3861 */ 3862int 3863i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 ) 3864{ 3865 u_long x; --- 239 unchanged lines hidden (view full) --- 4105 i2c_read_byte(bktr,&(remote->data[0]), 0); 4106 i2c_read_byte(bktr,&(remote->data[1]), 0); 4107 i2c_read_byte(bktr,&(remote->data[2]), 0); 4108 i2c_stop(bktr); 4109 4110 return; 4111} 4112 | 3889 3890/* 3891 * Program the i2c bus directly 3892 */ 3893int 3894i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 ) 3895{ 3896 u_long x; --- 239 unchanged lines hidden (view full) --- 4136 i2c_read_byte(bktr,&(remote->data[0]), 0); 4137 i2c_read_byte(bktr,&(remote->data[1]), 0); 4138 i2c_read_byte(bktr,&(remote->data[2]), 0); 4139 i2c_stop(bktr); 4140 4141 return; 4142} 4143 |
4113#endif /* defined(__FreeBSD__) && (NSMBUS > 0) */ | 4144#endif /* defined(BKTR_USE_FREEBSD_SMBUS) */ |
4114 4115 4116#if defined( I2C_SOFTWARE_PROBE ) 4117 4118/* 4119 * we are keeping this around for any parts that we need to probe 4120 * but that CANNOT be probed via an i2c read. 4121 * this is necessary because the hardware i2c mechanism --- 67 unchanged lines hidden --- | 4145 4146 4147#if defined( I2C_SOFTWARE_PROBE ) 4148 4149/* 4150 * we are keeping this around for any parts that we need to probe 4151 * but that CANNOT be probed via an i2c read. 4152 * this is necessary because the hardware i2c mechanism --- 67 unchanged lines hidden --- |