Deleted Added
sdiff udiff text old ( 32926 ) new ( 33025 )
full compact
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
204
205*/
206
207#define DDB(x) x
208#define DEB(x)
209
210#ifdef __FreeBSD__
211#include "bktr.h"
212#include "opt_devfs.h"
213#include "pci.h"
214#endif /* __FreeBSD__ */
215
216#if !defined(__FreeBSD__) || (NBKTR > 0 && NPCI > 0)
217
218#include <sys/param.h>
219#include <sys/systm.h>
220#include <sys/conf.h>

--- 197 unchanged lines hidden (view full) ---

418#endif
419
420/*
421 * Parameters describing size of transmitted image.
422 */
423
424static struct format_params format_params[] = {
425/* # define BT848_IFORM_F_AUTO (0x0) - don't matter. */
426 { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, 0 },
427/* # define BT848_IFORM_F_NTSCM (0x1) */
428 { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 },
429/* # define BT848_IFORM_F_NTSCJ (0x2) */
430 { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 },
431/* # define BT848_IFORM_F_PALBDGHI (0x3) */
432 { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT1 },
433/* # define BT848_IFORM_F_PALM (0x4) */
434 { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 },
435/*{ 625, 32, 576, 910, 186, 922, 640, 780, 25, 0x68, 0x5d, BT848_IFORM_X_XT0 }, */
436/* # define BT848_IFORM_F_PALN (0x5) */

--- 36 unchanged lines hidden (view full) ---

473 * Table of Meteor-supported Pixel Formats (for SETGEO compatibility)
474 */
475
476/* FIXME: Also add YUV_422 and YUV_PACKED as well */
477static struct {
478 u_long meteor_format;
479 struct meteor_pixfmt public;
480} meteor_pixfmt_table[] = {
481
482 /* FIXME: Should byte swap flag be on for this one; negative in drvr? */
483 { METEOR_GEO_YUV_422,
484 { 0, METEOR_PIXTYPE_YUV, 2, { 0xff0000,0x00ff00,0x0000ff }, 1,1 }
485 },
486 { METEOR_GEO_YUV_PACKED,
487 { 0, METEOR_PIXTYPE_YUV_PACKED, 2, { 0xff0000,0x00ff00,0x0000ff }, 0,1 }
488 },

--- 47 unchanged lines hidden (view full) ---

536/* PLL on a the Philips FR1236MK2 tuner */
537#define PHILIPS_FR1236_NTSC_WADDR 0xc2
538#define PHILIPS_FR1236_NTSC_RADDR 0xc3
539
540/* guaranteed address for any TSA5522/3 (PLL on all(?) tuners) */
541#define TSA552x_WADDR 0xc2
542#define TSA552x_RADDR 0xc3
543
544#define TSA552x_CB_MSB (0x80)
545#define TSA552x_CB_CP (1<<6)
546#define TSA552x_CB_T2 (1<<5)
547#define TSA552x_CB_T1 (1<<4)
548#define TSA552x_CB_T0 (1<<3)
549#define TSA552x_CB_RSA (1<<2)
550#define TSA552x_CB_RSB (1<<1)
551#define TSA552x_CB_OS (1<<0)
552
553
554/* address of BTSC/SAP decoder chip */
555#define TDA9850_WADDR 0xb6
556#define TDA9850_RADDR 0xb7
557
558/* address of MSP3400C chip */
559#define MSP3400C_WADDR 0x80
560#define MSP3400C_RADDR 0x81
561

--- 86 unchanged lines hidden (view full) ---

648#ifdef BT848_DUMP
649static int dump_bt848( bt848_ptr_t bt848 );
650#endif
651
652static void yuvpack_prog( bktr_ptr_t bktr, char i_flag, int cols,
653 int rows, int interlace );
654static void yuv422_prog( bktr_ptr_t bktr, char i_flag, int cols,
655 int rows, int interlace );
656static void rgb_prog( bktr_ptr_t bktr, char i_flag, int cols,
657 int rows, int interlace );
658static void build_dma_prog( bktr_ptr_t bktr, char i_flag );
659
660static bool_t getline(bktr_reg_t *, int);
661static bool_t notclipped(bktr_reg_t * , int , int);
662static bool_t split(bktr_reg_t *, volatile u_long **, int, u_long, int,
663 volatile u_char ** , int );

--- 190 unchanged lines hidden (view full) ---

854 bktr->tuner.channel = 0;
855 bktr->tuner.chnlset = DEFAULT_CHNLSET;
856 bktr->audio_mux_select = 0;
857 bktr->audio_mute_state = FALSE;
858
859 probeCard( bktr, TRUE );
860
861#ifdef DEVFS
862 bktr->devfs_bktr_token = devfs_add_devswf(&bktr_cdevsw, unit,
863 DV_CHR, 0, 0, 0444, "bktr%d", unit);
864 bktr->devfs_tuner_token = devfs_add_devswf(&bktr_cdevsw, unit+16,
865 DV_CHR, 0, 0, 0444, "tuner%d", unit);
866#endif /* DEVFS */
867 fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG);
868 pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 4);
869
870}
871
872
873/*
874 * interrupt handling routine complete bktr_read() if using interrupts.
875 */
876static void

