@@ -360,56 +360,87 @@ bttv_apply_geo(struct bttv *btv, struct bttv_geometry *geo, int odd)
360
360
/* ---------------------------------------------------------- */
361
361
/* risc group / risc main loop / dma management */
362
362
363
- void
364
- bttv_set_dma (struct bttv * btv , int override )
363
+ static void bttv_set_risc_status (struct bttv * btv )
365
364
{
366
- unsigned long cmd ;
367
- int capctl ;
365
+ unsigned long cmd = BT848_RISC_JUMP ;
366
+ /*
367
+ * The value of btv->loop_irq sets or resets the RISC_STATUS for video
368
+ * and/or vbi by setting the value of bits [23:16] in the first dword
369
+ * of the JUMP instruction:
370
+ * video risc: set (1) and reset (~1)
371
+ * vbi risc: set(4) and reset (~4)
372
+ */
373
+ if (btv -> loop_irq ) {
374
+ cmd |= BT848_RISC_IRQ ;
375
+ cmd |= (btv -> loop_irq & 0x0f ) << 16 ;
376
+ cmd |= (~btv -> loop_irq & 0x0f ) << 20 ;
377
+ }
378
+ btv -> main .cpu [RISC_SLOT_LOOP ] = cpu_to_le32 (cmd );
379
+ }
380
+
381
+ static void bttv_set_irq_timer (struct bttv * btv )
382
+ {
383
+ if (btv -> curr .frame_irq || btv -> loop_irq || btv -> cvbi )
384
+ mod_timer (& btv -> timeout , jiffies + BTTV_TIMEOUT );
385
+ else
386
+ del_timer (& btv -> timeout );
387
+ }
388
+
389
+ static int bttv_set_capture_control (struct bttv * btv , int start_capture )
390
+ {
391
+ int capctl = 0 ;
392
+
393
+ if (btv -> curr .top || btv -> curr .bottom )
394
+ capctl = BT848_CAP_CTL_CAPTURE_ODD |
395
+ BT848_CAP_CTL_CAPTURE_EVEN ;
396
+
397
+ if (btv -> cvbi )
398
+ capctl |= BT848_CAP_CTL_CAPTURE_VBI_ODD |
399
+ BT848_CAP_CTL_CAPTURE_VBI_EVEN ;
400
+
401
+ capctl |= start_capture ;
402
+
403
+ btaor (capctl , ~0x0f , BT848_CAP_CTL );
404
+
405
+ return capctl ;
406
+ }
407
+
408
+ static void bttv_start_dma (struct bttv * btv )
409
+ {
410
+ if (btv -> dma_on )
411
+ return ;
412
+ btwrite (btv -> main .dma , BT848_RISC_STRT_ADD );
413
+ btor (0x3 , BT848_GPIO_DMA_CTL );
414
+ btv -> dma_on = 1 ;
415
+ }
416
+
417
+ static void bttv_stop_dma (struct bttv * btv )
418
+ {
419
+ if (!btv -> dma_on )
420
+ return ;
421
+ btand (~0x3 , BT848_GPIO_DMA_CTL );
422
+ btv -> dma_on = 0 ;
423
+ }
424
+
425
+ void bttv_set_dma (struct bttv * btv , int start_capture )
426
+ {
427
+ int capctl = 0 ;
368
428
369
- btv -> cap_ctl = 0 ;
370
- if (NULL != btv -> curr .top ) btv -> cap_ctl |= 0x02 ;
371
- if (NULL != btv -> curr .bottom ) btv -> cap_ctl |= 0x01 ;
372
- if (NULL != btv -> cvbi ) btv -> cap_ctl |= 0x0c ;
429
+ bttv_set_risc_status (btv );
430
+ bttv_set_irq_timer (btv );
431
+ capctl = bttv_set_capture_control (btv , start_capture );
373
432
374
- capctl = 0 ;
375
- capctl |= (btv -> cap_ctl & 0x03 ) ? 0x03 : 0x00 ; /* capture */
376
- capctl |= ( btv -> cap_ctl & 0x0c ) ? 0x0c : 0x00 ; /* vbi data */
377
- capctl |= override ;
433
+ if ( capctl )
434
+ bttv_start_dma (btv );
435
+ else
436
+ bttv_stop_dma ( btv ) ;
378
437
379
438
d2printk ("%d: capctl=%x lirq=%d top=%08llx/%08llx even=%08llx/%08llx\n" ,
380
439
btv -> c .nr ,capctl ,btv -> loop_irq ,
381
440
btv -> cvbi ? (unsigned long long )btv -> cvbi -> top .dma : 0 ,
382
441
btv -> curr .top ? (unsigned long long )btv -> curr .top -> top .dma : 0 ,
383
442
btv -> cvbi ? (unsigned long long )btv -> cvbi -> bottom .dma : 0 ,
384
443
btv -> curr .bottom ? (unsigned long long )btv -> curr .bottom -> bottom .dma : 0 );
385
-
386
- cmd = BT848_RISC_JUMP ;
387
- if (btv -> loop_irq ) {
388
- cmd |= BT848_RISC_IRQ ;
389
- cmd |= (btv -> loop_irq & 0x0f ) << 16 ;
390
- cmd |= (~btv -> loop_irq & 0x0f ) << 20 ;
391
- }
392
- if (btv -> curr .frame_irq || btv -> loop_irq || btv -> cvbi ) {
393
- mod_timer (& btv -> timeout , jiffies + BTTV_TIMEOUT );
394
- } else {
395
- del_timer (& btv -> timeout );
396
- }
397
- btv -> main .cpu [RISC_SLOT_LOOP ] = cpu_to_le32 (cmd );
398
-
399
- btaor (capctl , ~0x0f , BT848_CAP_CTL );
400
- if (capctl ) {
401
- if (btv -> dma_on )
402
- return ;
403
- btwrite (btv -> main .dma , BT848_RISC_STRT_ADD );
404
- btor (3 , BT848_GPIO_DMA_CTL );
405
- btv -> dma_on = 1 ;
406
- } else {
407
- if (!btv -> dma_on )
408
- return ;
409
- btand (~3 , BT848_GPIO_DMA_CTL );
410
- btv -> dma_on = 0 ;
411
- }
412
- return ;
413
444
}
414
445
415
446
int
0 commit comments