Update the bktr driver to match the current state of FreeBSD-current,
[dragonfly.git] / sys / dev / video / bktr / bktr_core.c
index 3841501..e3e43f0 100644 (file)
@@ -61,8 +61,8 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/bktr/bktr_core.c,v 1.133 2003/12/08 07:59:18 obrien Exp $
- * $DragonFly: src/sys/dev/video/bktr/bktr_core.c,v 1.13 2004/05/15 17:54:12 joerg Exp $
+ * $FreeBSD: src/sys/dev/bktr/bktr_core.c,v 1.138 2005/01/09 17:42:03 cognet Exp
+ * $DragonFly: src/sys/dev/video/bktr/bktr_core.c,v 1.14 2005/03/12 11:35:27 corecode Exp $
  */
 
 /*
@@ -348,7 +348,7 @@ 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, 
+static bool_t   split(bktr_reg_t *, volatile uint32_t **, int, u_long, int, 
                      volatile u_char ** , int  );
 
 static void    start_capture( bktr_ptr_t bktr, unsigned type );
@@ -2552,7 +2552,7 @@ static 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 ,
+static bool_t split(bktr_reg_t * bktr, volatile uint32_t **dma_prog, int width ,
                    u_long operation, int pixel_width,
                    volatile u_char ** target_buffer, int cols ) {
 
@@ -2642,11 +2642,11 @@ static void
 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 
+       volatile uint32_t       target_buffer, buffer, target,width;
+       volatile uint32_t       pitch;
+       volatile uint32_t       *dma_prog;      /* DMA prog is an array of 
                                                32 bit RISC instructions */
-       volatile u_long         *loop_point;
+       volatile uint32_t       *loop_point;
         struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ];
        u_int                   Bpp = pf_int->public.Bpp;
        unsigned int            vbisamples;     /* VBI samples per line */
@@ -2682,7 +2682,7 @@ 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 = (uint32_t *) bktr->dma_prog;
 
        /* Construct Write */
 