--- 38 unchanged lines hidden (view full) ---

915 status_sum |= (bktr_status & ~(BT848_INT_RSV0|BT848_INT_RSV1));
916 status_sum |= ((dstatus & (BT848_DSTATUS_COF|BT848_DSTATUS_LOF)) << 6);
917#endif /* STATUS_SUM */
918 /* printf( " STATUS %x %x %x \n",
919 dstatus, bktr_status, bt848->risc_count );
920 */
921 /* if risc was disabled re-start process again */
922 if ( !(bktr_status & BT848_INT_RISC_EN) ||
923 ((bktr_status & (BT848_INT_FTRGT |
924 BT848_INT_PPERR |
925 BT848_INT_RIPERR |
926 BT848_INT_PABORT |
927 BT848_INT_OCERR |
928 BT848_INT_SCERR)) != 0) ||
929 ((bt848->tdec == 0) && (bktr_status & TDEC_BITS)) ) {
930
931 u_short tdec_save = bt848->tdec;
932
933 bt848->gpio_dma_ctl = FIFO_RISC_DISABLED;
934
935 bt848->int_mask = ALL_INTS_DISABLED;
936

--- 127 unchanged lines hidden (view full) ---

1064 bt848->gpio_dma_ctl = FIFO_ENABLED;
1065 wakeup((caddr_t)bktr);
1066 }
1067
1068 /*
1069 * If the user requested to be notified via signal,
1070 * let them know the frame is complete.
1071 */
1072 if (bktr->proc && !(bktr->signal & METEOR_SIG_MODE_MASK))
1073 psignal( bktr->proc,
1074 bktr->signal&(~METEOR_SIG_MODE_MASK) );
1075
1076 /*
1077 * Reset the want flags if in continuous or
1078 * synchronous capture mode.
1079 */

--- 254 unchanged lines hidden (view full) ---

1334
1335 if (MINOR(minor(dev)) > 0)
1336 return( ENXIO );
1337
1338 unit = UNIT(minor(dev));
1339 if (unit >= NBKTR) /* unit out of range */
1340 return( ENXIO );
1341
1342 printf("btkr driver : use ioctl interface . read function not implemented \n");
1343 return( ENXIO );
1344
1345 bktr = &(brooktree[unit]);
1346 if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */
1347 return( ENOMEM );
1348
1349 if (bktr->flags & METEOR_CAP_MASK)
1350 return( EIO ); /* already capturing */
1351
1352 count = bktr->rows * bktr->cols *
1353 pixfmt_table[ bktr->pixfmt ].public.Bpp;
1354
1355 if ((int) uio->uio_iov->iov_len < count)
1356 return( EINVAL );
1357
1358 bktr->flags &= ~(METEOR_CAP_MASK | METEOR_WANT_MASK);
1359
1360 /* Start capture */
1361 bt848 = bktr->base;
1362 bt848->gpio_dma_ctl = FIFO_ENABLED;
1363 bt848->gpio_dma_ctl = FIFO_RISC_ENABLED;
1364
1365 status = tsleep((caddr_t)bktr, BKTRPRI, "captur", 0);
1366 if (!status) /* successful capture */
1367 status = uiomove((caddr_t)bktr->bigbuf, count, uio);
1368 else
1369 printf ("bktr%d: read: tsleep error %d\n", unit, status);
1370
1371 bktr->flags &= ~(METEOR_SINGLE | METEOR_WANT_MASK);
1372

