diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-01-05 01:24:54 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-01-05 01:24:54 +0000 |
commit | 2dd4305b1ca719879643d830e9d61cf4ec705bd1 (patch) | |
tree | 603c8f1d8c5ec01156991e1a5f5e63cabd94892b /sys/dev/pci | |
parent | cc22f49005177b3945061c1907714b81989a7768 (diff) |
endianess-free, works on macppc now, except for the fb endianess
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/bktr/bktr_card.c | 47 | ||||
-rw-r--r-- | sys/dev/pci/bktr/bktr_core.c | 1010 | ||||
-rw-r--r-- | sys/dev/pci/bktr/bktr_core.h | 8 | ||||
-rw-r--r-- | sys/dev/pci/bktr/bktr_os.c | 38 | ||||
-rw-r--r-- | sys/dev/pci/bktr/bktr_reg.h | 49 |
5 files changed, 634 insertions, 518 deletions
diff --git a/sys/dev/pci/bktr/bktr_card.c b/sys/dev/pci/bktr/bktr_card.c index bc34ab5a73c..81a4d7026c9 100644 --- a/sys/dev/pci/bktr/bktr_card.c +++ b/sys/dev/pci/bktr/bktr_card.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_card.c,v 1.4 2002/07/13 22:48:03 mickey Exp $ */ +/* $OpenBSD: bktr_card.c,v 1.5 2003/01/05 01:24:53 mickey Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_card.c,v 1.16 2000/10/31 13:09:56 roger Exp $ */ /* @@ -370,7 +370,7 @@ writeEEProm( bktr_ptr_t bktr, int offset, int count, u_char *data ) * and so do newer Bt878 based cards. */ int -readEEProm( bktr_ptr_t bktr, int offset, int count, u_char *data ) +readEEProm(bktr_ptr_t bktr, int offset, int count, u_char *data) { int x; int addr; @@ -476,9 +476,9 @@ static int locate_tuner_address( bktr_ptr_t bktr) { * range 0xa0 to 0xae. */ static int locate_eeprom_address( bktr_ptr_t bktr) { - if (i2cRead( bktr, 0xa0) != ABSENT) return 0xa0; - if (i2cRead( bktr, 0xac) != ABSENT) return 0xac; - if (i2cRead( bktr, 0xae) != ABSENT) return 0xae; + if (i2cRead(bktr, 0xa0) != ABSENT) return 0xa0; + if (i2cRead(bktr, 0xac) != ABSENT) return 0xac; + if (i2cRead(bktr, 0xae) != ABSENT) return 0xae; return -1; /* no eeprom found */ } @@ -536,7 +536,6 @@ static int locate_eeprom_address( bktr_ptr_t bktr) { #define PCI_VENDOR_FLYVIDEO_2 0x1852 #define PCI_VENDOR_PINNACLE_ALT 0xBD11 /* this is swapped w/ prod id */ - void probeCard( bktr_ptr_t bktr, int verbose, int unit ) { @@ -606,7 +605,8 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit ) bktr->card.eepromAddr = eeprom_i2c_address; bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE); - readEEProm(bktr, 0, 256, (u_char *) &eeprom ); + if (readEEProm(bktr, 0, 256, eeprom) && bootverbose) + printf("%s: error reading EEPROM\n", bktr_name(bktr)); byte_252 = (unsigned int)eeprom[252]; byte_253 = (unsigned int)eeprom[253]; byte_254 = (unsigned int)eeprom[254]; @@ -615,7 +615,7 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit ) subsystem_id = (byte_252 << 8) | byte_253; subsystem_vendor_id = (byte_254 << 8) | byte_255; - if ( bootverbose ) + if (bootverbose) printf("%s: subsystem 0x%04x 0x%04x\n", bktr_name(bktr), subsystem_vendor_id, subsystem_id); @@ -655,30 +655,35 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit ) goto checkTuner; } - if (subsystem_vendor_id == PCI_VENDOR_LEADTEK_ALT) { + if (subsystem_vendor_id == PCI_VENDOR_LEADTEK) { bktr->card = cards[ (card = CARD_LEADTEK) ]; bktr->card.eepromAddr = eeprom_i2c_address; bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE); goto checkTuner; } - if (subsystem_vendor_id == PCI_VENDOR_PINNACLE_ALT) { + if (subsystem_vendor_id == PCI_VENDOR_PINNACLE) { bktr->card = cards[ (card = CARD_MIRO) ]; bktr->card.eepromAddr = eeprom_i2c_address; bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE); goto checkTuner; } + if (subsystem_vendor_id == PCI_VENDOR_TERRATEC) { + bktr->card = cards[ (card = CARD_TERRATVPLUS) ]; + bktr->card.eepromAddr = eeprom_i2c_address; + bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE); + goto checkTuner; + } + /* Vendor is unknown. We will use the standard probe code */ /* which may not give best results */ - printf("%s: Warning - card vendor 0x%04x (model 0x%04x) unknown.\n", - bktr_name(bktr), subsystem_vendor_id, subsystem_id); - } - else - { - printf("%s: Card has no configuration EEPROM. Cannot determine card make.\n", - bktr_name(bktr)); - } + printf("%s: Warning " + "- card vendor 0x%04x (model 0x%04x) unknown.\n", + bktr_name(bktr), subsystem_vendor_id, subsystem_id); + } else + printf("%s: Card has no configuration EEPROM. " + "Cannot determine card make.\n", bktr_name(bktr)); } /* end of bt878/bt879 card detection code */ /* If we get to this point, we must have a Bt848/848A/849A card */ @@ -708,7 +713,7 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit ) bktr->card = cards[ (card = CARD_UNKNOWN) ]; bktr->card.eepromAddr = PFC8582_WADDR; bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE); - readEEProm(bktr, 0, 128, (u_char *) &eeprom ); + readEEProm(bktr, 0, 128, eeprom ); /* For Hauppauge, check the EEPROM begins with 0x84 */ if (eeprom[0] == 0x84) { @@ -907,7 +912,7 @@ checkTuner: unsigned char tuner_code; unsigned char no_audio_mux; - readEEProm(bktr, 0, 128, (u_char *) &eeprom ); + readEEProm(bktr, 0, 128, eeprom); /* LOCATE THE EEPROM DATA BLOCKS */ block_1 = &eeprom[0]; @@ -1039,7 +1044,7 @@ checkTuner: /* Extract information from the EEPROM data */ - readEEProm(bktr, 0, 128, (u_char *) &eeprom ); + readEEProm(bktr, 0, 128, eeprom); tuner_make = (eeprom[0x41] & 0x7); tuner_tv_fm = (eeprom[0x41] & 0x18) >> 3; diff --git a/sys/dev/pci/bktr/bktr_core.c b/sys/dev/pci/bktr/bktr_core.c index 5e7b6a24d6c..cbe8e87cb27 100644 --- a/sys/dev/pci/bktr/bktr_core.c +++ b/sys/dev/pci/bktr/bktr_core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_core.c,v 1.5 2002/04/30 23:18:38 mickey Exp $ */ +/* $OpenBSD: bktr_core.c,v 1.6 2003/01/05 01:24:53 mickey Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_core.c,v 1.114 2000/10/31 13:09:56 roger Exp $ */ /* @@ -18,7 +18,7 @@ /* The Brooktree BT848 Driver driver is based upon Mark Tinguely and - Jim Lowe's driver for the Matrox Meteor PCI card . The + Jim Lowe's driver for the Matrox Meteor PCI card . The Philips SAA 7116 and SAA 7196 are very different chipsets than the BT848. @@ -28,7 +28,7 @@ */ /* - * 1. Redistributions of source code must retain the + * 1. Redistributions of source code must retain the * Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman * All rights reserved. * @@ -44,7 +44,7 @@ * must display the following acknowledgement: * This product includes software developed by Amancio Hasty and * Roger Hardiman - * 4. The name of the author may not be used to endorse or promote products + * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR @@ -64,7 +64,7 @@ /* - * 1. Redistributions of source code must retain the + * 1. Redistributions of source code must retain the * Copyright (c) 1995 Mark Tinguely and Jim Lowe * All rights reserved. * @@ -79,7 +79,7 @@ * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Mark Tinguely and Jim Lowe - * 4. The name of the author may not be used to endorse or promote products + * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR @@ -196,10 +196,9 @@ typedef unsigned int uintptr_t; #ifdef __NetBSD__ #include <uvm/uvm_extern.h> -#else -#include <uvm/uvm_extern.h> /* for vtophys */ -#include <uvm/uvm_pmap.h> /* for vtophys */ +#endif +#ifdef __OpenBSD__ #include <dev/rndvar.h> #endif @@ -242,11 +241,11 @@ typedef u_char bool_t; /* 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 + 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 * @@ -311,7 +310,7 @@ static const struct format_params format_params[] = { }; /* - * Table of supported Pixel Formats + * Table of supported Pixel Formats */ static const struct meteor_pixfmt_internal { @@ -435,9 +434,8 @@ static void rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, static void build_dma_prog( bktr_ptr_t bktr, char i_flag ); static bool_t getline(bktr_reg_t *, int); -static bool_t notclipped(bktr_reg_t * , int , int); -static bool_t split(bktr_reg_t *, volatile u_long **, int, u_long, int, - volatile u_char ** , int ); +static bool_t notclipped(bktr_reg_t * , int , int); +static bool_t split(bktr_reg_t *, u_int **, int, u_int, int, u_int * , int); static void start_capture( bktr_ptr_t bktr, unsigned type ); static void set_fps( bktr_ptr_t bktr, u_short fps ); @@ -471,7 +469,7 @@ static int i2c_read_byte( bktr_ptr_t bktr, unsigned char *data, int last ); /* * the common attach code, used by all OS versions. */ -void +void common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev ) { vm_offset_t buf = 0; @@ -481,19 +479,17 @@ common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev ) /***************************************/ #if defined(__NetBSD__) || defined(__OpenBSD__) /* allocate space for dma program */ - bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, - DMA_PROG_ALLOC); + bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, DMA_PROG_ALLOC); bktr->odd_dma_prog = get_bktr_mem(bktr, &bktr->dm_oprog, - DMA_PROG_ALLOC); + DMA_PROG_ALLOC); /* allocate space for the VBI buffer */ - bktr->vbidata = get_bktr_mem(bktr, &bktr->dm_vbidata, - VBI_DATA_SIZE); + bktr->vbidata = get_bktr_mem(bktr, &bktr->dm_vbidata, VBI_DATA_SIZE); bktr->vbibuffer = get_bktr_mem(bktr, &bktr->dm_vbibuffer, - VBI_BUFFER_SIZE); + VBI_BUFFER_SIZE); /* allocate space for pixel buffer */ - if ( BROOKTREE_ALLOC ) + if (BROOKTREE_ALLOC) buf = get_bktr_mem(bktr, &bktr->dm_mem, BROOKTREE_ALLOC); else buf = 0; @@ -545,17 +541,21 @@ bktr_store_address(unit, BKTR_MEM_BUF, buf); if ( bootverbose ) { printf("%s: buffer size %d, addr 0x%x\n", - bktr_name(bktr), BROOKTREE_ALLOC, vtophys(buf)); + bktr_name(bktr), BROOKTREE_ALLOC, +#ifdef __FreeBSD__ + vtophys(buf)); +#else + bktr->dm_prog->dm_segs->ds_addr); +#endif } - if ( buf != 0 ) { + if (buf != 0) { bktr->bigbuf = buf; bktr->alloc_pages = BROOKTREE_ALLOC_PAGES; - bzero((caddr_t) bktr->bigbuf, BROOKTREE_ALLOC); + bzero((void *)bktr->bigbuf, BROOKTREE_ALLOC); } else { bktr->alloc_pages = 0; } - bktr->flags = METEOR_INITALIZED | METEOR_AUTOMODE | METEOR_DEV0 | METEOR_RGB16; @@ -567,17 +567,14 @@ bktr_store_address(unit, BKTR_MEM_BUF, buf); bktr->pixfmt = oformat_meteor_to_bt( bktr->format ); bktr->pixfmt_compat = TRUE; - bktr->vbiinsert = 0; bktr->vbistart = 0; bktr->vbisize = 0; bktr->vbiflags = 0; - /* using the pci device id and revision id */ /* and determine the card type */ - if (PCI_VENDOR(pci_id) == PCI_VENDOR_BROOKTREE) - { + if (PCI_VENDOR(pci_id) == PCI_VENDOR_BROOKTREE) { switch (PCI_PRODUCT(pci_id)) { case PCI_PRODUCT_BROOKTREE_BT848: if (rev == 0x12) @@ -595,7 +592,7 @@ bktr_store_address(unit, BKTR_MEM_BUF, buf); bktr->id = BROOKTREE_879; break; } - }; + } bktr->clr_on_start = FALSE; @@ -616,21 +613,22 @@ bktr_store_address(unit, BKTR_MEM_BUF, buf); bktr->msp_source_selected = -1; bktr->audio_mux_present = 1; - probeCard( bktr, TRUE, unit ); + probeCard(bktr, TRUE, unit); /* Initialise any MSP34xx or TDA98xx audio chips */ - init_audio_devices( bktr ); - + init_audio_devices(bktr); } /* Copy the vbi lines from 'vbidata' into the circular buffer, 'vbibuffer'. - * The circular buffer holds 'n' fixed size data blocks. - * vbisize is the number of bytes in the circular buffer - * vbiread is the point we reading data out of the circular buffer - * vbiinsert is the point we insert data into the circular buffer + * The circular buffer holds 'n' fixed size data blocks. + * vbisize is the number of bytes in the circular buffer + * vbiread is the point we reading data out of the circular buffer + * vbiinsert is the point we insert data into the circular buffer */ -static void vbidecode(bktr_ptr_t bktr) { +static void +vbidecode(bktr_ptr_t bktr) +{ unsigned char *dest; unsigned int *seq_dest; @@ -653,7 +651,6 @@ static void vbidecode(bktr_ptr_t bktr) { /* This can wrap around */ bktr->vbi_sequence_number++; - /* Increment the vbiinsert pointer */ /* This can wrap around */ bktr->vbiinsert += VBI_DATA_SIZE; @@ -661,7 +658,6 @@ static void vbidecode(bktr_ptr_t bktr) { /* And increase the amount of vbi data in the buffer */ bktr->vbisize = bktr->vbisize + VBI_DATA_SIZE; - } @@ -671,17 +667,15 @@ static void vbidecode(bktr_ptr_t bktr) { * In the OS specific section, bktr_intr() is defined which calls this * common interrupt handler. */ -int +int common_bktr_intr( void *arg ) -{ - bktr_ptr_t bktr; - u_long bktr_status; - u_char dstatus; - u_long field; - u_long w_field; - u_long req_field; - - bktr = (bktr_ptr_t) arg; +{ + bktr_ptr_t bktr = (bktr_ptr_t) arg; + u_int bktr_status; + u_char dstatus; + u_int field; + u_int w_field; + u_int req_field; /* * check to see if any interrupts are unmasked on this device. If @@ -689,7 +683,7 @@ common_bktr_intr( void *arg ) * interrupt dispatch list. */ if (INL(bktr, BKTR_INT_MASK) == ALL_INTS_DISABLED) - return 0; /* bail out now, before we do something we + return 0; /* bail out now, before we do something we shouldn't */ if (!(bktr->flags & METEOR_OPEN)) { @@ -724,8 +718,8 @@ common_bktr_intr( void *arg ) /* BT848_INT_FDSR | */ BT848_INT_PPERR | BT848_INT_RIPERR | BT848_INT_PABORT | - BT848_INT_OCERR | BT848_INT_SCERR) ) != 0) - || ((INB(bktr, BKTR_TDEC) == 0) && (bktr_status & TDEC_BITS)) ) { + BT848_INT_OCERR | BT848_INT_SCERR) ) != 0) + || ((INB(bktr, BKTR_TDEC) == 0) && (bktr_status & TDEC_BITS)) ) { u_short tdec_save = INB(bktr, BKTR_TDEC); @@ -737,7 +731,7 @@ common_bktr_intr( void *arg ) /* Reset temporal decimation counter */ OUTB(bktr, BKTR_TDEC, 0); OUTB(bktr, BKTR_TDEC, tdec_save); - + /* Reset to no-fields captured state */ if (bktr->flags & (METEOR_CONTIN | METEOR_SYNCAP)) { switch(bktr->flags & METEOR_ONLY_FIELDS_MASK) { @@ -753,7 +747,11 @@ common_bktr_intr( void *arg ) } } +#ifdef __FreeBSD__ OUTL(bktr, BKTR_RISC_STRT_ADD, vtophys(bktr->dma_prog)); +#else + OUTL(bktr, BKTR_RISC_STRT_ADD, bktr->dm_prog->dm_segs->ds_addr); +#endif OUTW(bktr, BKTR_GPIO_DMA_CTL, FIFO_ENABLED); OUTW(bktr, BKTR_GPIO_DMA_CTL, bktr->capcontrol); @@ -785,32 +783,29 @@ common_bktr_intr( void *arg ) /* * Disable future interrupts if a capture mode is not selected. - * This can happen when we are in the process of closing or + * This can happen when we are in the process of closing or * changing capture modes, otherwise it shouldn't happen. */ if (!(bktr->flags & METEOR_CAP_MASK)) OUTB(bktr, BKTR_CAP_CTL, CAPTURE_OFF); - /* Determine which field generated this interrupt */ field = ( bktr_status & BT848_INT_FIELD ) ? EVEN_F : ODD_F; - /* * Process the VBI data if it is being captured. We do this once * both Odd and Even VBI data is captured. Therefore we do this * in the Even field interrupt handler. */ - if ( (bktr->vbiflags & VBI_CAPTURE) - &&(bktr->vbiflags & VBI_OPEN) - &&(field==EVEN_F)) { + if ((bktr->vbiflags & (VBI_CAPTURE|VBI_OPEN)) == + (VBI_CAPTURE|VBI_OPEN) && (field == EVEN_F)) { /* Put VBI data into circular buffer */ - vbidecode(bktr); + vbidecode(bktr); /* If someone is blocked on reading from /dev/vbi, wake them */ if (bktr->vbi_read_blocked) { bktr->vbi_read_blocked = FALSE; - wakeup(VBI_SLEEP); + wakeup(VBI_SLEEP); } /* If someone has a select() on /dev/vbi, inform them */ @@ -821,8 +816,6 @@ common_bktr_intr( void *arg ) #endif selwakeup(&bktr->vbi_select); } - - } @@ -838,7 +831,7 @@ common_bktr_intr( void *arg ) switch ( bktr->flags & METEOR_ONLY_FIELDS_MASK ) { case METEOR_ONLY_ODD_FIELDS : req_field = ODD_F ; break; case METEOR_ONLY_EVEN_FIELDS : req_field = EVEN_F ; break; - default : req_field = (ODD_F|EVEN_F); + default : req_field = (ODD_F|EVEN_F); break; } @@ -879,11 +872,11 @@ common_bktr_intr( void *arg ) if (!(bktr->flags & METEOR_WANT_MASK)) { bktr->frames_captured++; /* - * post the completion time. + * post the completion time. */ if (bktr->flags & METEOR_WANT_TS) { struct timeval *ts; - + if ((u_int) bktr->alloc_pages * PAGE_SIZE <= (bktr->frame_size + sizeof(struct timeval))) { ts =(struct timeval *)bktr->bigbuf + @@ -894,7 +887,7 @@ common_bktr_intr( void *arg ) microtime(ts); } } - + /* * Wake up the user in single capture mode. @@ -954,7 +947,7 @@ common_bktr_intr( void *arg ) /* - * + * */ extern int bt848_format; /* used to set the default format, PAL or NTSC */ int @@ -983,10 +976,10 @@ video_open( bktr_ptr_t bktr ) video_format = 1; #endif - if (bt848_format == 0 ) + if (bt848_format == 0 ) video_format = 0; - if (bt848_format == 1 ) + if (bt848_format == 1 ) video_format = 1; if (video_format == 1 ) { @@ -1055,7 +1048,7 @@ video_open( bktr_ptr_t bktr ) bktr->capture_area_enabled = FALSE; OUTL(bktr, BKTR_INT_MASK, BT848_INT_MYSTERYBIT); /* if you take this out triton - based motherboards will + based motherboards will operate unreliably */ return( 0 ); } @@ -1082,13 +1075,13 @@ vbi_open( bktr_ptr_t bktr ) } /* - * + * */ int tuner_open( bktr_ptr_t bktr ) { if ( !(bktr->tflags & TUNER_INITALIZED) ) /* device not found */ - return( ENXIO ); + return( ENXIO ); if ( bktr->tflags & TUNER_OPEN ) /* already open */ return( 0 ); @@ -1108,7 +1101,7 @@ tuner_open( bktr_ptr_t bktr ) /* Initialise any audio chips, eg MSP34xx or TDA98xx */ init_audio_devices( bktr ); - + return( 0 ); } @@ -1116,7 +1109,7 @@ tuner_open( bktr_ptr_t bktr ) /* - * + * */ int video_close( bktr_ptr_t bktr ) @@ -1187,7 +1180,7 @@ video_read(bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio) OUTB(bktr, BKTR_CAP_CTL, bktr->bktr_cap_ctl); - count = bktr->rows * bktr->cols * + count = bktr->rows * bktr->cols * pixfmt_table[ bktr->pixfmt ].public.Bpp; if ((int) uio->uio_iov->iov_len < count) @@ -1224,7 +1217,7 @@ video_read(bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio) * The buffer holds vbi data blocks which are the same size * vbiinsert is the position we will insert the next item into the buffer * vbistart is the actual position in the buffer we want to read from - * vbisize is the exact number of bytes in the buffer left to read + * vbisize is the exact number of bytes in the buffer left to read */ int vbi_read(bktr_ptr_t bktr, struct uio *uio, int ioflag) @@ -1245,7 +1238,7 @@ vbi_read(bktr_ptr_t bktr, struct uio *uio, int ioflag) } /* Now we have some data to give to the user */ - + /* We cannot read more bytes than there are in * the circular buffer */ @@ -1259,7 +1252,7 @@ vbi_read(bktr_ptr_t bktr, struct uio *uio, int ioflag) /* We need to wrap around */ readsize2 = VBI_BUFFER_SIZE - bktr->vbistart; - status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize2, uio); + status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize2, uio); status += uiomove((caddr_t)bktr->vbibuffer, (readsize - readsize2), uio); } else { /* We do not need to wrap around */ @@ -1320,10 +1313,8 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro clip rectangle . The first clip rectangle is clip_list[0]. */ - - - if (bktr->max_clip_node == 0 && - (bktr->clip_list[0].y_min != 0 && + if (bktr->max_clip_node == 0 && + (bktr->clip_list[0].y_min != 0 && bktr->clip_list[0].y_max != 0)) { return EINVAL; } @@ -1345,7 +1336,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro if (bktr->clip_list[i].x_min >= bktr->clip_list[i].x_max || bktr->clip_list[i].y_min >= bktr->clip_list[i].y_max || bktr->clip_list[i].x_min < 0 || - bktr->clip_list[i].x_max < 0 || + bktr->clip_list[i].x_max < 0 || bktr->clip_list[i].y_min < 0 || bktr->clip_list[i].y_max < 0 ) { bktr->max_clip_node = 0; @@ -1399,7 +1390,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro break; } - bktr->dma_prog_loaded = FALSE; + bktr->dma_prog_loaded = FALSE; break; case METEORSFMT: /* set input format */ @@ -1411,7 +1402,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro case METEOR_FMT_NTSC: bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | METEOR_NTSC; - OUTB(bktr, BKTR_IFORM, temp_iform | BT848_IFORM_F_NTSCM | + OUTB(bktr, BKTR_IFORM, temp_iform | BT848_IFORM_F_NTSCM | format_params[BT848_IFORM_F_NTSCM].iform_xtsel); OUTB(bktr, BKTR_ADELAY, format_params[BT848_IFORM_F_NTSCM].adelay); OUTB(bktr, BKTR_BDELAY, format_params[BT848_IFORM_F_NTSCM].bdelay); @@ -1438,7 +1429,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro default: return( EINVAL ); } - bktr->dma_prog_loaded = FALSE; + bktr->dma_prog_loaded = FALSE; break; case METEORGFMT: /* get input format */ @@ -1449,7 +1440,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro case BT848GFMT: /* get input format */ *(u_long *)arg = INB(bktr, BKTR_IFORM) & BT848_IFORM_FORMAT; break; - + case METEORSCOUNT: /* (re)set error counts */ counts = (struct meteor_counts *) arg; bktr->fifo_errors = counts->fifo_errors; @@ -1503,7 +1494,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro case METEORSBRIG: /* set brightness */ char_temp = ( *(u_char *)arg & 0xff) - 128; OUTB(bktr, BKTR_BRIGHT, char_temp); - + break; case METEORGBRIG: /* get brightness */ @@ -1599,7 +1590,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro OUTW(bktr, BKTR_GPIO_DMA_CTL, bktr->capcontrol); OUTL(bktr, BKTR_INT_MASK, BT848_INT_MYSTERYBIT | - BT848_INT_RISCI | + BT848_INT_RISCI | BT848_INT_VSYNC | BT848_INT_FMTCHG); @@ -1625,8 +1616,8 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro break; case METEOR_CAP_CONTINOUS: - if (bktr->bigbuf==0) /* no frame buffer allocated */ - return( ENOMEM ); + if (bktr->bigbuf == 0) /* no frame buffer allocated */ + return (ENOMEM); /* already capturing */ if (temp & METEOR_CAP_MASK) return( EIO ); @@ -1649,7 +1640,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro dump_bt848( bt848 ); #endif break; - + case METEOR_CAP_STOP_CONT: if (bktr->flags & METEOR_CONTIN) { /* turn off capture */ @@ -1761,16 +1752,16 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro if (buf != 0) { kmem_free(kernel_map, bktr->bigbuf, (bktr->alloc_pages * PAGE_SIZE)); -#endif +#endif bktr->bigbuf = buf; bktr->alloc_pages = temp; if (bootverbose) - printf( - "%s: ioctl: Allocating %d bytes\n", - bktr_name(bktr), temp*PAGE_SIZE); - } - else + printf("%s: ioctl: " + "Allocating %d bytes\n", + bktr_name(bktr), + temp * PAGE_SIZE); + } else error = ENOMEM; } } @@ -1795,7 +1786,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro break; case METEOR_GEO_YUV_422: bktr->format = METEOR_GEO_YUV_422; - if (geo->oformat & METEOR_GEO_YUV_12) + if (geo->oformat & METEOR_GEO_YUV_12) bktr->format = METEOR_GEO_YUV_12; break; case METEOR_GEO_YUV_PACKED: @@ -1860,10 +1851,10 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro bktr->capture_area_x_size = cap_area->x_size; bktr->capture_area_y_size = cap_area->y_size; bktr->capture_area_enabled = TRUE; - + bktr->dma_prog_loaded = FALSE; break; - + case BT848_GCAPAREA: /* get capture area of each video frame */ cap_area = (struct bktr_capture_area *) arg; if (bktr->capture_area_enabled == FALSE) { @@ -1913,7 +1904,7 @@ tuner_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro remote_read(bktr, (struct bktr_remote *)arg); break; -#if defined( TUNER_AFC ) +#if defined(TUNER_AFC) case TVTUNER_SETAFC: bktr->tuner.afc = (*(int *)arg != 0); break; @@ -2222,7 +2213,7 @@ tuner_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro bktr->tuner.radio_mode = *(unsigned char *)arg; break; - case RADIO_GETFREQ: + case RADIO_GETFREQ: *(unsigned long *)arg = bktr->tuner.frequency; break; @@ -2258,15 +2249,15 @@ tuner_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro *(unsigned long *)arg = temp; break; - /* Luigi's I2CWR ioctl */ + /* Luigi's I2CWR ioctl */ case BT848_I2CWR: par = *(u_long *)arg; write = (par >> 24) & 0xff ; i2c_addr = (par >> 16) & 0xff ; i2c_port = (par >> 8) & 0xff ; data = (par) & 0xff ; - - if (write) { + + if (write) { i2cWrite( bktr, i2c_addr, i2c_port, data); } else { data = i2cRead( bktr, i2c_addr); @@ -2408,7 +2399,7 @@ common_ioctl( bktr_ptr_t bktr, ioctl_cmd_t cmd, caddr_t arg ) set_audio( bktr, AUDIO_EXTERN ); break; - } + } default: return( EINVAL ); @@ -2429,7 +2420,7 @@ common_ioctl( bktr_ptr_t bktr, ioctl_cmd_t cmd, caddr_t arg ) | pixfmt_swap_flags( bktr->pixfmt )); bktr->pixfmt_compat = FALSE; break; - + case METEORGACTPIXFMT: *(int *)arg = bktr->pixfmt; break; @@ -2441,7 +2432,7 @@ common_ioctl( bktr_ptr_t bktr, ioctl_cmd_t cmd, caddr_t arg ) if (( pixfmt < 0 ) || ( pixfmt >= PIXFMT_TABLE_SIZE )) return( EINVAL ); - memcpy( pf_pub, &pixfmt_table[ pixfmt ].public, + memcpy( pf_pub, &pixfmt_table[ pixfmt ].public, sizeof( *pf_pub ) ); /* Patch in our format index */ @@ -2477,14 +2468,14 @@ common_ioctl( bktr_ptr_t bktr, ioctl_cmd_t cmd, caddr_t arg ) /* - * + * */ -#ifdef BT848_DEBUG +#ifdef BT848_DEBUG static int dump_bt848( bktr_ptr_t bktr ) { int r[60]={ - 4, 8, 0xc, 0x8c, 0x10, 0x90, 0x14, 0x94, + 4, 8, 0xc, 0x8c, 0x10, 0x90, 0x14, 0x94, 0x18, 0x98, 0x1c, 0x9c, 0x20, 0xa0, 0x24, 0xa4, 0x28, 0x2c, 0xac, 0x30, 0x34, 0x38, 0x3c, 0x40, 0xc0, 0x48, 0x4c, 0xcc, 0x50, 0xd0, 0xd4, 0x60, @@ -2495,7 +2486,7 @@ dump_bt848( bktr_ptr_t bktr ) for (i = 0; i < 40; i+=4) { printf("%s: Reg:value : \t%x:%x \t%x:%x \t %x:%x \t %x:%x\n", - bktr_name(bktr), + bktr_name(bktr), r[i], INL(bktr, r[i]), r[i+1], INL(bktr, r[i+1]), r[i+2], INL(bktr, r[i+2]), @@ -2503,7 +2494,7 @@ dump_bt848( bktr_ptr_t bktr ) } printf("%s: INT STAT %x \n", bktr_name(bktr), - INL(bktr, BKTR_INT_STAT)); + INL(bktr, BKTR_INT_STAT)); printf("%s: Reg INT_MASK %x \n", bktr_name(bktr), INL(bktr, BKTR_INT_MASK)); printf("%s: Reg GPIO_DMA_CTL %x \n", bktr_name(bktr), @@ -2568,7 +2559,7 @@ bool_t notclipped (bktr_reg_t * bktr, int x, int width) { bktr->yclip = -1; bktr->yclip2 = -1; bktr->current_col = 0; - + if (bktr->max_clip_node == 0 ) return TRUE; clip_node = (bktr_clip_t *) &bktr->clip_list[0]; @@ -2579,16 +2570,16 @@ bool_t notclipped (bktr_reg_t * bktr, int x, int width) { bktr->clip_start = i; return FALSE; } - } - + } + return TRUE; -} +} bool_t getline(bktr_reg_t *bktr, int x ) { int i, j; bktr_clip_t * clip_node ; - - if (bktr->line_length == 0 || + + if (bktr->line_length == 0 || bktr->current_col >= bktr->line_length) return FALSE; bktr->y = min(bktr->last_y, bktr->line_length); @@ -2605,7 +2596,7 @@ bool_t getline(bktr_reg_t *bktr, int x ) { bktr->yclip2 = min(clip_node->y_max, bktr->line_length); bktr->last_y = bktr->yclip2; bktr->clip_start = i; - + for (j = i+1; j < bktr->max_clip_node; j++ ) { clip_node = (bktr_clip_t *) &bktr->clip_list[j]; if (x >= clip_node->x_min && x <= clip_node->x_max) { @@ -2613,11 +2604,11 @@ bool_t getline(bktr_reg_t *bktr, int x ) { bktr->yclip2 = min(clip_node->y_max, bktr->line_length); bktr->last_y = bktr->yclip2; bktr->clip_start = j; - } + } } else break ; - } + } return TRUE; - } + } } } @@ -2627,10 +2618,11 @@ bool_t getline(bktr_reg_t *bktr, int x ) { } return FALSE; } - -static bool_t split(bktr_reg_t * bktr, volatile u_long **dma_prog, int width , - u_long operation, int pixel_width, - volatile u_char ** target_buffer, int cols ) { + +static bool_t +split(bktr_reg_t *bktr, u_int **dma_prog, int width, u_int operation, + int pixel_width, u_int *target_buffer, int cols) +{ u_long flag, flag2; const struct meteor_pixfmt *pf = &pixfmt_table[ bktr->pixfmt ].public; @@ -2642,7 +2634,7 @@ static bool_t split(bktr_reg_t * bktr, volatile u_long **dma_prog, int width , /* must be Blue. */ start_skip = 0; if (( pf->type == METEOR_PIXTYPE_RGB ) && ( pf->Bpp == 3 )) - switch ( ((uintptr_t) (volatile void *) *target_buffer) % 4 ) { + switch ((*target_buffer) % 4) { case 2 : start_skip = 4 ; break; case 1 : start_skip = 8 ; break; } @@ -2654,18 +2646,18 @@ static bool_t split(bktr_reg_t * bktr, volatile u_long **dma_prog, int width , flag = OP_SOL; } else if (bktr->current_col == cols) { flag = OP_EOL; - } else flag = 0; + } else flag = 0; skip = 0; if (( flag & OP_SOL ) && ( start_skip > 0 )) { - *(*dma_prog)++ = OP_SKIP | OP_SOL | start_skip; + *(*dma_prog)++ = htole32(OP_SKIP | OP_SOL | start_skip); flag &= ~OP_SOL; skip = start_skip; } - *(*dma_prog)++ = operation | flag | (width * pixel_width - skip); - if (operation != OP_SKIP ) - *(*dma_prog)++ = (uintptr_t) (volatile void *) *target_buffer; + *(*dma_prog)++ = htole32(operation | flag | (width * pixel_width - skip)); + if (operation != OP_SKIP ) + *(*dma_prog)++ = htole32(*target_buffer); *target_buffer += width * pixel_width; bktr->current_col += width; @@ -2688,26 +2680,27 @@ static bool_t split(bktr_reg_t * bktr, volatile u_long **dma_prog, int width , skip = 0; if (( flag & OP_SOL ) && ( start_skip > 0 )) { - *(*dma_prog)++ = OP_SKIP | OP_SOL | start_skip; + *(*dma_prog)++ = htole32(OP_SKIP | OP_SOL | start_skip); flag &= ~OP_SOL; skip = start_skip; } - *(*dma_prog)++ = operation | flag | - (width * pixel_width / 2 - skip); - if (operation != OP_SKIP ) - *(*dma_prog)++ = (uintptr_t) (volatile void *) *target_buffer ; - *target_buffer += (width * pixel_width / 2) ; + *(*dma_prog)++ = htole32(operation | flag | + (width * pixel_width / 2 - skip)); + if (operation != OP_SKIP ) + *(*dma_prog)++ = htole32(*target_buffer); + *target_buffer += width * pixel_width / 2; if ( operation == OP_WRITE ) operation = OP_WRITEC; - *(*dma_prog)++ = operation | flag2 | - (width * pixel_width / 2); - *target_buffer += (width * pixel_width / 2) ; - bktr->current_col += width; + *(*dma_prog)++ = htole32(operation | flag2 | + (width * pixel_width / 2)); + *target_buffer += width * pixel_width / 2; + bktr->current_col += width; } - return TRUE; + + return TRUE; } @@ -2715,19 +2708,19 @@ static bool_t split(bktr_reg_t * bktr, volatile u_long **dma_prog, int width , * Generate the RISC instructions to capture both VBI and video images */ static void -rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) +rgb_vbi_prog(bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) { - int i; - volatile u_long target_buffer, buffer, target,width; - volatile u_long pitch; - volatile u_long *dma_prog; /* DMA prog is an array of - 32 bit RISC instructions */ - volatile u_long *loop_point; + int i; + u_int target_buffer, buffer, target, width; + u_int pitch; + u_int *dma_prog; /* DMA prog is an array of + 32 bit RISC instructions */ + u_int *loop_point; const struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; - u_int Bpp = pf_int->public.Bpp; - unsigned int vbisamples; /* VBI samples per line */ - unsigned int vbilines; /* VBI lines per field */ - unsigned int num_dwords; /* DWORDS per line */ + u_int Bpp = pf_int->public.Bpp; + unsigned int vbisamples; /* VBI samples per line */ + unsigned int vbilines; /* VBI lines per field */ + unsigned int num_dwords; /* DWORDS per line */ vbisamples = format_params[bktr->format_params].vbi_num_samples; vbilines = format_params[bktr->format_params].vbi_num_lines; @@ -2741,13 +2734,13 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) OUTB(bktr, BKTR_OFORM, 0x00); - OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) | 0x40); /* set chroma comb */ - OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) | 0x40); + OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) | 0x40); /* set chroma comb */ + OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) | 0x40); OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) & ~0x80); /* clear Ycomb */ OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) & ~0x80); - /* disable gamma correction removal */ - OUTB(bktr, BKTR_COLOR_CTL, INB(bktr, BKTR_COLOR_CTL) | BT848_COLOR_CTL_GAMMA); + /* disable gamma correction removal */ + OUTB(bktr, BKTR_COLOR_CTL, INB(bktr, BKTR_COLOR_CTL) | BT848_COLOR_CTL_GAMMA); if (cols > 385 ) { OUTB(bktr, BKTR_E_VTC, 0); @@ -2758,16 +2751,20 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) } bktr->capcontrol = 3 << 2 | 3; - dma_prog = (u_long *) bktr->dma_prog; + dma_prog = (u_int *) bktr->dma_prog; /* Construct Write */ if (bktr->video.addr) { - target_buffer = (u_long) bktr->video.addr; + target_buffer = bktr->video.addr; pitch = bktr->video.width; } else { - target_buffer = (u_long) vtophys(bktr->bigbuf); +#ifdef __FreeBSD__ + target_buffer = (u_int) vtophys(bktr->bigbuf); +#else + target_buffer = bktr->dm_mem->dm_segs->ds_addr; +#endif pitch = cols*Bpp; } @@ -2776,70 +2773,74 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) /* Wait for the VRE sync marking the end of the Even and * the start of the Odd field. Resync here. */ - *dma_prog++ = OP_SYNC | BKTR_RESYNC |BKTR_VRE; - *dma_prog++ = 0; + *dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC |BKTR_VRE); + *dma_prog++ = htole32(0); loop_point = dma_prog; /* store the VBI data */ /* look for sync with packed data */ - *dma_prog++ = OP_SYNC | BKTR_FM1; - *dma_prog++ = 0; + *dma_prog++ = htole32(OP_SYNC | BKTR_FM1); + *dma_prog++ = htole32(0); for(i = 0; i < vbilines; i++) { - *dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples; - *dma_prog++ = (u_long) vtophys((caddr_t)bktr->vbidata + + *dma_prog++ = htole32(OP_WRITE | OP_SOL | OP_EOL | vbisamples); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int) vtophys((caddr_t)bktr->vbidata + + (i * VBI_LINE_SIZE)); +#else + *dma_prog++ = htole32(bktr->dm_vbidata->dm_segs->ds_addr + (i * VBI_LINE_SIZE)); +#endif } - if ( (i_flag == 2/*Odd*/) || (i_flag==3) /*interlaced*/ ) { + if ( (i_flag == 2/*Odd*/) || (i_flag==3) /*interlaced*/ ) { /* store the Odd field video image */ /* look for sync with packed data */ - *dma_prog++ = OP_SYNC | BKTR_FM1; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | BKTR_FM1); + *dma_prog++ = htole32(0); /* NULL WORD */ width = cols; for (i = 0; i < (rows/interlace); i++) { target = target_buffer; if ( notclipped(bktr, i, width)) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, cols); - + split(bktr, &dma_prog, bktr->y2 - bktr->y, OP_WRITE, + Bpp, &target, cols); + } else { while(getline(bktr, i)) { if (bktr->y != bktr->y2 ) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, cols); + split(bktr, &dma_prog, bktr->y2 - bktr->y, + OP_WRITE, Bpp, &target, cols); } if (bktr->yclip != bktr->yclip2 ) { - split(bktr,(volatile u_long **) &dma_prog, - bktr->yclip2 - bktr->yclip, - OP_SKIP, - Bpp, (volatile u_char **) &target, cols); + split(bktr, &dma_prog, bktr->yclip2 - + bktr->yclip, OP_SKIP, Bpp, &target, cols); } } - } - + target_buffer += interlace * pitch; - } } /* end if */ /* Grab the Even field */ /* Look for the VRO, end of Odd field, marker */ - *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO); + *dma_prog++ = htole32(0); /* NULL WORD */ /* store the VBI data */ /* look for sync with packed data */ - *dma_prog++ = OP_SYNC | BKTR_FM1; - *dma_prog++ = 0; + *dma_prog++ = htole32(OP_SYNC | BKTR_FM1); + *dma_prog++ = htole32(0); for(i = 0; i < vbilines; i++) { *dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples; +#ifdef __FreeBSD__ *dma_prog++ = (u_long) vtophys((caddr_t)bktr->vbidata + ((i+MAX_VBI_LINES) * VBI_LINE_SIZE)); +#else + *dma_prog++ = bktr->dm_vbidata->dm_segs->ds_addr + + ((i+MAX_VBI_LINES) * VBI_LINE_SIZE); +#endif } /* store the video image */ @@ -2851,58 +2852,53 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) if ((i_flag == 1) /*Even Only*/ || (i_flag==3) /*interlaced*/) { /* look for sync with packed data */ - *dma_prog++ = OP_SYNC | BKTR_FM1; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | BKTR_FM1); + *dma_prog++ = htole32(0); /* NULL WORD */ width = cols; for (i = 0; i < (rows/interlace); i++) { target = target_buffer; if ( notclipped(bktr, i, width)) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, cols); + split(bktr, &dma_prog, bktr->y2 - bktr->y, OP_WRITE, + Bpp, &target, cols); } else { while(getline(bktr, i)) { if (bktr->y != bktr->y2 ) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, - cols); - } + split(bktr, &dma_prog, bktr->y2 - bktr->y, + OP_WRITE, Bpp, &target, cols); + } if (bktr->yclip != bktr->yclip2 ) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->yclip2 - bktr->yclip, OP_SKIP, - Bpp, (volatile u_char **) &target, cols); - } - - } - + split(bktr, &dma_prog, bktr->yclip2 - + bktr->yclip, OP_SKIP, Bpp, &target, cols); + } + } } target_buffer += interlace * pitch; - } } /* Look for end of 'Even Field' */ - *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE); + *dma_prog++ = htole32(0); /* NULL WORD */ - *dma_prog++ = OP_JUMP ; - *dma_prog++ = (u_long ) vtophys(loop_point) ; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int )vtophys(loop_point) ; +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr + + ((void *)loop_point - (void *)dma_prog)); +#endif + *dma_prog++ = htole32(0); /* NULL WORD */ } - - - static void rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) { - int i; - volatile u_long target_buffer, buffer, target,width; - volatile u_long pitch; - volatile u_long *dma_prog; + int i; + u_int target_buffer, buffer, target,width; + u_int pitch; + u_int *dma_prog; const struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; u_int Bpp = pf_int->public.Bpp; @@ -2913,12 +2909,12 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) OUTB(bktr, BKTR_OFORM, 0x00); - OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) | 0x40); /* set chroma comb */ - OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) | 0x40); + OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) | 0x40); /* set chroma comb */ + OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) | 0x40); OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) & ~0x80); /* clear Ycomb */ OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) & ~0x80); - /* disable gamma correction removal */ + /* disable gamma correction removal */ OUTB(bktr, BKTR_COLOR_CTL, INB(bktr, BKTR_COLOR_CTL) | BT848_COLOR_CTL_GAMMA); if (cols > 385 ) { @@ -2930,7 +2926,7 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) } bktr->capcontrol = 3 << 2 | 3; - dma_prog = (u_long *) bktr->dma_prog; + dma_prog = (u_int *)bktr->dma_prog; /* Construct Write */ @@ -2939,124 +2935,131 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ) pitch = bktr->video.width; } else { +#ifdef __FreeBSD__ target_buffer = (u_long) vtophys(bktr->bigbuf); +#else + *dma_prog++ = htole32(bktr->dm_mem->dm_segs->ds_addr); +#endif pitch = cols*Bpp; } buffer = target_buffer; /* contruct sync : for video packet format */ - *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1; + *dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC | BKTR_FM1); /* sync, mode indicator packed data */ - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(0); /* NULL WORD */ width = cols; for (i = 0; i < (rows/interlace); i++) { target = target_buffer; if ( notclipped(bktr, i, width)) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, cols); + split(bktr, &dma_prog, bktr->y2 - bktr->y, OP_WRITE, + Bpp, &target, cols); } else { while(getline(bktr, i)) { if (bktr->y != bktr->y2 ) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, cols); + split(bktr, &dma_prog, bktr->y2 - bktr->y, OP_WRITE, + Bpp, &target, cols); } if (bktr->yclip != bktr->yclip2 ) { - split(bktr,(volatile u_long **) &dma_prog, - bktr->yclip2 - bktr->yclip, - OP_SKIP, - Bpp, (volatile u_char **) &target, cols); + split(bktr, &dma_prog, bktr->yclip2 - bktr->yclip, + OP_SKIP, Bpp, &target, cols); } } - } target_buffer += interlace * pitch; - } switch (i_flag) { case 1: /* sync vre */ - *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_VRO; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | BKTR_GEN_IRQ | BKTR_VRO); + *dma_prog++ = htole32(0); /* NULL WORD */ - *dma_prog++ = OP_JUMP; + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif return; case 2: /* sync vro */ - *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_VRE; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | BKTR_GEN_IRQ | BKTR_VRE); + *dma_prog++ = htole32(0); /* NULL WORD */ - *dma_prog++ = OP_JUMP; + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif return; case 3: /* sync vro */ - *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP; ; + *dma_prog++ = htole32(OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_oprog->dm_segs->ds_addr); +#endif break; } if (interlace == 2) { - target_buffer = buffer + pitch; + target_buffer = buffer + pitch; - dma_prog = (u_long *) bktr->odd_dma_prog; + dma_prog = (u_int *) bktr->odd_dma_prog; /* sync vre IRQ bit */ - *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC | BKTR_FM1); + *dma_prog++ = htole32(0); /* NULL WORD */ width = cols; for (i = 0; i < (rows/interlace); i++) { target = target_buffer; if ( notclipped(bktr, i, width)) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, cols); + split(bktr, &dma_prog, bktr->y2 - bktr->y, OP_WRITE, + Bpp, &target, cols); } else { while(getline(bktr, i)) { if (bktr->y != bktr->y2 ) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->y2 - bktr->y, OP_WRITE, - Bpp, (volatile u_char **) &target, - cols); - } + split(bktr, &dma_prog, bktr->y2 - bktr->y, + OP_WRITE, Bpp, &target, cols); + } if (bktr->yclip != bktr->yclip2 ) { - split(bktr, (volatile u_long **) &dma_prog, - bktr->yclip2 - bktr->yclip, OP_SKIP, - Bpp, (volatile u_char **) &target, cols); - } - - } - + split(bktr, &dma_prog, bktr->yclip2 - + bktr->yclip, OP_SKIP, Bpp, &target, cols); + } + } } target_buffer += interlace * pitch; - } } /* sync vre IRQ bit */ - *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP ; + *dma_prog++ = htole32(OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog++ = (u_long ) vtophys(bktr->dma_prog) ; - *dma_prog++ = 0; /* NULL WORD */ +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif + *dma_prog++ = htole32(0); /* NULL WORD */ } /* - * + * */ static void yuvpack_prog( bktr_ptr_t bktr, char i_flag, @@ -3084,7 +3087,7 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag, dma_prog = (u_long *) bktr->dma_prog; /* Construct Write */ - + /* write , sol, eol */ inst = OP_WRITE | OP_SOL | (cols); /* write , sol, eol */ @@ -3093,49 +3096,65 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag, if (bktr->video.addr) target_buffer = (u_long) bktr->video.addr; else +#ifdef __FreeBSD__ target_buffer = (u_long) vtophys(bktr->bigbuf); +#else + target_buffer = bktr->dm_mem->dm_segs->ds_addr; +#endif buffer = target_buffer; /* contruct sync : for video packet format */ /* sync, mode indicator packed data */ - *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM1; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 15 | BKTR_FM1); + *dma_prog++ = htole32(0); /* NULL WORD */ b = cols; for (i = 0; i < (rows/interlace); i++) { - *dma_prog++ = inst; - *dma_prog++ = target_buffer; - *dma_prog++ = inst3; - *dma_prog++ = target_buffer + b; + *dma_prog++ = htole32(inst); + *dma_prog++ = htole32(target_buffer); + *dma_prog++ = htole32(inst3); + *dma_prog++ = htole32(target_buffer + b); target_buffer += interlace*(cols * 2); } switch (i_flag) { case 1: /* sync vre */ - *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | BKTR_VRE); + *dma_prog++ = htole32(0); /* NULL WORD */ - *dma_prog++ = OP_JUMP; + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif return; case 2: /* sync vro */ - *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP; + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | BKTR_VRO); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif return; case 3: /* sync vro */ - *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP ; + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_oprog->dm_segs->ds_addr); +#endif break; } @@ -3146,46 +3165,53 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag, dma_prog = (u_long * ) bktr->odd_dma_prog; /* sync vre */ - *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_FM1; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | 1 << 15 | BKTR_FM1); + *dma_prog++ = htole32(0); /* NULL WORD */ for (i = 0; i < (rows/interlace) ; i++) { - *dma_prog++ = inst; - *dma_prog++ = target_buffer; - *dma_prog++ = inst3; - *dma_prog++ = target_buffer + b; + *dma_prog++ = htole32(inst); + *dma_prog++ = htole32(target_buffer); + *dma_prog++ = htole32(inst3); + *dma_prog++ = htole32(target_buffer + b); target_buffer += interlace * ( cols*2); } } /* sync vro IRQ bit */ - *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP ; + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif - *dma_prog++ = OP_JUMP; + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); - *dma_prog++ = 0; /* NULL WORD */ +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif + *dma_prog++ = htole32(0); /* NULL WORD */ } /* - * + * */ static void -yuv422_prog( bktr_ptr_t bktr, char i_flag, - int cols, int rows, int interlace ){ - - int i; - volatile unsigned int inst; - volatile u_long target_buffer, t1, buffer; - volatile u_long *dma_prog; +yuv422_prog(bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace) +{ + int i; + u_int inst; + u_int target_buffer, t1, buffer; + u_int *dma_prog; const struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; OUTB(bktr, BKTR_COLOR_FMT, pf_int->color_fmt); - dma_prog = (u_long *) bktr->dma_prog; + dma_prog = (u_int *) bktr->dma_prog; bktr->capcontrol = 1 << 6 | 1 << 4 | 3; @@ -3207,205 +3233,249 @@ yuv422_prog( bktr_ptr_t bktr, char i_flag, OUTB(bktr, BKTR_COLOR_CTL, INB(bktr, BKTR_COLOR_CTL) | BT848_COLOR_CTL_GAMMA); /* Construct Write */ - inst = OP_WRITE123 | OP_SOL | OP_EOL | (cols); + inst = OP_WRITE123 | OP_SOL | OP_EOL | (cols); if (bktr->video.addr) - target_buffer = (u_long) bktr->video.addr; + target_buffer = (u_int) bktr->video.addr; else - target_buffer = (u_long) vtophys(bktr->bigbuf); - +#ifdef __FreeBSD__ + target_buffer = (u_int) vtophys(bktr->bigbuf); +#else + target_buffer = bktr->dm_mem->dm_segs->ds_addr; +#endif + buffer = target_buffer; t1 = buffer; /* contruct sync : for video packet format */ - *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; /*sync, mode indicator packed data*/ - *dma_prog++ = 0; /* NULL WORD */ + /* sync, mode indicator packed data*/ + *dma_prog++ = htole32(OP_SYNC | 1 << 15 | BKTR_FM3); + *dma_prog++ = htole32(0); /* NULL WORD */ for (i = 0; i < (rows/interlace ) ; i++) { - *dma_prog++ = inst; - *dma_prog++ = cols/2 | cols/2 << 16; - *dma_prog++ = target_buffer; - *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; - *dma_prog++ = t1 + (cols*rows) + (cols*rows/2) + i*cols/2 * interlace; + *dma_prog++ = htole32(inst); + *dma_prog++ = htole32(cols/2 | cols/2 << 16); + *dma_prog++ = htole32(target_buffer); + *dma_prog++ = htole32(t1 + (cols*rows) + i*cols/2 * interlace); + *dma_prog++ = htole32(t1 + (cols*rows) + (cols*rows/2) + + i*cols/2 * interlace); target_buffer += interlace*cols; } switch (i_flag) { case 1: - *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; /*sync vre*/ - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | BKTR_VRE); /*sync vre*/ + *dma_prog++ = htole32(0); /* NULL WORD */ - *dma_prog++ = OP_JUMP ; - *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif return; case 2: - *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; /*sync vre*/ - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | BKTR_VRO); /*sync vre*/ + *dma_prog++ = htole32(0); /* NULL WORD */ - *dma_prog++ = OP_JUMP; - *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif return; case 3: - *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO); + *dma_prog++ = htole32(0); /* NULL WORD */ - *dma_prog++ = OP_JUMP ; - *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog = (u_int) vtophys(bktr->odd_dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_oprog->dm_segs->ds_addr); +#endif break; } if (interlace == 2) { - dma_prog = (u_long * ) bktr->odd_dma_prog; + dma_prog = (u_int * ) bktr->odd_dma_prog; - target_buffer = (u_long) buffer + cols; + target_buffer = (u_int) buffer + cols; t1 = buffer + cols/2; - *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 15 | BKTR_FM3); + *dma_prog++ = htole32(0); /* NULL WORD */ for (i = 0; i < (rows/interlace ) ; i++) { - *dma_prog++ = inst; - *dma_prog++ = cols/2 | cols/2 << 16; - *dma_prog++ = target_buffer; - *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; - *dma_prog++ = t1 + (cols*rows) + (cols*rows/2) + i*cols/2 * interlace; + *dma_prog++ = htole32(inst); + *dma_prog++ = htole32(cols/2 | cols/2 << 16); + *dma_prog++ = htole32(target_buffer); + *dma_prog++ = htole32(t1 + (cols*rows) + + i*cols/2 * interlace); + *dma_prog++ = htole32(t1 + (cols*rows) + + (cols*rows/2) + i*cols/2 * interlace); target_buffer += interlace*cols; } } - - *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP ; - *dma_prog++ = (u_long ) vtophys(bktr->dma_prog) ; - *dma_prog++ = 0; /* NULL WORD */ + + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int) vtophys(bktr->dma_prog) ; +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif + *dma_prog++ = htole32(0); /* NULL WORD */ } /* - * + * */ static void yuv12_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace ){ - int i; - volatile unsigned int inst; - volatile unsigned int inst1; - volatile u_long target_buffer, t1, buffer; - volatile u_long *dma_prog; + int i; + u_int inst; + u_int inst1; + u_int target_buffer, t1, buffer; + u_int *dma_prog; const struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; OUTB(bktr, BKTR_COLOR_FMT, pf_int->color_fmt); - dma_prog = (u_long *) bktr->dma_prog; + dma_prog = (u_int *) bktr->dma_prog; bktr->capcontrol = 1 << 6 | 1 << 4 | 3; OUTB(bktr, BKTR_ADC, SYNC_LEVEL); OUTB(bktr, BKTR_OFORM, 0x0); - + /* Construct Write */ - inst = OP_WRITE123 | OP_SOL | OP_EOL | (cols); - inst1 = OP_WRITES123 | OP_SOL | OP_EOL | (cols); - if (bktr->video.addr) - target_buffer = (u_long) bktr->video.addr; - else - target_buffer = (u_long) vtophys(bktr->bigbuf); - + inst = OP_WRITE123 | OP_SOL | OP_EOL | (cols); + inst1 = OP_WRITES123 | OP_SOL | OP_EOL | (cols); + if (bktr->video.addr) + target_buffer = (u_long) bktr->video.addr; + else +#ifdef __FreeBSD__ + target_buffer = (u_long) vtophys(bktr->bigbuf); +#else + target_buffer = bktr->dm_mem->dm_segs->ds_addr; +#endif + buffer = target_buffer; - t1 = buffer; - - *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; /*sync, mode indicator packed data*/ - *dma_prog++ = 0; /* NULL WORD */ - - for (i = 0; i < (rows/interlace )/2 ; i++) { - *dma_prog++ = inst; - *dma_prog++ = cols/2 | (cols/2 << 16); - *dma_prog++ = target_buffer; - *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; - *dma_prog++ = t1 + (cols*rows) + (cols*rows/4) + i*cols/2 * interlace; - target_buffer += interlace*cols; - *dma_prog++ = inst1; - *dma_prog++ = cols/2 | (cols/2 << 16); - *dma_prog++ = target_buffer; - target_buffer += interlace*cols; - - } - - switch (i_flag) { - case 1: - *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; /*sync vre*/ - *dma_prog++ = 0; /* NULL WORD */ - - *dma_prog++ = OP_JUMP; - *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); - return; + t1 = buffer; - case 2: - *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; /*sync vro*/ - *dma_prog++ = 0; /* NULL WORD */ + /* sync, mode indicator packed data*/ + *dma_prog++ = htole32(OP_SYNC | 1 << 15 | BKTR_FM3); + *dma_prog++ = htole32(0); /* NULL WORD */ + + for (i = 0; i < (rows/interlace )/2 ; i++) { + *dma_prog++ = htole32(inst); + *dma_prog++ = htole32(cols/2 | (cols/2 << 16)); + *dma_prog++ = htole32(target_buffer); + *dma_prog++ = htole32(t1 + (cols*rows) + i*cols/2 * interlace); + *dma_prog++ = htole32(t1 + (cols*rows) + (cols*rows/4) + + i*cols/2 * interlace); + target_buffer += interlace*cols; + *dma_prog++ = htole32(inst1); + *dma_prog++ = htole32(cols/2 | (cols/2 << 16)); + *dma_prog++ = htole32(target_buffer); + target_buffer += interlace*cols; - *dma_prog++ = OP_JUMP; - *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); - return; - - case 3: - *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP ; - *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); + } + + switch (i_flag) { + case 1: + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | BKTR_VRE); /*sync vre*/ + *dma_prog++ = htole32(0); /* NULL WORD */ + + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif + return; + + case 2: + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | BKTR_VRO); /*sync vro*/ + *dma_prog++ = htole32(0); /* NULL WORD */ + + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int) vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif + return; + + case 3: + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog = (u_int) vtophys(bktr->odd_dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_oprog->dm_segs->ds_addr); +#endif break; } if (interlace == 2) { - dma_prog = (u_long * ) bktr->odd_dma_prog; + dma_prog = (u_int *)bktr->odd_dma_prog; target_buffer = (u_long) buffer + cols; t1 = buffer + cols/2; - *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; - *dma_prog++ = 0; /* NULL WORD */ + *dma_prog++ = htole32(OP_SYNC | 1 << 15 | BKTR_FM3); + *dma_prog++ = htole32(0); /* NULL WORD */ for (i = 0; i < ((rows/interlace )/2 ) ; i++) { - *dma_prog++ = inst; - *dma_prog++ = cols/2 | (cols/2 << 16); - *dma_prog++ = target_buffer; - *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; - *dma_prog++ = t1 + (cols*rows) + (cols*rows/4) + i*cols/2 * interlace; - target_buffer += interlace*cols; - *dma_prog++ = inst1; - *dma_prog++ = cols/2 | (cols/2 << 16); - *dma_prog++ = target_buffer; - target_buffer += interlace*cols; - - } - - + *dma_prog++ = htole32(inst); + *dma_prog++ = htole32(cols/2 | (cols/2 << 16)); + *dma_prog++ = htole32(target_buffer); + *dma_prog++ = htole32(t1 + (cols*rows) + + i*cols/2 * interlace); + *dma_prog++ = htole32(t1 + (cols*rows) + + (cols*rows/4) + i*cols/2 * interlace); + target_buffer += interlace*cols; + *dma_prog++ = htole32(inst1); + *dma_prog++ = htole32(cols/2 | (cols/2 << 16)); + *dma_prog++ = htole32(target_buffer); + target_buffer += interlace*cols; + } } - - *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE; - *dma_prog++ = 0; /* NULL WORD */ - *dma_prog++ = OP_JUMP; - *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); - *dma_prog++ = 0; /* NULL WORD */ + + *dma_prog++ = htole32(OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE); + *dma_prog++ = htole32(0); /* NULL WORD */ + *dma_prog++ = htole32(OP_JUMP); +#ifdef __FreeBSD__ + *dma_prog++ = (u_int )vtophys(bktr->dma_prog); +#else + *dma_prog++ = htole32(bktr->dm_prog->dm_segs->ds_addr); +#endif + *dma_prog++ = htole32(0); /* NULL WORD */ } - /* - * + * */ static void build_dma_prog( bktr_ptr_t bktr, char i_flag ) { int rows, cols, interlace; int tmp_int; - unsigned int temp; + unsigned int temp; const struct format_params *fp; const struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; - + fp = &format_params[bktr->format_params]; @@ -3427,7 +3497,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag ) OUTB(bktr, BKTR_O_HSCALE_LO, temp & 0xff); OUTB(bktr, BKTR_E_HSCALE_HI, (temp >> 8) & 0xff); OUTB(bktr, BKTR_O_HSCALE_HI, (temp >> 8) & 0xff); - + /* horizontal active */ temp = bktr->cols; /* printf("%s: HACTIVE value is %d\n", bktr_name(bktr), temp); */ @@ -3437,7 +3507,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag ) OUTB(bktr, BKTR_O_CROP, INB(bktr, BKTR_O_CROP) & ~0x3); OUTB(bktr, BKTR_E_CROP, INB(bktr, BKTR_E_CROP) | ((temp >> 8) & 0x3)); OUTB(bktr, BKTR_O_CROP, INB(bktr, BKTR_O_CROP) | ((temp >> 8) & 0x3)); - + /* horizontal delay */ if (bktr->capture_area_enabled) temp = ( (fp->hdelay* fp->scaled_hactive + bktr->capture_area_x_offset* fp->scaled_htotal) @@ -3499,7 +3569,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag ) OUTB(bktr, BKTR_O_CROP, INB(bktr, BKTR_O_CROP) & ~0x30); OUTB(bktr, BKTR_O_CROP, INB(bktr, BKTR_O_CROP) | ((temp >> 4) & 0x30)); OUTB(bktr, BKTR_O_VACTIVE_LO, temp & 0xff); - + /* vertical delay */ if (bktr->capture_area_enabled) temp = fp->vdelay + (bktr->capture_area_y_offset); @@ -3525,21 +3595,21 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag ) /* capture control */ switch (i_flag) { case 1: - bktr->bktr_cap_ctl = + bktr->bktr_cap_ctl = (BT848_CAP_CTL_DITH_FRAME | BT848_CAP_CTL_EVEN); OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) & ~0x20); OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) & ~0x20); interlace = 1; break; case 2: - bktr->bktr_cap_ctl = + bktr->bktr_cap_ctl = (BT848_CAP_CTL_DITH_FRAME | BT848_CAP_CTL_ODD); OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) & ~0x20); OUTB(bktr, BKTR_O_VSCALE_HI, INB(bktr, BKTR_O_VSCALE_HI) & ~0x20); interlace = 1; break; default: - bktr->bktr_cap_ctl = + bktr->bktr_cap_ctl = (BT848_CAP_CTL_DITH_FRAME | BT848_CAP_CTL_EVEN | BT848_CAP_CTL_ODD); OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) | 0x20); @@ -3548,7 +3618,11 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag ) break; } +#ifdef __FreeBSD__ OUTL(bktr, BKTR_RISC_STRT_ADD, vtophys(bktr->dma_prog)); +#else + OUTL(bktr, BKTR_RISC_STRT_ADD, bktr->dm_prog->dm_segs->ds_addr); +#endif rows = bktr->rows; cols = bktr->cols; @@ -3604,7 +3678,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag ) /* - * + * */ static void start_capture( bktr_ptr_t bktr, unsigned type ) @@ -3616,7 +3690,7 @@ start_capture( bktr_ptr_t bktr, unsigned type ) /* If requested, clear out capture buf first */ if (bktr->clr_on_start && (bktr->video.addr == 0)) { - bzero((caddr_t)bktr->bigbuf, + bzero((caddr_t)bktr->bigbuf, (size_t)bktr->rows * bktr->cols * bktr->frames * pixfmt_table[ bktr->pixfmt ].public.Bpp); } @@ -3655,15 +3729,18 @@ start_capture( bktr_ptr_t bktr, unsigned type ) build_dma_prog(bktr, i_flag); bktr->dma_prog_loaded = TRUE; } - - OUTL(bktr, BKTR_RISC_STRT_ADD, vtophys(bktr->dma_prog)); +#ifdef __FreeBSD__ + OUTL(bktr, BKTR_RISC_STRT_ADD, vtophys(bktr->dma_prog)); +#else + OUTL(bktr, BKTR_RISC_STRT_ADD, bktr->dm_prog->dm_segs->ds_addr); +#endif } /* - * + * */ static void set_fps( bktr_ptr_t bktr, u_short fps ) @@ -3706,13 +3783,13 @@ set_fps( bktr_ptr_t bktr, u_short fps ) -/* - * Given a pixfmt index, compute the bt848 swap_flags necessary to +/* + * Given a pixfmt index, compute the bt848 swap_flags necessary to * achieve the specified swapping. - * Note that without bt swapping, 2Bpp and 3Bpp modes are written - * byte-swapped, and 4Bpp modes are byte and word swapped (see Table 6 - * and read R->L). - * Note also that for 3Bpp, we may additionally need to do some creative + * Note that without bt swapping, 2Bpp and 3Bpp modes are written + * byte-swapped, and 4Bpp modes are byte and word swapped (see Table 6 + * and read R->L). + * Note also that for 3Bpp, we may additionally need to do some creative * SKIPing to align the FIFO bytelines with the target buffer (see split()). * This is abstracted here: e.g. no swaps = RGBA; byte & short swap = ABGR * as one would expect. @@ -3729,7 +3806,7 @@ static u_int pixfmt_swap_flags( int pixfmt ) case 3 : /* no swaps supported for 3bpp - makes no sense w/ bt848 */ break; - + case 4 : if ( pf->swap_bytes ) swapf = pf->swap_shorts ? 0 : WSWAP; else @@ -3741,7 +3818,7 @@ static u_int pixfmt_swap_flags( int pixfmt ) -/* +/* * Converts meteor-defined pixel formats (e.g. METEOR_GEO_RGB16) into * our pixfmt_table indices. */ @@ -3768,7 +3845,7 @@ static int oformat_meteor_to_bt( u_long format ) ( pf1->Bpp == pf2->Bpp ) && !bcmp( pf1->masks, pf2->masks, sizeof( pf1->masks )) && ( pf1->swap_bytes == pf2->swap_bytes ) && - ( pf1->swap_shorts == pf2->swap_shorts )) + ( pf1->swap_shorts == pf2->swap_shorts )) break; } if ( i >= PIXFMT_TABLE_SIZE ) @@ -3782,14 +3859,14 @@ static int oformat_meteor_to_bt( u_long format ) */ /* */ -#define I2CBITTIME (0x5<<4) /* 5 * 0.48uS */ -#define I2CBITTIME_878 (1 << 7) +#define I2CBITTIME (0x5) /* 5 * 0.48uS */ +#define I2CBITTIME_878 (0x8) #define I2C_READ 0x01 -#define I2C_COMMAND (I2CBITTIME | \ +#define I2C_COMMAND ((I2CBITTIME << 4) | \ BT848_DATA_CTL_I2CSCL | \ BT848_DATA_CTL_I2CSDA) -#define I2C_COMMAND_878 (I2CBITTIME_878 | \ +#define I2C_COMMAND_878 ((I2CBITTIME_878 << 4) | \ BT848_DATA_CTL_I2CSCL | \ BT848_DATA_CTL_I2CSDA) @@ -3986,39 +4063,38 @@ i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 ) /* - * + * */ int i2cRead( bktr_ptr_t bktr, int addr ) { - u_long x; + u_int32_t x, stat; /* clear status bits */ OUTL(bktr, BKTR_INT_STAT, BT848_INT_RACK | BT848_INT_I2CDONE); /* write the READ address */ /* The Bt878 and Bt879 differed on the treatment of i2c commands */ - + if (bktr->id == BROOKTREE_848 || bktr->id == BROOKTREE_848A || - bktr->id == BROOKTREE_849A) { + bktr->id == BROOKTREE_849A) OUTL(bktr, BKTR_I2C_DATA_CTL, ((addr & 0xff) << 24) | I2C_COMMAND); - } else { + else OUTL(bktr, BKTR_I2C_DATA_CTL, ((addr & 0xff) << 24) | I2C_COMMAND_878); - } /* wait for completion */ - for ( x = 0x7fffffff; x; --x ) { /* safety valve */ - if ( INL(bktr, BKTR_INT_STAT) & BT848_INT_I2CDONE ) + for (x = 5000; x--; DELAY(1)) /* 5 msec, safety valve */ + if ((stat = INL(bktr, BKTR_INT_STAT)) & BT848_INT_I2CDONE) break; - } /* check for ACK */ - if ( !x || !(INL(bktr, BKTR_INT_STAT) & BT848_INT_RACK) ) - return( -1 ); + if ((stat & (I2C_BITS)) != (I2C_BITS)) + return (-1); /* it was a read */ - return( (INL(bktr, BKTR_I2C_DATA_CTL) >> 8) & 0xff ); + x = INL(bktr, BKTR_I2C_DATA_CTL); + return ((x >> 8) & 0xff); } /* The MSP34xx Audio chip require i2c bus writes of up to 5 bytes which the */ diff --git a/sys/dev/pci/bktr/bktr_core.h b/sys/dev/pci/bktr/bktr_core.h index 2fd3c5bf42c..e8362e6078e 100644 --- a/sys/dev/pci/bktr/bktr_core.h +++ b/sys/dev/pci/bktr/bktr_core.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_core.h,v 1.1 2001/03/28 03:27:09 fgsch Exp $ */ +/* $OpenBSD: bktr_core.h,v 1.2 2003/01/05 01:24:53 mickey Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_core.h,v 1.4 2000/06/26 09:41:32 roger Exp $ */ /* @@ -64,7 +64,7 @@ void msp_dpl_write( bktr_ptr_t bktr, int i2c_addr, unsigned char dev, * For /dev/bktr[n] use memory address of bktr structure * For /dev/vbi[n] use memory address of bktr structure + 1 * this is ok as the bktr structure is > 1 byte - */ + */ #define BKTR_SLEEP ((caddr_t)bktr ) #define VBI_SLEEP ((caddr_t)bktr + 1) @@ -74,12 +74,12 @@ const char *bktr_name(bktr_ptr_t bktr); /* Prototypes for attatch and interrupt functions */ void common_bktr_attach( bktr_ptr_t bktr, int unit, - u_long pci_id, u_int rev ); + u_long pci_id, u_int rev ); int common_bktr_intr( void *arg ); /* Prototypes for open, close, read, mmap and ioctl calls */ -int video_open( bktr_ptr_t bktr ); +int video_open( bktr_ptr_t bktr ); int video_close( bktr_ptr_t bktr ); int video_read( bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio ); int video_ioctl( bktr_ptr_t bktr, int unit, diff --git a/sys/dev/pci/bktr/bktr_os.c b/sys/dev/pci/bktr/bktr_os.c index 51476824d76..ff02757776c 100644 --- a/sys/dev/pci/bktr/bktr_os.c +++ b/sys/dev/pci/bktr/bktr_os.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_os.c,v 1.13 2002/07/13 16:25:36 mickey Exp $ */ +/* $OpenBSD: bktr_os.c,v 1.14 2003/01/05 01:24:53 mickey Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_os.c,v 1.20 2000/10/20 08:16:53 roger Exp $ */ /* @@ -163,7 +163,7 @@ SYSCTL_INT(_hw_bt848, OID_AUTO, slow_msp_audio, CTLFLAG_RW, &bt848_slow_msp_audi #define BKTR_DEBUG #ifdef BKTR_DEBUG -int bktr_debug = 0; +int bktr_debug = 1; #define DPR(x) (bktr_debug ? printf x : 0) #else #define DPR(x) @@ -285,7 +285,7 @@ bktr_probe( device_t dev ) device_set_desc(dev, "BrookTree 879"); return 0; } - }; + } return ENXIO; } @@ -1389,6 +1389,15 @@ bktr_attach(struct device *parent, struct device *self, void *aux) unit = bktr->bktr_dev.dv_unit; bktr->dmat = pa->pa_dmat; + /* Enabled Bus Master + XXX: check if all old DMA is stopped first (e.g. after warm + boot) */ + fun = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); + DPR((" fun=%b", fun, PCI_COMMAND_STATUS_BITS)); + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, + fun | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE | + PCI_COMMAND_BACKTOBACK_ENABLE); + #ifndef __OpenBSD__ printf("\n"); #endif @@ -1396,13 +1405,11 @@ bktr_attach(struct device *parent, struct device *self, void *aux) /* * map memory */ - retval = pci_mapreg_map(pa, PCI_MAPREG_START, - PCI_MAPREG_TYPE_MEM - | PCI_MAPREG_MEM_TYPE_32BIT, 0, - &bktr->memt, &bktr->memh, NULL, - &bktr->obmemsz, 0); - DPR(("pci_mapreg_map: memt %x, memh %x, size %x\n", - bktr->memt, (u_int)bktr->memh, (u_int)bktr->obmemsz)); + retval = pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_TYPE_MEM | + PCI_MAPREG_MEM_TYPE_32BIT, 0, &bktr->memt, &bktr->memh, NULL, + &bktr->obmemsz, 0); + DPR(("pci_mapreg_map: memt %lx, memh %lx, size %x\n", + bktr->memt, bktr->memh, bktr->obmemsz)); if (retval) { printf("%s: couldn't map memory\n", bktr_name(bktr)); return; @@ -1451,7 +1458,7 @@ bktr_attach(struct device *parent, struct device *self, void *aux) * you have more than four, then 16 would probably be a better value. */ #ifndef BROOKTREE_DEF_LATENCY_VALUE -#define BROOKTREE_DEF_LATENCY_VALUE 10 +#define BROOKTREE_DEF_LATENCY_VALUE 0x10 #endif latency = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_LATENCY_TIMER); latency = (latency >> 8) & 0xff; @@ -1467,16 +1474,9 @@ bktr_attach(struct device *parent, struct device *self, void *aux) } - /* Enabled Bus Master - XXX: check if all old DMA is stopped first (e.g. after warm - boot) */ - fun = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); - pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, - fun | PCI_COMMAND_MASTER_ENABLE); - /* read the pci id and determine the card type */ fun = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ID_REG); - rev = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG) & 0x000000ff; + rev = PCI_REVISION(pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG)); common_bktr_attach(bktr, unit, fun, rev); diff --git a/sys/dev/pci/bktr/bktr_reg.h b/sys/dev/pci/bktr/bktr_reg.h index bc1ad4dd476..9aeb2b8093f 100644 --- a/sys/dev/pci/bktr/bktr_reg.h +++ b/sys/dev/pci/bktr/bktr_reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_reg.h,v 1.5 2002/03/14 03:16:07 millert Exp $ */ +/* $OpenBSD: bktr_reg.h,v 1.6 2003/01/05 01:24:53 mickey Exp $ */ /* * $FreeBSD: src/sys/dev/bktr/bktr_reg.h,v 1.42 2000/10/31 13:09:56 roger Exp $ * @@ -310,6 +310,11 @@ struct bt848_registers { #define BT848_INT_HSYNC (1<<2) #define BT848_INT_VSYNC (1<<1) #define BT848_INT_FMTCHG (1<<0) +#define BT848_INT_BITS \ + ("\020\01FMTCHG\02VSYNC\03HSYNC\04OFLOW\05HLOCK\06VPRES\07RSV0"\ + "\010RSV1\011I2CDONE\012GPINT\014RISCI\015FBUS\016FTRGT\017FDSR"\ + "\020PPERR\021RIPERR\022PABORT\023OCERR\024SCERR"\ + "\030MYSTERYBIT\031FIELD\032RACK\034RISC_EN") int :32; /* 108, 109,10a,10b */ BTWORD (gpio_dma_ctl); /* 10c, 10d,10e,10f */ #define BT848_DMA_CTL_PL23TP4 (0<<6) /* planar1 trigger 4 */ @@ -476,12 +481,42 @@ struct bktr_i2c_softc { * with the right type of endianness. */ #if defined(__NetBSD__) || defined(__OpenBSD__) || ( defined(__FreeBSD__) && (__FreeBSD_version >=300000) ) -#define INB(bktr,offset) bus_space_read_1((bktr)->memt,(bktr)->memh,(offset)) -#define INW(bktr,offset) bus_space_read_2((bktr)->memt,(bktr)->memh,(offset)) -#define INL(bktr,offset) bus_space_read_4((bktr)->memt,(bktr)->memh,(offset)) -#define OUTB(bktr,offset,value) bus_space_write_1((bktr)->memt,(bktr)->memh,(offset),(value)) -#define OUTW(bktr,offset,value) bus_space_write_2((bktr)->memt,(bktr)->memh,(offset),(value)) -#define OUTL(bktr,offset,value) bus_space_write_4((bktr)->memt,(bktr)->memh,(offset),(value)) +#define INB(sc,o) (({ \ + u_int8_t __v; \ + __v = bus_space_read_1((sc)->memt, (sc)->memh, (o)); \ + bus_space_barrier((sc)->memt, (sc)->memh, (o), 1, \ + BUS_SPACE_BARRIER_READ); \ + (__v); \ +})) +#define INW(sc,o) (({ \ + u_int16_t __v; \ + __v = bus_space_read_2((sc)->memt, (sc)->memh, (o)); \ + bus_space_barrier((sc)->memt, (sc)->memh, (o), 4, \ + BUS_SPACE_BARRIER_READ); \ + (__v); \ +})) +#define INL(sc,o) (({ \ + u_int32_t __v; \ + __v = bus_space_read_4((sc)->memt, (sc)->memh, (o)); \ + bus_space_barrier((sc)->memt, (sc)->memh, (o), 4, \ + BUS_SPACE_BARRIER_READ); \ + (__v); \ +})) +#define OUTB(sc,o,v) do { \ + bus_space_write_1((sc)->memt, (sc)->memh, (o), (v)); \ + bus_space_barrier((sc)->memt, (sc)->memh, (o), 1, \ + BUS_SPACE_BARRIER_WRITE); \ +} while (0) +#define OUTW(sc,o,v) do { \ + bus_space_write_2((sc)->memt, (sc)->memh, (o), (v)); \ + bus_space_barrier((sc)->memt, (sc)->memh, (o), 2, \ + BUS_SPACE_BARRIER_WRITE); \ +} while (0) +#define OUTL(sc,o,v) do { \ + bus_space_write_4((sc)->memt, (sc)->memh, (o), (v)); \ + bus_space_barrier((sc)->memt, (sc)->memh, (o), 4, \ + BUS_SPACE_BARRIER_WRITE); \ +} while (0) #else #define INB(bktr,offset) *(volatile unsigned char *)((int)((bktr)->memh)+(offset)) #define INW(bktr,offset) *(volatile unsigned short *)((int)((bktr)->memh)+(offset)) |