@@ -2724,19 +2724,19 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
                for (i = 0; i < (rows/interlace); i++) {
                    target = target_buffer;
                    if ( notclipped(bktr, i, width)) {
-                       split(bktr, (volatile u_long **) &dma_prog,
+                       split(bktr, (volatile uint32_t **) &dma_prog,
                              bktr->y2 - bktr->y, OP_WRITE,
                              Bpp, (volatile u_char **)(uintptr_t)&target,  cols);
        
                    } else {
                        while(getline(bktr, i)) {
                            if (bktr->y != bktr->y2 ) {
-                               split(bktr, (volatile u_long **) &dma_prog,
+                               split(bktr, (volatile uint32_t **) &dma_prog,
                                      bktr->y2 - bktr->y, OP_WRITE,
                                      Bpp, (volatile u_char **)(uintptr_t)&target, cols);
                            }
                            if (bktr->yclip != bktr->yclip2 ) {
-                               split(bktr,(volatile u_long **) &dma_prog,
+                               split(bktr,(volatile uint32_t **) &dma_prog,
                                      bktr->yclip2 - bktr->yclip,
                                      OP_SKIP,
                                      Bpp, (volatile u_char **)(uintptr_t)&target,  cols);
@@ -2781,19 +2781,19 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
                for (i = 0; i < (rows/interlace); i++) {
                    target = target_buffer;
                    if ( notclipped(bktr, i, width)) {
-                       split(bktr, (volatile u_long **) &dma_prog,
+                       split(bktr, (volatile uint32_t **) &dma_prog,
                              bktr->y2 - bktr->y, OP_WRITE,
                              Bpp, (volatile u_char **)(uintptr_t)&target,  cols);
                    } else {
                        while(getline(bktr, i)) {
                            if (bktr->y != bktr->y2 ) {
-                               split(bktr, (volatile u_long **) &dma_prog,
+                               split(bktr, (volatile uint32_t **) &dma_prog,
                                      bktr->y2 - bktr->y, OP_WRITE,
                                      Bpp, (volatile u_char **)(uintptr_t)&target,
                                      cols);
                            }   
                            if (bktr->yclip != bktr->yclip2 ) {
-                               split(bktr, (volatile u_long **) &dma_prog,
+                               split(bktr, (volatile uint32_t **) &dma_prog,
                                      bktr->yclip2 - bktr->yclip, OP_SKIP,
                                      Bpp, (volatile u_char **)(uintptr_t) &target,  cols);
                            }   
@@ -2824,9 +2824,9 @@ 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;
+       volatile uint32_t               target_buffer, buffer, target,width;
+       volatile uint32_t       pitch;
+       volatile  uint32_t      *dma_prog;
         struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ];
        u_int                   Bpp = pf_int->public.Bpp;
 
@@ -2854,16 +2854,16 @@ 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 = (uint32_t *) bktr->dma_prog;
 
        /* Construct Write */
 
        if (bktr->video.addr) {
-               target_buffer = (u_long) bktr->video.addr;
+               target_buffer = (uint32_t) bktr->video.addr;
                pitch = bktr->video.width;
        }
        else {
-               target_buffer = (u_long) vtophys(bktr->bigbuf);
+               target_buffer = (uint32_t) vtophys(bktr->bigbuf);
                pitch = cols*Bpp;
        }
 
@@ -2878,19 +2878,19 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
        for (i = 0; i < (rows/interlace); i++) {
            target = target_buffer;
            if ( notclipped(bktr, i, width)) {
-               split(bktr, (volatile u_long **) &dma_prog,
+               split(bktr, (volatile uint32_t **) &dma_prog,
                      bktr->y2 - bktr->y, OP_WRITE,
                      Bpp, (volatile u_char **)(uintptr_t)&target,  cols);
 
            } else {
                while(getline(bktr, i)) {
                    if (bktr->y != bktr->y2 ) {
-                       split(bktr, (volatile u_long **) &dma_prog,
+                       split(bktr, (volatile uint32_t **) &dma_prog,
                              bktr->y2 - bktr->y, OP_WRITE,
                              Bpp, (volatile u_char **)(uintptr_t)&target, cols);
                    }
                    if (bktr->yclip != bktr->yclip2 ) {
-                       split(bktr,(volatile u_long **) &dma_prog,
+                       split(bktr,(volatile uint32_t **) &dma_prog,
                              bktr->yclip2 - bktr->yclip,
                              OP_SKIP,
                              Bpp, (volatile u_char **)(uintptr_t)&target,  cols);
@@ -2910,7 +2910,7 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t ) vtophys(bktr->dma_prog);
                return;
 
        case 2:
@@ -2919,7 +2919,7 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t ) vtophys(bktr->dma_prog);
                return;
 
        case 3:
@@ -2927,7 +2927,7 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
                *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO;
                *dma_prog++ = 0;  /* NULL WORD */
                *dma_prog++ = OP_JUMP; ;
-               *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog);
+               *dma_prog = (uint32_t ) vtophys(bktr->odd_dma_prog);
                break;
        }
 
@@ -2935,7 +2935,7 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
 
                target_buffer = buffer + pitch; 
 
-               dma_prog = (u_long *) bktr->odd_dma_prog;
+               dma_prog = (uint32_t *) bktr->odd_dma_prog;
 
                /* sync vre IRQ bit */
                *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1;
@@ -2944,19 +2944,19 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
                for (i = 0; i < (rows/interlace); i++) {
                    target = target_buffer;
                    if ( notclipped(bktr, i, width)) {
-                       split(bktr, (volatile u_long **) &dma_prog,
+                       split(bktr, (volatile uint32_t **) &dma_prog,
                              bktr->y2 - bktr->y, OP_WRITE,
                              Bpp, (volatile u_char **)(uintptr_t)&target,  cols);
                    } else {
                        while(getline(bktr, i)) {
                            if (bktr->y != bktr->y2 ) {
-                               split(bktr, (volatile u_long **) &dma_prog,
+                               split(bktr, (volatile uint32_t **) &dma_prog,
                                      bktr->y2 - bktr->y, OP_WRITE,
                                      Bpp, (volatile u_char **)(uintptr_t)&target,
                                      cols);
                            }   
                            if (bktr->yclip != bktr->yclip2 ) {
-                               split(bktr, (volatile u_long **) &dma_prog,
+                               split(bktr, (volatile uint32_t **) &dma_prog,
                                      bktr->yclip2 - bktr->yclip, OP_SKIP,
                                      Bpp, (volatile u_char **)(uintptr_t)&target,  cols);
                            }   
@@ -2974,7 +2974,7 @@ rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
        *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRE;
        *dma_prog++ = 0;  /* NULL WORD */
        *dma_prog++ = OP_JUMP ;
-       *dma_prog++ = (u_long ) vtophys(bktr->dma_prog) ;
+       *dma_prog++ = (uint32_t ) vtophys(bktr->dma_prog) ;
        *dma_prog++ = 0;  /* NULL WORD */
 }
 
@@ -2989,8 +2989,8 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag,
        int                     i;
        volatile unsigned int   inst;
        volatile unsigned int   inst3;
-       volatile u_long         target_buffer, buffer;
-       volatile  u_long        *dma_prog;
+       volatile uint32_t       target_buffer, buffer;
+       volatile  uint32_t      *dma_prog;
         struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ];
        int                     b;
 
@@ -3005,7 +3005,7 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag,
        bktr->capcontrol =   1 << 6 | 1 << 4 | 1 << 2 | 3;
        bktr->capcontrol = 3 << 2 |  3;
 
-       dma_prog = (u_long *) bktr->dma_prog;
+       dma_prog = (uint32_t *) bktr->dma_prog;
 
        /* Construct Write */
     
@@ -3015,9 +3015,9 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag,
        inst3 = OP_WRITE | OP_EOL | (cols);
 
        if (bktr->video.addr)
-               target_buffer = (u_long) bktr->video.addr;
+               target_buffer = (uint32_t) bktr->video.addr;
        else
-               target_buffer = (u_long) vtophys(bktr->bigbuf);
+               target_buffer = (uint32_t) vtophys(bktr->bigbuf);
 
        buffer = target_buffer;
 
@@ -3043,7 +3043,7 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t) vtophys(bktr->dma_prog);
                return;
 
        case 2:
@@ -3051,7 +3051,7 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = OP_SYNC  | BKTR_GEN_IRQ | BKTR_VRO;
                *dma_prog++ = 0;  /* NULL WORD */
                *dma_prog++ = OP_JUMP;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t) vtophys(bktr->dma_prog);
                return;
 
        case 3:
@@ -3059,15 +3059,15 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = OP_SYNC | BKTR_GEN_IRQ | BKTR_RESYNC | BKTR_VRO;
                *dma_prog++ = 0;  /* NULL WORD */
                *dma_prog++ = OP_JUMP  ;
-               *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog);
+               *dma_prog = (uint32_t) vtophys(bktr->odd_dma_prog);
                break;
        }
 
        if (interlace == 2) {
 
-               target_buffer =  (u_long) buffer + cols*2;
+               target_buffer =  (uint32_t) buffer + cols*2;
 
-               dma_prog = (u_long * ) bktr->odd_dma_prog;
+               dma_prog = (uint32_t *) bktr->odd_dma_prog;
 
                /* sync vre */
                *dma_prog++ = OP_SYNC | BKTR_RESYNC | BKTR_FM1;
@@ -3086,10 +3086,10 @@ yuvpack_prog( bktr_ptr_t bktr, char i_flag,
        *dma_prog++ = OP_SYNC   |  BKTR_GEN_IRQ  | BKTR_RESYNC |  BKTR_VRE;
        *dma_prog++ = 0;  /* NULL WORD */
        *dma_prog++ = OP_JUMP ;
-       *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+       *dma_prog++ = (uint32_t) vtophys(bktr->dma_prog);
 
        *dma_prog++ = OP_JUMP;
-       *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+       *dma_prog++ = (uint32_t) vtophys(bktr->dma_prog);
        *dma_prog++ = 0;  /* NULL WORD */
 }
 
@@ -3103,13 +3103,13 @@ yuv422_prog( bktr_ptr_t bktr, char i_flag,
 
        int                     i;
        volatile unsigned int   inst;
-       volatile u_long         target_buffer, t1, buffer;
-       volatile u_long         *dma_prog;
+       volatile uint32_t       target_buffer, t1, buffer;
+       volatile uint32_t       *dma_prog;
         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 = (uint32_t*) bktr->dma_prog;
 
        bktr->capcontrol =   1 << 6 | 1 << 4 |  3;
 
@@ -3133,9 +3133,9 @@ yuv422_prog( bktr_ptr_t bktr, char i_flag,
        /* Construct Write */
        inst  = OP_WRITE123  | OP_SOL | OP_EOL |  (cols); 
        if (bktr->video.addr)
-               target_buffer = (u_long) bktr->video.addr;
+               target_buffer = (uint32_t) bktr->video.addr;
        else
-               target_buffer = (u_long) vtophys(bktr->bigbuf);
+               target_buffer = (uint32_t) vtophys(bktr->bigbuf);
     
        buffer = target_buffer;
 
@@ -3160,7 +3160,7 @@ yuv422_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP ;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t) vtophys(bktr->dma_prog);
                return;
 
        case 2:
@@ -3168,7 +3168,7 @@ yuv422_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t) vtophys(bktr->dma_prog);
                return;
 
        case 3:
@@ -3176,15 +3176,15 @@ yuv422_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP  ;
-               *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog);
+               *dma_prog = (uint32_t) vtophys(bktr->odd_dma_prog);
                break;
        }
 
        if (interlace == 2) {
 
-               dma_prog = (u_long * ) bktr->odd_dma_prog;
+               dma_prog = (uint32_t *) bktr->odd_dma_prog;
 
-               target_buffer  = (u_long) buffer + cols;
+               target_buffer  = (uint32_t) buffer + cols;
                t1 = buffer + cols/2;
                *dma_prog++ = OP_SYNC   |   1 << 15 | BKTR_FM3; 
                *dma_prog++ = 0;  /* NULL WORD */
@@ -3202,7 +3202,7 @@ yuv422_prog( bktr_ptr_t bktr, char i_flag,
        *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++ = (uint32_t) vtophys(bktr->dma_prog) ;
        *dma_prog++ = 0;  /* NULL WORD */
 }
 
@@ -3217,13 +3217,13 @@ yuv12_prog( bktr_ptr_t bktr, char i_flag,
        int                     i;
        volatile unsigned int   inst;
        volatile unsigned int   inst1;
-       volatile u_long         target_buffer, t1, buffer;
-       volatile u_long         *dma_prog;
+       volatile uint32_t       target_buffer, t1, buffer;
+       volatile uint32_t       *dma_prog;
         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 = (uint32_t *) bktr->dma_prog;
 
        bktr->capcontrol =   1 << 6 | 1 << 4 |  3;
 
@@ -3234,9 +3234,9 @@ yuv12_prog( bktr_ptr_t bktr, char i_flag,
        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;
+               target_buffer = (uint32_t) bktr->video.addr;
        else
-               target_buffer = (u_long) vtophys(bktr->bigbuf);
+               target_buffer = (uint32_t) vtophys(bktr->bigbuf);
      
        buffer = target_buffer;
        t1 = buffer;
@@ -3264,7 +3264,7 @@ yuv12_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t) vtophys(bktr->dma_prog);
                return;
 
        case 2:
@@ -3272,22 +3272,22 @@ yuv12_prog( bktr_ptr_t bktr, char i_flag,
                *dma_prog++ = 0;  /* NULL WORD */
 
                *dma_prog++ = OP_JUMP;
-               *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
+               *dma_prog++ = (uint32_t) 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);
+               *dma_prog = (uint32_t) vtophys(bktr->odd_dma_prog);
                break;
        }
 
        if (interlace == 2) {
 
-               dma_prog = (u_long * ) bktr->odd_dma_prog;
+               dma_prog = (uint32_t *) bktr->odd_dma_prog;
 
-               target_buffer  = (u_long) buffer + cols;
+               target_buffer  = (uint32_t) buffer + cols;
                t1 = buffer + cols/2;
                *dma_prog++ = OP_SYNC   | 1 << 15 | BKTR_FM3; 
                *dma_prog++ = 0;  /* NULL WORD */
@@ -3312,7 +3312,7 @@ yuv12_prog( bktr_ptr_t bktr, char i_flag,
        *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++ = (uint32_t) vtophys(bktr->dma_prog);
        *dma_prog++ = 0;  /* NULL WORD */
 }
   
@@ -3768,7 +3768,7 @@ i2cRead( bktr_ptr_t bktr, int addr )
        return ((int)((unsigned char)result));
 }
 
-#define IICBUS(bktr) ((bktr)->i2c_sc.iicbus)
+#define IICBUS(bktr) ((bktr)->i2c_sc.iicbb)
 
 /* The MSP34xx and DPL35xx Audio chip require i2c bus writes of up */
 /* to 5 bytes which the bt848 automated i2c bus controller cannot handle */