--- 35 unchanged lines hidden (view full) ---

1408
1409 case TUNER_DEV:
1410 return( tuner_ioctl( bktr, unit, cmd, arg, pr ) );
1411 }
1412
1413 return( ENXIO );
1414}
1415
1416/*
1417 * video ioctls
1418 */
1419static int
1420video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr )
1421{
1422 int tmp_int;
1423 bt848_ptr_t bt848;

--- 109 unchanged lines hidden (view full) ---

1533 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) |
1534 METEOR_PAL;
1535 bt848->adelay = format_params[temp].adelay;
1536 bt848->bdelay = format_params[temp].bdelay;
1537 bktr->format_params = temp;
1538 break;
1539
1540 }
1541 break;
1542
1543 case METEORSFMT: /* set input format */
1544 switch(*(unsigned long *)arg & METEOR_FORM_MASK ) {
1545 case 0: /* default */
1546 case METEOR_FMT_NTSC:
1547 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) |
1548 METEOR_NTSC;
1549 bt848->iform &= ~BT848_IFORM_FORMAT;
1550 bt848->iform |= BT848_IFORM_F_NTSCM;
1551 bt848->adelay = 0x68;
1552 bt848->bdelay = 0x5d;
1553 bktr->format_params = BT848_IFORM_F_NTSCM;
1554 break;
1555
1556 case METEOR_FMT_PAL:
1557 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) |
1558 METEOR_PAL;
1559 bt848->iform &= ~BT848_IFORM_FORMAT;
1560 bt848->iform |= BT848_IFORM_F_PALBDGHI;
1561 bt848->adelay = 0x7f;
1562 bt848->bdelay = 0x72;
1563 bktr->format_params = BT848_IFORM_F_PALBDGHI;
1564 break;
1565
1566 case METEOR_FMT_AUTOMODE:
1567 bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) |
1568 METEOR_AUTOMODE;
1569 bt848->iform &= ~BT848_IFORM_FORMAT;
1570 break;
1571
1572 default:
1573 return( EINVAL );
1574 }
1575 break;
1576
1577 case METEORGFMT: /* get input format */
1578 *(u_long *)arg = bktr->flags & METEOR_FORM_MASK;
1579 break;
1580
1581
1582 case BT848GFMT: /* get input format */

--- 198 unchanged lines hidden (view full) ---

