1/* BT848 1.24 Driver for Brooktree's Bt848 based cards. 2 The Brooktree BT848 Driver driver is based upon Mark Tinguely and 3 Jim Lowe's driver for the Matrox Meteor PCI card . The 4 Philips SAA 7116 and SAA 7196 are very different chipsets than 5 the BT848. For starters, the BT848 is a one chipset solution and 6 it incorporates a RISC engine to control the DMA transfers -- 7 that is it the actual dma process is control by a program which 8 resides in the hosts memory also the register definitions between --- 187 unchanged lines hidden (view full) --- 196 doing CAP_SINGLEs, and in dual-field capture, don't 197 capture fields for different frames 1981.22 11/08/97 Randall Hopper <rhh@ct.picker.com> 199 Fixes for packed 24bpp - FIFO alignment 2001.23 11/17/97 Amancio <hasty@star-gate.com> 201 Added yuv support mpeg encoding 2021.24 12/27/97 Jonathan Hanna <pangolin@rogers.wave.ca> 203 Patch to support Philips FR1236MK2 tuner |
2041.25 02/02/98 Takeshi Ohashi 205 <ohashi@atohasi.mickey.ai.kyutech.ac.jp> submitted 206 code to support bktr_read . 207 Flemming Jacobsen <fj@schizo.dk.tfs.com> 208 submitted code to support radio available with in 209 some bt848 based cards;additionally, wrote code to 210 correctly recognized his bt848 card. 211 Roger Hardiman <roger@cs.strath.ac.uk> submitted 212 various fixes to smooth out the microcode and made 213 all modes consistent. |
214*/ 215 216#define DDB(x) x 217#define DEB(x) 218 219#ifdef __FreeBSD__ 220#include "bktr.h" |
221#include "pci.h" 222#endif /* __FreeBSD__ */ 223 224#if !defined(__FreeBSD__) || (NBKTR > 0 && NPCI > 0) 225 226#include <sys/param.h> 227#include <sys/systm.h> 228#include <sys/conf.h> --- 197 unchanged lines hidden (view full) --- 426#endif 427 428/* 429 * Parameters describing size of transmitted image. 430 */ 431 432static struct format_params format_params[] = { 433/* # define BT848_IFORM_F_AUTO (0x0) - don't matter. */ |
434 { 525, 26, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, 0 }, |
435/* # define BT848_IFORM_F_NTSCM (0x1) */ |
436 { 525, 26, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 }, |
437/* # define BT848_IFORM_F_NTSCJ (0x2) */ 438 { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 }, 439/* # define BT848_IFORM_F_PALBDGHI (0x3) */ 440 { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT1 }, 441/* # define BT848_IFORM_F_PALM (0x4) */ 442 { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 }, 443/*{ 625, 32, 576, 910, 186, 922, 640, 780, 25, 0x68, 0x5d, BT848_IFORM_X_XT0 }, */ 444/* # define BT848_IFORM_F_PALN (0x5) */ --- 36 unchanged lines hidden (view full) --- 481 * Table of Meteor-supported Pixel Formats (for SETGEO compatibility) 482 */ 483 484/* FIXME: Also add YUV_422 and YUV_PACKED as well */ 485static struct { 486 u_long meteor_format; 487 struct meteor_pixfmt public; 488} meteor_pixfmt_table[] = { |
489 { METEOR_GEO_YUV_12, 490 { 0, METEOR_PIXTYPE_YUV_12, 2, { 0xff0000,0x00ff00,0x0000ff }, 1,1 } 491 }, |
492 493 /* FIXME: Should byte swap flag be on for this one; negative in drvr? */ 494 { METEOR_GEO_YUV_422, 495 { 0, METEOR_PIXTYPE_YUV, 2, { 0xff0000,0x00ff00,0x0000ff }, 1,1 } 496 }, 497 { METEOR_GEO_YUV_PACKED, 498 { 0, METEOR_PIXTYPE_YUV_PACKED, 2, { 0xff0000,0x00ff00,0x0000ff }, 0,1 } 499 }, --- 47 unchanged lines hidden (view full) --- 547/* PLL on a the Philips FR1236MK2 tuner */ 548#define PHILIPS_FR1236_NTSC_WADDR 0xc2 549#define PHILIPS_FR1236_NTSC_RADDR 0xc3 550 551/* guaranteed address for any TSA5522/3 (PLL on all(?) tuners) */ 552#define TSA552x_WADDR 0xc2 553#define TSA552x_RADDR 0xc3 554 |
555#define PHILIPS_PAL_WADDR 0xc2 556#define PHILIPS_PAL_RADDR 0xc3 557 558 |
559#define TSA552x_CB_MSB (0x80) 560#define TSA552x_CB_CP (1<<6) 561#define TSA552x_CB_T2 (1<<5) 562#define TSA552x_CB_T1 (1<<4) 563#define TSA552x_CB_T0 (1<<3) 564#define TSA552x_CB_RSA (1<<2) 565#define TSA552x_CB_RSB (1<<1) 566#define TSA552x_CB_OS (1<<0) |
567#define TSA552x_RADIO (TSA552x_CB_MSB | \ 568 TSA552x_CB_T0) |
569 |
570/* Add RADIO_OFFSET to the "frequency" to indicate that we want to tune */ 571/* the radio (if present) not the TV tuner. */ 572/* 20000 is equivalent to 20000MHz/16 = 1.25GHz - this area is unused. */ 573#define RADIO_OFFSET 20000 |
574 |
575 |
576/* address of BTSC/SAP decoder chip */ 577#define TDA9850_WADDR 0xb6 578#define TDA9850_RADDR 0xb7 579 580/* address of MSP3400C chip */ 581#define MSP3400C_WADDR 0x80 582#define MSP3400C_RADDR 0x81 583 --- 86 unchanged lines hidden (view full) --- 670#ifdef BT848_DUMP 671static int dump_bt848( bt848_ptr_t bt848 ); 672#endif 673 674static void yuvpack_prog( bktr_ptr_t bktr, char i_flag, int cols, 675 int rows, int interlace ); 676static void yuv422_prog( bktr_ptr_t bktr, char i_flag, int cols, 677 int rows, int interlace ); |
678static void yuv12_prog( bktr_ptr_t bktr, char i_flag, int cols, 679 int rows, int interlace ); |
680static void rgb_prog( bktr_ptr_t bktr, char i_flag, int cols, 681 int rows, int interlace ); 682static void build_dma_prog( bktr_ptr_t bktr, char i_flag ); 683 684static bool_t getline(bktr_reg_t *, int); 685static bool_t notclipped(bktr_reg_t * , int , int); 686static bool_t split(bktr_reg_t *, volatile u_long **, int, u_long, int, 687 volatile u_char ** , int ); --- 190 unchanged lines hidden (view full) --- 878 bktr->tuner.channel = 0; 879 bktr->tuner.chnlset = DEFAULT_CHNLSET; 880 bktr->audio_mux_select = 0; 881 bktr->audio_mute_state = FALSE; 882 883 probeCard( bktr, TRUE ); 884 885#ifdef DEVFS |
886 bktr->devfs_token = devfs_add_devswf(&bktr_cdevsw, unit, 887 DV_CHR, 0, 0, 0644, "brooktree"); |
888#endif /* DEVFS */ |
889#if __FreeBSD__ > 2 |
890 fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG); 891 pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 4); |
892#endif |
893 894} 895 896 897/* 898 * interrupt handling routine complete bktr_read() if using interrupts. 899 */ 900static void --- 38 unchanged lines hidden (view full) --- 939 status_sum |= (bktr_status & ~(BT848_INT_RSV0|BT848_INT_RSV1)); 940 status_sum |= ((dstatus & (BT848_DSTATUS_COF|BT848_DSTATUS_LOF)) << 6); 941#endif /* STATUS_SUM */ 942 /* printf( " STATUS %x %x %x \n", 943 dstatus, bktr_status, bt848->risc_count ); 944 */ 945 /* if risc was disabled re-start process again */ 946 if ( !(bktr_status & BT848_INT_RISC_EN) || |
947 ((bktr_status &(BT848_INT_FBUS | 948 BT848_INT_FTRGT | 949 BT848_INT_FDSR | |
950 BT848_INT_PPERR | 951 BT848_INT_RIPERR | 952 BT848_INT_PABORT | 953 BT848_INT_OCERR | |
954 BT848_INT_SCERR) ) != 0) || |
955 ((bt848->tdec == 0) && (bktr_status & TDEC_BITS)) ) { 956 957 u_short tdec_save = bt848->tdec; 958 959 bt848->gpio_dma_ctl = FIFO_RISC_DISABLED; 960 961 bt848->int_mask = ALL_INTS_DISABLED; 962 --- 127 unchanged lines hidden (view full) --- 1090 bt848->gpio_dma_ctl = FIFO_ENABLED; 1091 wakeup((caddr_t)bktr); 1092 } 1093 1094 /* 1095 * If the user requested to be notified via signal, 1096 * let them know the frame is complete. 1097 */ |
1098 |
1099 if (bktr->proc && !(bktr->signal & METEOR_SIG_MODE_MASK)) 1100 psignal( bktr->proc, 1101 bktr->signal&(~METEOR_SIG_MODE_MASK) ); 1102 1103 /* 1104 * Reset the want flags if in continuous or 1105 * synchronous capture mode. 1106 */ --- 254 unchanged lines hidden (view full) --- 1361 1362 if (MINOR(minor(dev)) > 0) 1363 return( ENXIO ); 1364 1365 unit = UNIT(minor(dev)); 1366 if (unit >= NBKTR) /* unit out of range */ 1367 return( ENXIO ); 1368 |
1369 bktr = &(brooktree[unit]); |
1370 bt848 = bktr->base; 1371 |
1372 if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */ 1373 return( ENOMEM ); 1374 1375 if (bktr->flags & METEOR_CAP_MASK) 1376 return( EIO ); /* already capturing */ 1377 |
1378 bt848->cap_ctl = bktr->bktr_cap_ctl; 1379 1380 |
1381 count = bktr->rows * bktr->cols * 1382 pixfmt_table[ bktr->pixfmt ].public.Bpp; 1383 1384 if ((int) uio->uio_iov->iov_len < count) 1385 return( EINVAL ); 1386 1387 bktr->flags &= ~(METEOR_CAP_MASK | METEOR_WANT_MASK); 1388 |
1389 /* capture one frame */ 1390 start_capture(bktr, METEOR_SINGLE); 1391 /* wait for capture to complete */ 1392 bt848->int_stat = ALL_INTS_CLEARED; |
1393 bt848->gpio_dma_ctl = FIFO_ENABLED; |
1394 bt848->gpio_dma_ctl = bktr->capcontrol; 1395 bt848->int_mask = BT848_INT_MYSTERYBIT | 1396 BT848_INT_RISCI | 1397 BT848_INT_VSYNC | 1398 BT848_INT_FMTCHG; |
1399 |
1400 |
1401 status = tsleep((caddr_t)bktr, BKTRPRI, "captur", 0); 1402 if (!status) /* successful capture */ 1403 status = uiomove((caddr_t)bktr->bigbuf, count, uio); 1404 else 1405 printf ("bktr%d: read: tsleep error %d\n", unit, status); 1406 1407 bktr->flags &= ~(METEOR_SINGLE | METEOR_WANT_MASK); 1408 --- 35 unchanged lines hidden (view full) --- 1444 1445 case TUNER_DEV: 1446 return( tuner_ioctl( bktr, unit, cmd, arg, pr ) ); 1447 } 1448 1449 return( ENXIO ); 1450} 1451 |
1452 |
1453/* 1454 * video ioctls 1455 */ 1456static int 1457video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr ) 1458{ 1459 int tmp_int; 1460 bt848_ptr_t bt848; --- 109 unchanged lines hidden (view full) --- 1570 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | 1571 METEOR_PAL; 1572 bt848->adelay = format_params[temp].adelay; 1573 bt848->bdelay = format_params[temp].bdelay; 1574 bktr->format_params = temp; 1575 break; 1576 1577 } |
1578 bktr->dma_prog_loaded = FALSE; |
1579 break; 1580 1581 case METEORSFMT: /* set input format */ 1582 switch(*(unsigned long *)arg & METEOR_FORM_MASK ) { 1583 case 0: /* default */ 1584 case METEOR_FMT_NTSC: 1585 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | 1586 METEOR_NTSC; 1587 bt848->iform &= ~BT848_IFORM_FORMAT; |
1588 bt848->iform |= BT848_IFORM_F_NTSCM | 1589 format_params[BT848_IFORM_F_NTSCM].iform_xtsel; |
1590 bt848->adelay = 0x68; 1591 bt848->bdelay = 0x5d; 1592 bktr->format_params = BT848_IFORM_F_NTSCM; 1593 break; 1594 1595 case METEOR_FMT_PAL: 1596 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | 1597 METEOR_PAL; 1598 bt848->iform &= ~BT848_IFORM_FORMAT; |
1599 bt848->iform |= BT848_IFORM_F_PALBDGHI | 1600 format_params[BT848_IFORM_F_PALBDGHI].iform_xtsel; |
1601 bt848->adelay = 0x7f; 1602 bt848->bdelay = 0x72; 1603 bktr->format_params = BT848_IFORM_F_PALBDGHI; 1604 break; 1605 1606 case METEOR_FMT_AUTOMODE: 1607 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | 1608 METEOR_AUTOMODE; 1609 bt848->iform &= ~BT848_IFORM_FORMAT; 1610 break; 1611 1612 default: 1613 return( EINVAL ); 1614 } |
1615 bktr->dma_prog_loaded = FALSE; |
1616 break; 1617 1618 case METEORGFMT: /* get input format */ 1619 *(u_long *)arg = bktr->flags & METEOR_FORM_MASK; 1620 break; 1621 1622 1623 case BT848GFMT: /* get input format */ --- 198 unchanged lines hidden (view full) --- 1822 1823 case METEORSETGEO: 1824 /* can't change parameters while capturing */ 1825 if (bktr->flags & METEOR_CAP_MASK) 1826 return( EBUSY ); 1827 1828 1829 geo = (struct meteor_geomet *) arg; |
1830 1831 error = 0; 1832 /* Either even or odd, if even & odd, then these a zero */ 1833 if ((geo->oformat & METEOR_GEO_ODD_ONLY) && 1834 (geo->oformat & METEOR_GEO_EVEN_ONLY)) { 1835 printf( "bktr%d: ioctl: Geometry odd or even only.\n", 1836 unit); 1837 return( EINVAL ); --- 64 unchanged lines hidden (view full) --- 1902 1903 if (error) 1904 return error; 1905 1906 bktr->rows = geo->rows; 1907 bktr->cols = geo->columns; 1908 bktr->frames = geo->frames; 1909 |
1910 /* Pixel format (if in meteor pixfmt compatibility mode) */ 1911 if ( bktr->pixfmt_compat ) { 1912 bktr->format = METEOR_GEO_YUV_422; 1913 switch (geo->oformat & METEOR_GEO_OUTPUT_MASK) { 1914 case 0: /* default */ 1915 case METEOR_GEO_RGB16: 1916 bktr->format = METEOR_GEO_RGB16; 1917 break; --- 324 unchanged lines hidden (view full) --- 2242 2243 case BT848_SIGNATURE: 2244 offset = (((struct eeProm *)arg)->offset); 2245 count = (((struct eeProm *)arg)->count); 2246 buf = &(((struct eeProm *)arg)->bytes[ 0 ]); 2247 if ( signCard( bktr, offset, count, buf ) < 0 ) 2248 return( EIO ); 2249 break; |
2250 /* Ioctl's for running the tuner device in radio mode */ 2251#if 0 2252 case RADIO_SETMODE: /* XXX Todo: implement me ... */ 2253 break; 2254 case RADIO_GETFREQ; /* XXX Todo: implement me ... */ 2255 break; 2256#endif 2257 case RADIO_SETFREQ: 2258 /* The argument to this ioctl is NOT freq*16. It is 2259 ** freq*100. 2260 */ |
2261 |
2262 /* The radio in my stereo and the linear regression function 2263 ** in my HP48 have reached the conclusion that in order to 2264 ** set the radio tuner of the FM1216 to f MHz, the value to 2265 ** enter into the PLL is: f*20-407 2266 ** If anyone has the exact values from the spec. sheet 2267 ** please forward them -- fj@login.dknet.dk 2268 */ 2269 temp=(int)*(unsigned long *)arg/5-407 +RADIO_OFFSET; 2270 2271#ifdef BKTR_RADIO_DEBUG 2272 printf("bktr%d: arg=%d temp=%d\n",unit,(int)*(unsigned long *)arg,temp); 2273#endif 2274 2275#ifndef BKTR_RADIO_NOFREQCHECK 2276 /* According to the spec. sheet the band: 87.5MHz-108MHz */ 2277 /* is supported. */ 2278 if(temp<1343+RADIO_OFFSET || temp>1753+RADIO_OFFSET) { 2279 printf("bktr%d: Radio frequency out of range\n",unit); 2280 return(EINVAL); 2281 } 2282#endif 2283 temp_mute( bktr, TRUE ); 2284 temp = tv_freq( bktr, temp ); 2285 temp_mute( bktr, FALSE ); 2286#ifdef BKTR_RADIO_DEBUG 2287 if(temp) 2288 printf("bktr%d: tv_freq returned: %d\n",unit,temp); 2289#endif 2290 if ( temp < 0 ) 2291 return( EINVAL ); 2292 *(unsigned long *)arg = temp; 2293 break; 2294 2295 |
2296 default: 2297 return common_ioctl( bktr, bt848, cmd, arg ); 2298 } 2299 2300 return( 0 ); 2301} 2302 2303 --- 384 unchanged lines hidden (view full) --- 2688 pitch = bktr->video.width; 2689 } 2690 else { 2691 target_buffer = (u_long) vtophys(bktr->bigbuf); 2692 pitch = cols*Bpp; 2693 } 2694 2695 buffer = target_buffer; |
2696 |
2697 |
2698 /* contruct sync : for video packet format */ 2699 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM1; 2700 2701 /* sync, mode indicator packed data */ 2702 *dma_prog++ = 0; /* NULL WORD */ 2703 width = cols; 2704 for (i = 0; i < (rows/interlace); i++) { 2705 target = target_buffer; --- 21 unchanged lines hidden (view full) --- 2727 2728 target_buffer += interlace * pitch; 2729 2730 } 2731 2732 switch (i_flag) { 2733 case 1: 2734 /* sync vre */ |
2735 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; |
2736 *dma_prog++ = 0; /* NULL WORD */ 2737 |
2738 *dma_prog++ = OP_JUMP; |
2739 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 2740 return; 2741 2742 case 2: 2743 /* sync vro */ |
2744 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; |
2745 *dma_prog++ = 0; /* NULL WORD */ 2746 2747 *dma_prog++ = OP_JUMP; 2748 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 2749 return; 2750 2751 case 3: 2752 /* sync vro */ 2753 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO; 2754 *dma_prog++ = 0; /* NULL WORD */ |
2755 *dma_prog++ = OP_JUMP; ; |
2756 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); 2757 break; 2758 } 2759 2760 if (interlace == 2) { |
2761 |
2762 target_buffer = buffer + pitch; 2763 |
2764 dma_prog = (u_long *) bktr->odd_dma_prog; 2765 2766 2767 /* sync vre IRQ bit */ 2768 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM1; 2769 *dma_prog++ = 0; /* NULL WORD */ 2770 width = cols; 2771 for (i = 0; i < (rows/interlace); i++) { --- 93 unchanged lines hidden (view full) --- 2865 *dma_prog++ = inst3; 2866 *dma_prog++ = target_buffer + b; 2867 target_buffer += interlace*(cols * 2); 2868 } 2869 2870 switch (i_flag) { 2871 case 1: 2872 /* sync vre */ |
2873 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; |
2874 *dma_prog++ = 0; /* NULL WORD */ 2875 2876 *dma_prog++ = OP_JUMP; 2877 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 2878 return; 2879 2880 case 2: 2881 /* sync vro */ |
2882 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; |
2883 *dma_prog++ = 0; /* NULL WORD */ 2884 *dma_prog++ = OP_JUMP; 2885 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 2886 return; 2887 2888 case 3: |
2889 /* sync vro */ 2890 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO; |
2891 *dma_prog++ = 0; /* NULL WORD */ 2892 *dma_prog++ = OP_JUMP ; 2893 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); 2894 break; 2895 } 2896 2897 if (interlace == 2) { 2898 --- 10 unchanged lines hidden (view full) --- 2909 *dma_prog++ = target_buffer; 2910 *dma_prog++ = inst3; 2911 *dma_prog++ = target_buffer + b; 2912 target_buffer += interlace * ( cols*2); 2913 } 2914 } 2915 2916 /* sync vro IRQ bit */ |
2917 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE; |
2918 *dma_prog++ = 0; /* NULL WORD */ 2919 *dma_prog++ = OP_JUMP ; 2920 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 2921 2922 *dma_prog++ = OP_JUMP; 2923 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 2924 *dma_prog++ = 0; /* NULL WORD */ 2925} --- 42 unchanged lines hidden (view full) --- 2968 inst = OP_WRITE123 | OP_SOL | OP_EOL | (cols); 2969 if (bktr->video.addr) 2970 target_buffer = (u_long) bktr->video.addr; 2971 else 2972 target_buffer = (u_long) vtophys(bktr->bigbuf); 2973 2974 buffer = target_buffer; 2975 |
2976 t1 = buffer; |
2977 2978 /* contruct sync : for video packet format */ 2979 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; /*sync, mode indicator packed data*/ 2980 *dma_prog++ = 0; /* NULL WORD */ 2981 |
2982 for (i = 0; i < (rows/interlace ) ; i++) { |
2983 *dma_prog++ = inst; 2984 *dma_prog++ = cols/2 | cols/2 << 16; 2985 *dma_prog++ = target_buffer; 2986 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; 2987 *dma_prog++ = t1 + (cols*rows) + (cols*rows/2) + i*cols/2 * interlace; 2988 target_buffer += interlace*cols; 2989 } 2990 2991 switch (i_flag) { 2992 case 1: |
2993 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; /*sync vre*/ |
2994 *dma_prog++ = 0; /* NULL WORD */ 2995 |
2996 *dma_prog++ = OP_JUMP ; |
2997 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 2998 return; 2999 3000 case 2: |
3001 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; /*sync vre*/ |
3002 *dma_prog++ = 0; /* NULL WORD */ 3003 3004 *dma_prog++ = OP_JUMP; 3005 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 3006 return; 3007 3008 case 3: |
3009 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO; |
3010 *dma_prog++ = 0; /* NULL WORD */ 3011 3012 *dma_prog++ = OP_JUMP ; 3013 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); 3014 break; 3015 } 3016 3017 if (interlace == 2) { 3018 3019 dma_prog = (u_long * ) bktr->odd_dma_prog; 3020 3021 target_buffer = (u_long) buffer + cols; |
3022 t1 = buffer + cols/2; |
3023 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; 3024 *dma_prog++ = 0; /* NULL WORD */ 3025 |
3026 for (i = 0; i < (rows/interlace ) ; i++) { |
3027 *dma_prog++ = inst; 3028 *dma_prog++ = cols/2 | cols/2 << 16; 3029 *dma_prog++ = target_buffer; 3030 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; 3031 *dma_prog++ = t1 + (cols*rows) + (cols*rows/2) + i*cols/2 * interlace; 3032 target_buffer += interlace*cols; 3033 } 3034 } 3035 |
3036 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE; |
3037 *dma_prog++ = 0; /* NULL WORD */ 3038 *dma_prog++ = OP_JUMP ; 3039 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog) ; 3040 *dma_prog++ = 0; /* NULL WORD */ 3041} 3042 3043 3044/* 3045 * 3046 */ 3047static void 3048yuv12_prog( bktr_ptr_t bktr, char i_flag, 3049 int cols, int rows, int interlace ){ 3050 |
3051 int i; |
3052 volatile unsigned int inst; 3053 volatile unsigned int inst1; 3054 volatile u_long target_buffer, t1, buffer; 3055 bt848_ptr_t bt848; 3056 volatile u_long *dma_prog; 3057 struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; 3058 3059 bt848 = bktr->base; --- 29 unchanged lines hidden (view full) --- 3089 else 3090 target_buffer = (u_long) vtophys(bktr->bigbuf); 3091 3092 buffer = target_buffer; 3093 t1 = buffer; 3094 3095 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; /*sync, mode indicator packed data*/ 3096 *dma_prog++ = 0; /* NULL WORD */ |
3097 |
3098 for (i = 0; i < (rows/interlace )/2 ; i++) { |
3099 *dma_prog++ = inst; 3100 *dma_prog++ = cols/2 | (cols/2 << 16); 3101 *dma_prog++ = target_buffer; 3102 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; 3103 *dma_prog++ = t1 + (cols*rows) + (cols*rows/4) + i*cols/2 * interlace; 3104 target_buffer += interlace*cols; 3105 *dma_prog++ = inst1; 3106 *dma_prog++ = cols/2 | (cols/2 << 16); 3107 *dma_prog++ = target_buffer; 3108 target_buffer += interlace*cols; 3109 3110 } 3111 3112 switch (i_flag) { 3113 case 1: |
3114 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; /*sync vre*/ |
3115 *dma_prog++ = 0; /* NULL WORD */ |
3116 3117 *dma_prog++ = OP_JUMP; 3118 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); |
3119 return; 3120 3121 case 2: |
3122 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; /*sync vro*/ |
3123 *dma_prog++ = 0; /* NULL WORD */ |
3124 3125 *dma_prog++ = OP_JUMP; 3126 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); |
3127 return; 3128 3129 case 3: 3130 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO; 3131 *dma_prog++ = 0; /* NULL WORD */ |
3132 *dma_prog++ = OP_JUMP ; |
3133 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog); 3134 break; 3135 } 3136 3137 if (interlace == 2) { 3138 3139 dma_prog = (u_long * ) bktr->odd_dma_prog; 3140 3141 target_buffer = (u_long) buffer + cols; |
3142 t1 = buffer + cols/2; 3143 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; |
3144 *dma_prog++ = 0; /* NULL WORD */ 3145 3146 for (i = 0; i < ((rows/interlace )/2 ) ; i++) { 3147 *dma_prog++ = inst; 3148 *dma_prog++ = cols/2 | (cols/2 << 16); 3149 *dma_prog++ = target_buffer; 3150 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace; 3151 *dma_prog++ = t1 + (cols*rows) + (cols*rows/4) + i*cols/2 * interlace; --- 5 unchanged lines hidden (view full) --- 3157 3158 } 3159 3160 3161 } 3162 3163 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE; 3164 *dma_prog++ = 0; /* NULL WORD */ |
3165 *dma_prog++ = OP_JUMP; |
3166 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog); 3167 *dma_prog++ = 0; /* NULL WORD */ 3168} 3169 3170 3171 3172/* 3173 * 3174 */ 3175static void 3176build_dma_prog( bktr_ptr_t bktr, char i_flag ) 3177{ 3178 int rows, cols, interlace; 3179 bt848_ptr_t bt848; |
3180 int tmp_int; 3181 unsigned int temp; 3182 struct format_params *fp; |
3183 struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ]; |
3184 |
3185 |
3186 fp = &format_params[bktr->format_params]; 3187 |
3188 bt848 = bktr->base; 3189 bt848->int_mask = ALL_INTS_DISABLED; 3190 3191 /* disable FIFO & RISC, leave other bits alone */ 3192 bt848->gpio_dma_ctl &= ~FIFO_RISC_ENABLED; 3193 |
3194 /* set video parameters */ 3195 temp = ((quad_t ) fp->htotal* (quad_t) fp->horizontal * 4096 3196 / fp->vertical / bktr->cols) - 4096; 3197 bt848->e_hscale_lo = temp & 0xff; 3198 bt848->o_hscale_lo = temp & 0xff; 3199 bt848->e_hscale_hi = (temp >> 8) & 0xff; 3200 bt848->o_hscale_hi = (temp >> 8) & 0xff; 3201 3202 /* horizontal active */ 3203 temp = bktr->cols; 3204 bt848->e_hactive_lo = temp & 0xff; 3205 bt848->o_hactive_lo = temp & 0xff; 3206 bt848->e_crop &= ~0x3; 3207 bt848->o_crop &= ~0x3; 3208 bt848->e_crop |= (temp >> 8) & 0x3; 3209 bt848->o_crop |= (temp >> 8) & 0x3; 3210 3211 /* horizontal delay */ 3212 temp = (fp->hdelay * bktr->cols) / fp->hactive; 3213 temp = temp & 0x3fe; 3214 bt848->e_delay_lo = temp & 0xff; 3215 bt848->o_delay_lo = temp & 0xff; 3216 bt848->e_crop &= ~0xc; 3217 bt848->o_crop &= ~0xc; 3218 bt848->e_crop |= (temp >> 6) & 0xc; 3219 bt848->o_crop |= (temp >> 6) & 0xc; 3220 3221 /* vertical scale */ 3222 3223 if (bktr->flags & METEOR_ONLY_ODD_FIELDS || 3224 bktr->flags & METEOR_ONLY_EVEN_FIELDS) 3225 tmp_int = 65536 - 3226 (((fp->vactive * 256 + (bktr->rows/2)) / bktr->rows) - 512); 3227 else { 3228 tmp_int = 65536 - 3229 (((fp->vactive * 512 + (bktr->rows / 2)) / bktr->rows) - 512); 3230 } 3231 3232 tmp_int &= 0x1fff; 3233 bt848->e_vscale_lo = tmp_int & 0xff; 3234 bt848->o_vscale_lo = tmp_int & 0xff; 3235 bt848->e_vscale_hi &= ~0x1f; 3236 bt848->o_vscale_hi &= ~0x1f; 3237 bt848->e_vscale_hi |= (tmp_int >> 8) & 0x1f; 3238 bt848->o_vscale_hi |= (tmp_int >> 8) & 0x1f; 3239 3240 3241 /* vertical active */ 3242 bt848->e_crop &= ~0x30; 3243 bt848->e_crop |= (fp->vactive >> 4) & 0x30; 3244 bt848->e_vactive_lo = fp->vactive & 0xff; 3245 bt848->o_crop &= ~0x30; 3246 bt848->o_crop |= (fp->vactive >> 4) & 0x30; 3247 bt848->o_vactive_lo = fp->vactive & 0xff; 3248 3249 /* vertical delay */ 3250 bt848->e_vdelay_lo = fp->vdelay; 3251 bt848->o_vdelay_lo = fp->vdelay; 3252 3253 /* end of video params */ 3254 |
3255 /* capture control */ 3256 switch (i_flag) { 3257 case 1: 3258 bktr->bktr_cap_ctl = 3259 (BT848_CAP_CTL_DITH_FRAME | BT848_CAP_CTL_EVEN); 3260 bt848->e_vscale_hi &= ~0x20; 3261 bt848->o_vscale_hi &= ~0x20; 3262 interlace = 1; --- 572 unchanged lines hidden (view full) --- 3835 u_char bandAddrs[ 3 ]; 3836}; 3837 */ 3838const struct TUNER tuners[] = { 3839/* XXX FIXME: fill in the band-switch crosspoints */ 3840 /* NO_TUNER */ 3841 { "<none>", /* the 'name' */ 3842 TTYPE_XXX, /* input type */ |
3843 0x00, /* PLL write address */ 3844 { 0x00, /* control byte for PLL */ 3845 0x00, 3846 0x00, 3847 0x00 }, |
3848 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3849 { 0x00, 0x00, 0x00,0x00} }, /* the band-switch values */ |
3850 3851 /* TEMIC_NTSC */ 3852 { "Temic NTSC", /* the 'name' */ 3853 TTYPE_NTSC, /* input type */ 3854 TEMIC_NTSC_WADDR, /* PLL write address */ |
3855 { TSA552x_SCONTROL, /* control byte for PLL */ 3856 TSA552x_SCONTROL, 3857 TSA552x_SCONTROL, 3858 0x00 }, |
3859 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3860 { 0x02, 0x04, 0x01, 0x00 } }, /* the band-switch values */ |
3861 3862 /* TEMIC_PAL */ 3863 { "Temic PAL", /* the 'name' */ 3864 TTYPE_PAL, /* input type */ 3865 TEMIC_PALI_WADDR, /* PLL write address */ |
3866 { TSA552x_SCONTROL, /* control byte for PLL */ 3867 TSA552x_SCONTROL, 3868 TSA552x_SCONTROL, 3869 0x00 }, |
3870 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3871 { 0x02, 0x04, 0x01, 0x00 } }, /* the band-switch values */ |
3872 3873 /* TEMIC_SECAM */ 3874 { "Temic SECAM", /* the 'name' */ 3875 TTYPE_SECAM, /* input type */ 3876 0x00, /* PLL write address */ |
3877 { TSA552x_SCONTROL, /* control byte for PLL */ 3878 TSA552x_SCONTROL, 3879 TSA552x_SCONTROL, 3880 0x00 }, |
3881 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3882 { 0x02, 0x04, 0x01,0x00 } }, /* the band-switch values */ |
3883 3884 /* PHILIPS_NTSC */ 3885 { "Philips NTSC", /* the 'name' */ 3886 TTYPE_NTSC, /* input type */ 3887 PHILIPS_NTSC_WADDR, /* PLL write address */ |
3888 { TSA552x_SCONTROL, /* control byte for PLL */ 3889 TSA552x_SCONTROL, 3890 TSA552x_SCONTROL, 3891 0x00 }, |
3892 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3893 { 0xa0, 0x90, 0x30, 0x00 } }, /* the band-switch values */ |
3894 3895 /* PHILIPS_PAL */ 3896 { "Philips PAL", /* the 'name' */ 3897 TTYPE_PAL, /* input type */ |
3898 PHILIPS_PAL_WADDR, /* PLL write address */ 3899 { TSA552x_FCONTROL, /* control byte for PLL */ 3900 TSA552x_FCONTROL, 3901 TSA552x_FCONTROL, 3902 TSA552x_RADIO }, |
3903 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3904 { 0xa0, 0x90, 0x30, 0xa5 } }, /* the band-switch values */ 3905 /* Radio: (for FM1216) 3906 ** 0xa4 sets radiomode 3907 ** bit0 - AFC 3908 ** bit1 - Mono 3909 ** bit3 - Mute */ |
3910 3911 /* PHILIPS_SECAM */ 3912 { "Philips SECAM", /* the 'name' */ 3913 TTYPE_SECAM, /* input type */ 3914 0x00, /* PLL write address */ |
3915 { TSA552x_SCONTROL, /* control byte for PLL */ 3916 TSA552x_SCONTROL, 3917 TSA552x_SCONTROL, 3918 0x00 }, |
3919 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3920 { 0xa0, 0x90, 0x30,0x00 } }, /* the band-switch values */ |
3921 3922 /* TEMIC_PAL I */ 3923 { "Temic PAL I", /* the 'name' */ 3924 TTYPE_PAL, /* input type */ 3925 TEMIC_PALI_WADDR, /* PLL write address */ |
3926 { TSA552x_SCONTROL, /* control byte for PLL */ 3927 TSA552x_SCONTROL, 3928 TSA552x_SCONTROL, 3929 0x00 }, |
3930 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3931 { 0x02, 0x04, 0x01,0x00 } }, /* the band-switch values */ |
3932 3933 /* PHILIPS_PAL */ 3934 { "Philips PAL I", /* the 'name' */ 3935 TTYPE_PAL, /* input type */ |
3936 TEMIC_PALI_WADDR, /* PLL write address */ 3937 { TSA552x_SCONTROL, /* control byte for PLL */ 3938 TSA552x_SCONTROL, 3939 TSA552x_SCONTROL, 3940 0x00 }, |
3941 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3942 { 0xa0, 0x90, 0x30,0x00 } }, /* the band-switch values */ |
3943 3944 /* PHILIPS_FR1236_NTSC */ 3945 { "Philips FR1236 NTSC FM", /* the 'name' */ 3946 TTYPE_NTSC, /* input type */ 3947 PHILIPS_FR1236_NTSC_WADDR, /* PLL write address */ |
3948 { TSA552x_SCONTROL, /* control byte for PLL */ 3949 TSA552x_SCONTROL, 3950 TSA552x_SCONTROL, 3951 0x00}, |
3952 { 0x00, 0x00 }, /* band-switch crosspoints */ |
3953 { 0xa0, 0x90, 0x30,0x00 } }, /* the band-switch values */ |
3954}; 3955 3956 3957/* 3958 * get a signature of the card 3959 * read all 128 possible i2c read addresses from 0x01 thru 0xff 3960 * build a bit array with a 1 bit for each i2c device that responds 3961 * --- 469 unchanged lines hidden (view full) --- 4431 if ( tuner == NULL ) 4432 return( -1 ); 4433 4434 /* 4435 * select the band based on frequency 4436 * XXX FIXME: get the cross-over points from the tuner struct 4437 */ 4438 if ( frequency < (160 * FREQFACTOR) ) |
4439 N = 0; |
4440 else if ( frequency < (454 * FREQFACTOR) ) |
4441 N = 1; |
4442 else |
4443 N = 2; |
4444 |
4445 if(frequency > RADIO_OFFSET) { 4446 N=3; 4447 frequency -= RADIO_OFFSET; 4448 } 4449 |
4450 /* set the address of the PLL */ |
4451 addr = tuner->pllAddr; 4452 control = tuner->pllControl[ N ]; 4453 band = tuner->bandAddrs[ N ]; 4454 if(!(band && control)) /* Don't try to set un- */ 4455 return(-1); /* supported modes. */ |
4456 |
4457 |
4458 /* 4459 * N = 16 * { fRF(pc) + fIF(pc) } 4460 * where: 4461 * pc is picture carrier, fRF & fIF are in mHz 4462 * 4463 * frequency was passed in as mHz * 16 4464 */ 4465#if defined( TEST_TUNER_AFC ) --- 266 unchanged lines hidden --- |