1781
1782 case METEORSETGEO:
1783 /* can't change parameters while capturing */
1784 if (bktr->flags & METEOR_CAP_MASK)
1785 return( EBUSY );
1786
1787
1788 geo = (struct meteor_geomet *) arg;
1789 fp = &format_params[bktr->format_params];
1790
1791 error = 0;
1792 /* Either even or odd, if even & odd, then these a zero */
1793 if ((geo->oformat & METEOR_GEO_ODD_ONLY) &&
1794 (geo->oformat & METEOR_GEO_EVEN_ONLY)) {
1795 printf( "bktr%d: ioctl: Geometry odd or even only.\n",
1796 unit);
1797 return( EINVAL );

--- 64 unchanged lines hidden (view full) ---

1862
1863 if (error)
1864 return error;
1865
1866 bktr->rows = geo->rows;
1867 bktr->cols = geo->columns;
1868 bktr->frames = geo->frames;
1869
1870 temp = ((quad_t ) fp->htotal* (quad_t) fp->horizontal * 4096
1871 / fp->vertical / bktr->cols) - 4096;
1872 bt848->e_hscale_lo = temp & 0xff;
1873 bt848->o_hscale_lo = temp & 0xff;
1874 bt848->e_hscale_hi = (temp >> 8) & 0xff;
1875 bt848->o_hscale_hi = (temp >> 8) & 0xff;
1876
1877 /* horizontal active */
1878 temp = bktr->cols;
1879 bt848->e_hactive_lo = temp & 0xff;
1880 bt848->o_hactive_lo = temp & 0xff;
1881 bt848->e_crop &= ~0x3;
1882 bt848->o_crop &= ~0x3;
1883 bt848->e_crop |= (temp >> 8) & 0x3;
1884 bt848->o_crop |= (temp >> 8) & 0x3;
1885
1886 /* horizontal delay */
1887 temp = (fp->hdelay * bktr->cols) / fp->hactive;
1888 temp = temp + 2; /* why?? - rmt */
1889 temp = temp & 0x3fe;
1890 bt848->e_delay_lo = temp & 0xff;
1891 bt848->o_delay_lo = temp & 0xff;
1892 bt848->e_crop &= ~0xc;
1893 bt848->o_crop &= ~0xc;
1894 bt848->e_crop |= (temp >> 6) & 0xc;
1895 bt848->o_crop |= (temp >> 6) & 0xc;
1896
1897 /* vertical scale */
1898 if (geo->oformat & METEOR_GEO_ODD_ONLY ||
1899 geo->oformat & METEOR_GEO_EVEN_ONLY)
1900 tmp_int = 65536 -
1901 ((fp->vactive * 256 / bktr->rows) - 512);
1902 else {
1903 tmp_int = 65536 -
1904 (((fp->vactive * 512) / bktr->rows) - 512);
1905 }
1906
1907 tmp_int &= 0x1fff;
1908
1909 bt848->e_vscale_lo = tmp_int & 0xff;
1910 bt848->o_vscale_lo = tmp_int & 0xff;
1911 bt848->e_vscale_hi &= ~0x1f;
1912 bt848->o_vscale_hi &= ~0x1f;
1913 bt848->e_vscale_hi |= (tmp_int >> 8) & 0x1f;
1914 bt848->o_vscale_hi |= (tmp_int >> 8) & 0x1f;
1915
1916 /* vertical active */
1917 bt848->e_crop &= ~0x30;
1918 bt848->e_crop |= (fp->vactive >> 4) & 0x30;
1919 bt848->e_vactive_lo = fp->vactive & 0xff;
1920 bt848->o_crop &= ~0x30;
1921 bt848->o_crop |= (fp->vactive >> 4) & 0x30;
1922 bt848->o_vactive_lo = fp->vactive & 0xff;
1923
1924 /* vertical delay */
1925 bt848->e_vdelay_lo = fp->vdelay;
1926 bt848->o_vdelay_lo = fp->vdelay;
1927
1928 /* Pixel format (if in meteor pixfmt compatibility mode) */
1929 if ( bktr->pixfmt_compat ) {
1930 bktr->format = METEOR_GEO_YUV_422;
1931 switch (geo->oformat & METEOR_GEO_OUTPUT_MASK) {
1932 case 0: /* default */
1933 case METEOR_GEO_RGB16:
1934 bktr->format = METEOR_GEO_RGB16;
1935 break;

--- 324 unchanged lines hidden (view full) ---

2260
2261 case BT848_SIGNATURE:
2262 offset = (((struct eeProm *)arg)->offset);
2263 count = (((struct eeProm *)arg)->count);
2264 buf = &(((struct eeProm *)arg)->bytes[ 0 ]);
2265 if ( signCard( bktr, offset, count, buf ) < 0 )
2266 return( EIO );
2267 break;
2268
2269 default:
2270 return common_ioctl( bktr, bt848, cmd, arg );
2271 }
2272
2273 return( 0 );
2274}
2275
2276

--- 384 unchanged lines hidden (view full) ---

2661 pitch = bktr->video.width;
2662 }
2663 else {
2664 target_buffer = (u_long) vtophys(bktr->bigbuf);
2665 pitch = cols*Bpp;
2666 }
2667
2668 buffer = target_buffer;
2669 if (interlace == 2 && rows < 320 ) target_buffer += pitch;
2670
2671 /* contruct sync : for video packet format */
2672 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM1;
2673
2674 /* sync, mode indicator packed data */
2675 *dma_prog++ = 0; /* NULL WORD */
2676 width = cols;
2677 for (i = 0; i < (rows/interlace); i++) {
2678 target = target_buffer;

--- 21 unchanged lines hidden (view full) ---

2700
2701 target_buffer += interlace * pitch;
2702
2703 }
2704
2705 switch (i_flag) {
2706 case 1:
2707 /* sync vre */
2708 *dma_prog++ = OP_SYNC | 0xC << 24 | 1 << 24 | BKTR_VRE;
2709 *dma_prog++ = 0; /* NULL WORD */
2710
2711 *dma_prog++ = OP_JUMP | 0xC << 24;
2712 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2713 return;
2714
2715 case 2:
2716 /* sync vro */
2717 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 20 | BKTR_VRO;
2718 *dma_prog++ = 0; /* NULL WORD */
2719
2720 *dma_prog++ = OP_JUMP;
2721 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2722 return;
2723
2724 case 3:
2725 /* sync vro */
2726 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO;
2727 *dma_prog++ = 0; /* NULL WORD */
2728 *dma_prog++ = OP_JUMP | 0xc << 24 ;
2729 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog);
2730 break;
2731 }
2732
2733 if (interlace == 2) {
2734 if (rows < 320 )
2735 target_buffer = buffer ;
2736 else
2737 target_buffer = buffer + pitch;
2738
2739 dma_prog = (u_long *) bktr->odd_dma_prog;
2740
2741
2742 /* sync vre IRQ bit */
2743 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM1;
2744 *dma_prog++ = 0; /* NULL WORD */
2745 width = cols;
2746 for (i = 0; i < (rows/interlace); i++) {

--- 93 unchanged lines hidden (view full) ---

2840 *dma_prog++ = inst3;
2841 *dma_prog++ = target_buffer + b;
2842 target_buffer += interlace*(cols * 2);
2843 }
2844
2845 switch (i_flag) {
2846 case 1:
2847 /* sync vre */
2848 *dma_prog++ = OP_SYNC | 0xC << 24 | BKTR_VRE;
2849 *dma_prog++ = 0; /* NULL WORD */
2850
2851 *dma_prog++ = OP_JUMP;
2852 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2853 return;
2854
2855 case 2:
2856 /* sync vro */
2857 *dma_prog++ = OP_SYNC | 0xC << 24 | BKTR_VRO;
2858 *dma_prog++ = 0; /* NULL WORD */
2859 *dma_prog++ = OP_JUMP;
2860 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2861 return;
2862
2863 case 3:
2864 /* sync vre */
2865 *dma_prog++ = OP_SYNC | BKTR_VRE;
2866 *dma_prog++ = 0; /* NULL WORD */
2867 *dma_prog++ = OP_JUMP ;
2868 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog);
2869 break;
2870 }
2871
2872 if (interlace == 2) {
2873

--- 10 unchanged lines hidden (view full) ---

2884 *dma_prog++ = target_buffer;
2885 *dma_prog++ = inst3;
2886 *dma_prog++ = target_buffer + b;
2887 target_buffer += interlace * ( cols*2);
2888 }
2889 }
2890
2891 /* sync vro IRQ bit */
2892 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE;
2893 *dma_prog++ = 0; /* NULL WORD */
2894 *dma_prog++ = OP_JUMP ;
2895 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2896
2897 *dma_prog++ = OP_JUMP;
2898 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2899 *dma_prog++ = 0; /* NULL WORD */
2900}

--- 42 unchanged lines hidden (view full) ---

2943 inst = OP_WRITE123 | OP_SOL | OP_EOL | (cols);
2944 if (bktr->video.addr)
2945 target_buffer = (u_long) bktr->video.addr;
2946 else
2947 target_buffer = (u_long) vtophys(bktr->bigbuf);
2948
2949 buffer = target_buffer;
2950
2951 t1 = target_buffer;
2952
2953 /* contruct sync : for video packet format */
2954 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; /*sync, mode indicator packed data*/
2955 *dma_prog++ = 0; /* NULL WORD */
2956
2957 for (i = 0; i < (rows/interlace ) - 1; i++) {
2958 *dma_prog++ = inst;
2959 *dma_prog++ = cols/2 | cols/2 << 16;
2960 *dma_prog++ = target_buffer;
2961 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace;
2962 *dma_prog++ = t1 + (cols*rows) + (cols*rows/2) + i*cols/2 * interlace;
2963 target_buffer += interlace*cols;
2964 }
2965
2966 switch (i_flag) {
2967 case 1:
2968 *dma_prog++ = OP_SYNC | 0xC << 24 | 1 << 24 | BKTR_VRE; /*sync vre*/
2969 *dma_prog++ = 0; /* NULL WORD */
2970
2971 *dma_prog++ = OP_JUMP | 0xc << 24;
2972 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2973 return;
2974
2975 case 2:
2976 *dma_prog++ = OP_SYNC | 0xC << 24 | 1 << 24 | BKTR_VRO; /*sync vre*/
2977 *dma_prog++ = 0; /* NULL WORD */
2978
2979 *dma_prog++ = OP_JUMP;
2980 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
2981 return;
2982
2983 case 3:
2984 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_VRO;
2985 *dma_prog++ = 0; /* NULL WORD */
2986
2987 *dma_prog++ = OP_JUMP ;
2988 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog);
2989 break;
2990 }
2991
2992 if (interlace == 2) {
2993
2994 dma_prog = (u_long * ) bktr->odd_dma_prog;
2995
2996 target_buffer = (u_long) buffer + cols;
2997 t1 = target_buffer + cols/2;
2998 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3;
2999 *dma_prog++ = 0; /* NULL WORD */
3000
3001 for (i = 0; i < (rows/interlace ) - 1; i++) {
3002 *dma_prog++ = inst;
3003 *dma_prog++ = cols/2 | cols/2 << 16;
3004 *dma_prog++ = target_buffer;
3005 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace;
3006 *dma_prog++ = t1 + (cols*rows) + (cols*rows/2) + i*cols/2 * interlace;
3007 target_buffer += interlace*cols;
3008 }
3009 }
3010
3011 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE;
3012 *dma_prog++ = 0; /* NULL WORD */
3013 *dma_prog++ = OP_JUMP ;
3014 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog) ;
3015 *dma_prog++ = 0; /* NULL WORD */
3016}
3017
3018
3019/*
3020 *
3021 */
3022static void
3023yuv12_prog( bktr_ptr_t bktr, char i_flag,
3024 int cols, int rows, int interlace ){
3025
3026 int i, k;
3027 volatile unsigned int inst;
3028 volatile unsigned int inst1;
3029 volatile u_long target_buffer, t1, buffer;
3030 bt848_ptr_t bt848;
3031 volatile u_long *dma_prog;
3032 struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ];
3033
3034 bt848 = bktr->base;

--- 29 unchanged lines hidden (view full) ---

3064 else
3065 target_buffer = (u_long) vtophys(bktr->bigbuf);
3066
3067 buffer = target_buffer;
3068 t1 = buffer;
3069
3070 *dma_prog++ = OP_SYNC | 1 << 15 | BKTR_FM3; /*sync, mode indicator packed data*/
3071 *dma_prog++ = 0; /* NULL WORD */
3072 if (i_flag > 2)
3073 k = 1;
3074 else k = 0;
3075
3076 for (i = 0; i < (rows/interlace )/2 - k; i++) {
3077 *dma_prog++ = inst;
3078 *dma_prog++ = cols/2 | (cols/2 << 16);
3079 *dma_prog++ = target_buffer;
3080 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace;
3081 *dma_prog++ = t1 + (cols*rows) + (cols*rows/4) + i*cols/2 * interlace;
3082 target_buffer += interlace*cols;
3083 *dma_prog++ = inst1;
3084 *dma_prog++ = cols/2 | (cols/2 << 16);
3085 *dma_prog++ = target_buffer;
3086 target_buffer += interlace*cols;
3087
3088 }
3089
3090 switch (i_flag) {
3091 case 1:
3092 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRO; /*sync vro*/
3093 *dma_prog++ = 0; /* NULL WORD */
3094
3095 *dma_prog++ = OP_JUMP ;
3096 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
3097 return;
3098
3099 case 2:
3100 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_VRE; /*sync vre*/
3101 *dma_prog++ = 0; /* NULL WORD */
3102
3103 *dma_prog++ = OP_JUMP ;
3104 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
3105 return;
3106
3107 case 3:
3108 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRO;
3109 *dma_prog++ = 0; /* NULL WORD */
3110 *dma_prog++ = OP_JUMP | 0xC << 24;
3111 *dma_prog = (u_long ) vtophys(bktr->odd_dma_prog);
3112 break;
3113 }
3114
3115 if (interlace == 2) {
3116
3117 dma_prog = (u_long * ) bktr->odd_dma_prog;
3118
3119 target_buffer = (u_long) buffer + cols;
3120 t1 = target_buffer + cols/2;
3121 *dma_prog++ = OP_SYNC | 1 << 24 | BKTR_FM3;
3122 *dma_prog++ = 0; /* NULL WORD */
3123
3124 for (i = 0; i < ((rows/interlace )/2 ) ; i++) {
3125 *dma_prog++ = inst;
3126 *dma_prog++ = cols/2 | (cols/2 << 16);
3127 *dma_prog++ = target_buffer;
3128 *dma_prog++ = t1 + (cols*rows) + i*cols/2 * interlace;
3129 *dma_prog++ = t1 + (cols*rows) + (cols*rows/4) + i*cols/2 * interlace;

--- 5 unchanged lines hidden (view full) ---

3135
3136 }
3137
3138
3139 }
3140
3141 *dma_prog++ = OP_SYNC | 1 << 24 | 1 << 15 | BKTR_VRE;
3142 *dma_prog++ = 0; /* NULL WORD */
3143 *dma_prog++ = OP_JUMP | 0xC << 24;
3144 *dma_prog++ = (u_long ) vtophys(bktr->dma_prog);
3145 *dma_prog++ = 0; /* NULL WORD */
3146}
3147
3148
3149
3150/*
3151 *
3152 */
3153static void
3154build_dma_prog( bktr_ptr_t bktr, char i_flag )
3155{
3156 int rows, cols, interlace;
3157 bt848_ptr_t bt848;
3158 struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ];
3159
3160 bt848 = bktr->base;
3161 bt848->int_mask = ALL_INTS_DISABLED;
3162
3163 /* disable FIFO & RISC, leave other bits alone */
3164 bt848->gpio_dma_ctl &= ~FIFO_RISC_ENABLED;
3165
3166 /* capture control */
3167 switch (i_flag) {
3168 case 1:
3169 bktr->bktr_cap_ctl =
3170 (BT848_CAP_CTL_DITH_FRAME | BT848_CAP_CTL_EVEN);
3171 bt848->e_vscale_hi &= ~0x20;
3172 bt848->o_vscale_hi &= ~0x20;
3173 interlace = 1;

--- 572 unchanged lines hidden (view full) ---

3746 u_char bandAddrs[ 3 ];
3747};
3748 */
3749const struct TUNER tuners[] = {
3750/* XXX FIXME: fill in the band-switch crosspoints */
3751 /* NO_TUNER */
3752 { "<none>", /* the 'name' */
3753 TTYPE_XXX, /* input type */
3754 0x00, /* PLL write address */
3755 0x00, /* control byte for PLL */
3756 { 0x00, 0x00 }, /* band-switch crosspoints */
3757 { 0x00, 0x00, 0x00 } }, /* the band-switch values */
3758
3759 /* TEMIC_NTSC */
3760 { "Temic NTSC", /* the 'name' */
3761 TTYPE_NTSC, /* input type */
3762 TEMIC_NTSC_WADDR, /* PLL write address */
3763 TSA552x_SCONTROL, /* control byte for PLL */
3764 { 0x00, 0x00 }, /* band-switch crosspoints */
3765 { 0x02, 0x04, 0x01 } }, /* the band-switch values */
3766
3767 /* TEMIC_PAL */
3768 { "Temic PAL", /* the 'name' */
3769 TTYPE_PAL, /* input type */
3770 TEMIC_PALI_WADDR, /* PLL write address */
3771 TSA552x_SCONTROL, /* control byte for PLL */
3772 { 0x00, 0x00 }, /* band-switch crosspoints */
3773 { 0x02, 0x04, 0x01 } }, /* the band-switch values */
3774
3775 /* TEMIC_SECAM */
3776 { "Temic SECAM", /* the 'name' */
3777 TTYPE_SECAM, /* input type */
3778 0x00, /* PLL write address */
3779 TSA552x_SCONTROL, /* control byte for PLL */
3780 { 0x00, 0x00 }, /* band-switch crosspoints */
3781 { 0x02, 0x04, 0x01 } }, /* the band-switch values */
3782
3783 /* PHILIPS_NTSC */
3784 { "Philips NTSC", /* the 'name' */
3785 TTYPE_NTSC, /* input type */
3786 PHILIPS_NTSC_WADDR, /* PLL write address */
3787 TSA552x_SCONTROL, /* control byte for PLL */
3788 { 0x00, 0x00 }, /* band-switch crosspoints */
3789 { 0xa0, 0x90, 0x30 } }, /* the band-switch values */
3790
3791 /* PHILIPS_PAL */
3792 { "Philips PAL", /* the 'name' */
3793 TTYPE_PAL, /* input type */
3794 0x00, /* PLL write address */
3795 TSA552x_SCONTROL, /* control byte for PLL */
3796 { 0x00, 0x00 }, /* band-switch crosspoints */
3797 { 0xa0, 0x90, 0x30 } }, /* the band-switch values */
3798
3799 /* PHILIPS_SECAM */
3800 { "Philips SECAM", /* the 'name' */
3801 TTYPE_SECAM, /* input type */
3802 0x00, /* PLL write address */
3803 TSA552x_SCONTROL, /* control byte for PLL */
3804 { 0x00, 0x00 }, /* band-switch crosspoints */
3805 { 0xa0, 0x90, 0x30 } }, /* the band-switch values */
3806
3807 /* TEMIC_PAL I */
3808 { "Temic PAL I", /* the 'name' */
3809 TTYPE_PAL, /* input type */
3810 TEMIC_PALI_WADDR, /* PLL write address */
3811 TSA552x_SCONTROL, /* control byte for PLL */
3812 { 0x00, 0x00 }, /* band-switch crosspoints */
3813 { 0x02, 0x04, 0x01 } }, /* the band-switch values */
3814
3815 /* PHILIPS_PAL */
3816 { "Philips PAL I", /* the 'name' */
3817 TTYPE_PAL, /* input type */
3818 0x00, /* PLL write address */
3819 TSA552x_SCONTROL, /* control byte for PLL */
3820 { 0x00, 0x00 }, /* band-switch crosspoints */
3821 { 0xa0, 0x90, 0x30 } }, /* the band-switch values */
3822
3823 /* PHILIPS_FR1236_NTSC */
3824 { "Philips FR1236 NTSC FM", /* the 'name' */
3825 TTYPE_NTSC, /* input type */
3826 PHILIPS_FR1236_NTSC_WADDR, /* PLL write address */
3827 TSA552x_SCONTROL, /* control byte for PLL */
3828 { 0x00, 0x00 }, /* band-switch crosspoints */
3829 { 0xa0, 0x90, 0x30 } }, /* the band-switch values */
3830};
3831
3832
3833/*
3834 * get a signature of the card
3835 * read all 128 possible i2c read addresses from 0x01 thru 0xff
3836 * build a bit array with a 1 bit for each i2c device that responds
3837 *

--- 469 unchanged lines hidden (view full) ---

4307 if ( tuner == NULL )
4308 return( -1 );
4309
4310 /*
4311 * select the band based on frequency
4312 * XXX FIXME: get the cross-over points from the tuner struct
4313 */
4314 if ( frequency < (160 * FREQFACTOR) )
4315 band = tuner->bandAddrs[ 0 ];
4316 else if ( frequency < (454 * FREQFACTOR) )
4317 band = tuner->bandAddrs[ 1 ];
4318 else
4319 band = tuner->bandAddrs[ 2 ];
4320
4321 /* set the address of the PLL */
4322 addr = tuner->pllAddr;
4323 control = tuner->pllControl;
4324
4325 /*
4326 * N = 16 * { fRF(pc) + fIF(pc) }
4327 * where:
4328 * pc is picture carrier, fRF & fIF are in mHz
4329 *
4330 * frequency was passed in as mHz * 16
4331 */
4332#if defined( TEST_TUNER_AFC )

--- 266 unchanged lines hidden ---