Lines Matching refs:saa
81 #define NewCard (saa->boardcfg[3])
82 #define ChipControl (saa->boardcfg[1])
83 #define NTSCFirstActive (saa->boardcfg[4])
84 #define PALFirstActive (saa->boardcfg[5])
85 #define NTSCLastActive (saa->boardcfg[54])
86 #define PALLastActive (saa->boardcfg[55])
87 #define Have2MB (saa->boardcfg[18] & 0x40)
88 #define HaveCS8420 (saa->boardcfg[18] & 0x04)
89 #define IBMMPEGCD20 (saa->boardcfg[18] & 0x20)
90 #define HaveCS3310 (saa->boardcfg[18] & 0x01)
91 #define CS3310MaxLvl ((saa->boardcfg[30] << 8) | saa->boardcfg[31])
92 #define HaveCS4341 (saa->boardcfg[40] == 2)
93 #define SDIType (saa->boardcfg[27])
94 #define CurrentMode (saa->boardcfg[2])
115 static void I2CWipe(struct saa7146 *saa)
143 static int I2CRead(struct saa7146 *saa, unsigned char addr,
149 I2CWipe(saa);
155 I2CWipe(saa);
196 static int I2CWrite(struct saa7146 *saa, unsigned char addr, unsigned char b1,
203 I2CWipe(saa);
208 I2CWipe(saa);
220 static void attach_inform(struct saa7146 *saa, int id)
224 DEBUG(printk(KERN_DEBUG "stradis%d: i2c: device found=%02x\n", saa->nr,
228 saa->boardcfg[i] = I2CRead(saa, 0xa0, i, 1);
230 if (saa->boardcfg[0] != 0) {
232 "BEEN IGNORED\n", saa->nr);
234 saa->boardcfg[i] = rescue_eeprom[i];
237 printk("stradis%d: config =", saa->nr);
239 printk(" %02x", saa->boardcfg[i]);
245 static void I2CBusScan(struct saa7146 *saa)
249 if ((I2CRead(saa, i, 0, 0)) >= 0)
250 attach_inform(saa, i);
255 static int wait_for_debi_done(struct saa7146 *saa)
278 static int debiwrite(struct saa7146 *saa, u32 config, int addr,
284 if (wait_for_debi_done(saa) < 0)
290 saawrite(virt_to_bus(saa->dmadebi), SAA7146_DEBI_AD);
297 static u32 debiread(struct saa7146 *saa, u32 config, int addr, int count)
303 if (wait_for_debi_done(saa) < 0)
305 saawrite(virt_to_bus(saa->dmadebi), SAA7146_DEBI_AD);
313 wait_for_debi_done(saa);
324 static void do_irq_send_data(struct saa7146 *saa)
330 if (saa->playmode != VID_PLAY_NORMAL)
331 saa->audtail = saa->audhead = 0;
332 if (saa->audhead <= saa->audtail)
333 audbytes = saa->audtail - saa->audhead;
335 audbytes = 65536 - (saa->audhead - saa->audtail);
336 if (saa->vidhead <= saa->vidtail)
337 vidbytes = saa->vidtail - saa->vidhead;
339 vidbytes = 524288 - (saa->vidhead - saa->vidtail);
340 if (audbytes == 0 && vidbytes == 0 && saa->osdtail == saa->osdhead) {
345 if (audbytes >= 2048 && (debiread(saa, debNormal, IBM_MP2_AUD_FIFO, 2)
347 if (saa->audhead > saa->audtail)
348 split = 65536 - saa->audhead;
353 memcpy(saa->dmadebi, saa->audbuf + saa->audhead, split);
354 saa->audhead = 0;
358 memcpy(saa->dmadebi + split, saa->audbuf + saa->audhead,
360 saa->audhead += audbytes;
361 saa->audhead &= 0xffff;
362 debiwrite(saa, debAudio, (NewCard ? IBM_MP2_AUD_FIFO :
364 wake_up_interruptible(&saa->audq);
366 } else if (vidbytes >= 30720 && (debiread(saa, debNormal,
368 if (saa->vidhead > saa->vidtail)
369 split = 524288 - saa->vidhead;
374 memcpy(saa->dmadebi, saa->vidbuf + saa->vidhead, split);
375 saa->vidhead = 0;
379 memcpy(saa->dmadebi + split, saa->vidbuf + saa->vidhead,
381 saa->vidhead += vidbytes;
382 saa->vidhead &= 0x7ffff;
383 debiwrite(saa, debVideo, (NewCard ? IBM_MP2_FIFO :
385 wake_up_interruptible(&saa->vidq);
390 static void send_osd_data(struct saa7146 *saa)
392 int size = saa->osdtail - saa->osdhead;
398 debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR,
399 (saa->osdhead >> 3), 2);
400 memcpy(saa->dmadebi, &saa->osdbuf[saa->osdhead], size);
401 saa->osdhead += size;
403 debiwrite(saa, debNormal, IBM_MP2_OSD_DATA, 0, size);
405 if (saa->osdhead >= saa->osdtail) {
406 saa->osdhead = saa->osdtail = 0;
407 debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00c, 2);
413 struct saa7146 *saa = dev_id;
428 do_irq_send_data(saa);
433 istat = debiread(saa, debNormal, IBM_MP2_HOST_INT, 2);
436 send_osd_data(saa);
441 saa->vidinfo.frame_count++;
457 saa->vidinfo.frame_count = 0;
458 saa->vidinfo.h_size = 704;
459 saa->vidinfo.v_size = 480;
462 if (saa->endmarkhead != saa->endmarktail) {
463 saa->audhead =
464 saa->endmark[saa->endmarkhead];
465 saa->endmarkhead++;
466 if (saa->endmarkhead >= MAX_MARKS)
467 saa->endmarkhead = 0;
473 IDEBUG(printk("stradis%d irq: PPEF\n", saa->nr));
476 IDEBUG(printk("stradis%d irq: PABO\n", saa->nr));
479 IDEBUG(printk("stradis%d irq: PPED\n", saa->nr));
482 IDEBUG(printk("stradis%d irq: RPS_I1\n", saa->nr));
485 IDEBUG(printk("stradis%d irq: RPS_I0\n", saa->nr));
488 IDEBUG(printk("stradis%d irq: RPS_LATE1\n", saa->nr));
491 IDEBUG(printk("stradis%d irq: RPS_LATE0\n", saa->nr));
494 IDEBUG(printk("stradis%d irq: RPS_E1\n", saa->nr));
497 IDEBUG(printk("stradis%d irq: RPS_E0\n", saa->nr));
500 IDEBUG(printk("stradis%d irq: RPS_TO1\n", saa->nr));
503 IDEBUG(printk("stradis%d irq: RPS_TO0\n", saa->nr));
506 IDEBUG(printk("stradis%d irq: UPLD\n", saa->nr));
509 IDEBUG(printk("stradis%d irq: DEBI_E\n", saa->nr));
512 IDEBUG(printk("stradis%d irq: I2C_S\n", saa->nr));
515 IDEBUG(printk("stradis%d irq: I2C_E\n", saa->nr));
518 IDEBUG(printk("stradis%d irq: A2_IN\n", saa->nr));
521 IDEBUG(printk("stradis%d irq: A2_OUT\n", saa->nr));
524 IDEBUG(printk("stradis%d irq: A1_IN\n", saa->nr));
527 IDEBUG(printk("stradis%d irq: A1_OUT\n", saa->nr));
530 IDEBUG(printk("stradis%d irq: AFOU\n", saa->nr));
533 IDEBUG(printk("stradis%d irq: V_PE\n", saa->nr));
536 IDEBUG(printk("stradis%d irq: VFOU\n", saa->nr));
539 IDEBUG(printk("stradis%d irq: FIDA\n", saa->nr));
542 IDEBUG(printk("stradis%d irq: FIDB\n", saa->nr));
545 IDEBUG(printk("stradis%d irq: PIN3\n", saa->nr));
548 IDEBUG(printk("stradis%d irq: PIN2\n", saa->nr));
551 IDEBUG(printk("stradis%d irq: PIN0\n", saa->nr));
554 IDEBUG(printk("stradis%d irq: ECS\n", saa->nr));
557 IDEBUG(printk("stradis%d irq: EC3S\n", saa->nr));
560 IDEBUG(printk("stradis%d irq: EC0S\n", saa->nr));
566 saa->nr, count);
570 "stradis%d: IRQ loop cleared\n", saa->nr);
576 static int ibm_send_command(struct saa7146 *saa,
582 debiwrite(saa, debNormal, IBM_MP2_COMMAND, (command << 1)| 1,2);
584 debiwrite(saa, debNormal, IBM_MP2_COMMAND, command << 1, 2);
585 debiwrite(saa, debNormal, IBM_MP2_CMD_DATA, data, 2);
586 debiwrite(saa, debNormal, IBM_MP2_CMD_STAT, 1, 2);
588 (debiread(saa, debNormal, IBM_MP2_CMD_STAT, 2) & 1); i++)
595 static void cs4341_setlevel(struct saa7146 *saa, int left, int right)
597 I2CWrite(saa, 0x22, 0x03, left > 94 ? 94 : left, 2);
598 I2CWrite(saa, 0x22, 0x04, right > 94 ? 94 : right, 2);
601 static void initialize_cs4341(struct saa7146 *saa)
607 I2CWrite(saa, 0x22, 0x01, 0x11, 2);
609 I2CWrite(saa, 0x22, 0x02, 0x49, 2);
611 I2CWrite(saa, 0x22, 0x03, 0x00, 2);
613 I2CWrite(saa, 0x22, 0x04, 0x00, 2);
614 I2CWrite(saa, 0x22, 0x01, 0x10, 2);
615 if (I2CRead(saa, 0x22, 0x02, 1) == 0x49)
619 printk("stradis%d: CS4341 initialized (%d)\n", saa->nr, i);
623 static void initialize_cs8420(struct saa7146 *saa, int pro)
632 I2CWrite(saa, 0x20, init8420[i * 2], init8420[i * 2 + 1], 2);
634 I2CWrite(saa, 0x20, sequence[i * 2], sequence[i * 2 + 1], 2);
635 printk("stradis%d: CS8420 initialized\n", saa->nr);
638 static void initialize_saa7121(struct saa7146 *saa, int dopal)
651 I2CWrite(saa, 0x88, 0x3a, 0x13, 2);
653 I2CWrite(saa, 0x88, 0x6b, 0x20, 2);
655 I2CWrite(saa, 0x88, 0x6c,
658 I2CWrite(saa, 0x88, 0x6d,
661 I2CWrite(saa, 0x88, 0x7a,
665 I2CWrite(saa, 0x88, 0x7b,
669 I2CWrite(saa, 0x88, sequence[i * 2],
673 I2CWrite(saa, 0x88, 0x6b,
676 I2CWrite(saa, 0x88, 0x7a,
680 I2CWrite(saa, 0x88, 0x7b,
684 I2CWrite(saa, 0x88, sequence[i * 2],
690 static void set_genlock_offset(struct saa7146 *saa, int noffset)
705 debiwrite(saa, debNormal, XILINX_GLDELAY, nCode, 2);
708 static void set_out_format(struct saa7146 *saa, int mode)
710 initialize_saa7121(saa, (mode == VIDEO_MODE_NTSC ? 0 : 1));
711 saa->boardcfg[2] = mode;
715 debiwrite(saa, debNormal, XILINX_CTL0, 0x0808, 2);
719 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 0xe100, 2);
722 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
724 debiwrite(saa, debNormal, IBM_MP2_DISP_DLY,
728 debiwrite(saa, debNormal, XILINX_CTL0, 0x0800, 2);
731 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
733 debiwrite(saa, debNormal, IBM_MP2_DISP_DLY,
752 struct saa7146 *saa;
764 saa = &saa7146s[num];
765 if (saa->boardcfg[0] > 20)
767 loadtwo = (saa->boardcfg[18] & 0x10);
783 dmabuf = (u16 *) saa->dmadebi;
784 newdma = (u8 *) saa->dmadebi;
788 if (!strncmp(&saa->boardcfg[42], bitdata->loadwhat, 8))
790 else if (loadtwo && !strncmp(&saa->boardcfg[19],
793 else if (!saa->boardcfg[42] && !strncmp("decxl",
800 if (saa->boardcfg[0] && loadfile == 1)
802 if (saa->boardcfg[0] != 1 && loadfile == 2)
804 saa->boardcfg[0]++; /* mark fpga handled */
805 printk("stradis%d: loading %s\n", saa->nr,
840 printk(KERN_INFO "stradis%d: no fpga INIT\n", saa->nr);
848 debiwrite(saa, 0x01420000, 0, 0,
852 saa->nr);
859 debiwrite(saa, 0x014a0000, 0, 0,
868 saa->nr);
880 printk(KERN_INFO "stradis%d: FPGA Loaded\n", saa->nr);
881 saa->boardcfg[0] = 26; /* mark fpga programmed */
883 debiwrite(saa, debNormal, XILINX_PWM, 0, 2);
887 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT,
890 debiwrite(saa, debNormal, XILINX_CTL0, 0xffc4, 2);
894 debiwrite(saa, debNormal, XILINX_CTL0,
898 debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2);
899 saa->boardcfg[4] = 22; /* set NTSC First Active Line */
900 saa->boardcfg[5] = 23; /* set PAL First Active Line */
901 saa->boardcfg[54] = 2; /* set NTSC Last Active Line - 256 */
902 saa->boardcfg[55] = 54; /* set PAL Last Active Line - 256 */
903 set_out_format(saa, VIDEO_MODE_NTSC);
906 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 4, 2);
909 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 0, 2);
910 debiread(saa, debNormal, IBM_MP2_CHIP_CONTROL, 2);
911 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 0x10, 2);
912 debiwrite(saa, debNormal, IBM_MP2_CMD_ADDR, 0, 2);
913 debiwrite(saa, debNormal, IBM_MP2_CHIP_MODE, 0x2e, 2);
917 debiwrite(saa, debNormal, 0x80c0, 6, 2);
923 initialize_cs8420(saa, 0);
927 initialize_cs4341(saa);
929 debiwrite(saa, debNormal, IBM_MP2_INFC_CTL, 0x48, 2);
930 debiwrite(saa, debNormal, IBM_MP2_BEEP_CTL, 0xa000, 2);
931 debiwrite(saa, debNormal, IBM_MP2_DISP_LBOR, 0, 2);
932 debiwrite(saa, debNormal, IBM_MP2_DISP_TBOR, 0, 2);
934 set_genlock_offset(saa, 0);
935 debiwrite(saa, debNormal, IBM_MP2_FRNT_ATTEN, 0, 2);
937 debiwrite(saa, debNormal, XILINX_CTL0, 0x8080, 2);
943 static int do_ibm_reset(struct saa7146 *saa)
946 if (saa->boardcfg[0] < 37)
950 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, 0, 2);
953 saa->audhead = saa->audtail = 0;
954 saa->vidhead = saa->vidtail = 0;
963 debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2);
965 set_out_format(saa, CurrentMode);
966 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 4, 2);
969 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 0, 2);
970 debiread(saa, debNormal, IBM_MP2_CHIP_CONTROL, 2);
971 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2);
972 debiwrite(saa, debNormal, IBM_MP2_CHIP_MODE, 0x2e, 2);
976 debiwrite(saa, debNormal, 0x80c0, 6, 2);
982 initialize_cs8420(saa, 1);
986 initialize_cs4341(saa);
988 debiwrite(saa, debNormal, IBM_MP2_INFC_CTL, 0x48, 2);
989 debiwrite(saa, debNormal, IBM_MP2_BEEP_CTL, 0xa000, 2);
990 debiwrite(saa, debNormal, IBM_MP2_DISP_LBOR, 0, 2);
991 debiwrite(saa, debNormal, IBM_MP2_DISP_TBOR, 0, 2);
993 set_genlock_offset(saa, 0);
994 debiwrite(saa, debNormal, IBM_MP2_FRNT_ATTEN, 0, 2);
995 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2);
996 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2);
997 if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER,
999 printk(KERN_ERR "stradis%d: IBM config failed\n", saa->nr);
1003 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, ((i << 8)| i),2);
1006 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2);
1008 debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, 0x4037, 2);
1009 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2);
1010 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
1012 debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00c, 2);
1014 debiread(saa, debNormal, IBM_MP2_HOST_INT, 2);
1015 debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2);
1024 struct saa7146 *saa;
1027 saa = &saa7146s[num];
1029 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0xa55a, 2);
1030 i = debiread(saa, debNormal, IBM_MP2_OSD_SIZE, 2);
1033 saa->nr, i);
1036 if (saa->boardcfg[0] > 27)
1039 saa->boardcfg[1] = 0x13; /* no-sync default */
1040 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2);
1041 debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2);
1043 debiwrite(saa, debNormal, IBM_MP2_PROC_IDATA,
1046 debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2);
1047 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2);
1048 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1050 saa->boardcfg[0] = 28;
1053 if (saa->boardcfg[0] > 35)
1056 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2);
1057 debiwrite(saa, debNormal, IBM_MP2_AUD_IADDR, 0, 2);
1059 debiwrite(saa, debNormal, IBM_MP2_AUD_IDATA,
1061 debiwrite(saa, debNormal, IBM_MP2_AUD_IADDR, 0, 2);
1062 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2);
1063 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2);
1064 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2);
1065 if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER,
1068 "failed\n", saa->nr);
1073 debiwrite(saa, debNormal, XILINX_PWM,
1074 saa->boardcfg[14] +
1075 (saa->boardcfg[13] << 8), 2);
1077 debiwrite(saa, debNormal, XILINX_PWM, 0x46, 2);
1081 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT,
1085 saa->nr, 18 + (debiread(saa, debNormal,
1088 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1090 debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, 0x4037,
1092 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2);
1093 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
1095 debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00c, 2);
1096 debiread(saa, debNormal, IBM_MP2_HOST_INT, 2);
1100 debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2);
1101 saa->boardcfg[0] = 37;
1146 static void saa7146_set_winsize(struct saa7146 *saa)
1150 saa->win.color_fmt = format =
1151 (saa->win.depth == 15) ? palette2fmt[VIDEO_PALETTE_RGB555] :
1152 palette2fmt[bpp2fmt[(saa->win.bpp - 1) & 3]];
1153 offset = saa->win.x * saa->win.bpp + saa->win.y * saa->win.bpl;
1154 saawrite(saa->win.vidadr + offset, SAA7146_BASE_EVEN1);
1155 saawrite(saa->win.vidadr + offset + saa->win.bpl, SAA7146_BASE_ODD1);
1156 saawrite(saa->win.bpl * 2, SAA7146_PITCH1);
1157 saawrite(saa->win.vidadr + saa->win.bpl * saa->win.sheight,
1161 offset = (704 / (saa->win.width - 1)) & 0x3f;
1163 offset = (720896 / saa->win.width) / (offset + 1);
1166 yacl = /*(480 / saa->win.height - 1) & 0x3f */ 0;
1167 ysci = 1024 - (saa->win.height * 1024 / 480);
1169 yacl = /*(576 / saa->win.height - 1) & 0x3f */ 0;
1170 ysci = 1024 - (saa->win.height * 1024 / 576);
1231 static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr)
1236 clipmap = saa->dmavid2;
1237 if ((width = saa->win.width) > 1023)
1239 if ((height = saa->win.height) > 640)
1251 clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ?
1252 (saa->win.swidth - saa->win.x) : width, 0, 1024, 768);
1254 (saa->win.y + height > saa->win.sheight) ?
1255 (saa->win.sheight - saa->win.y) : height, 1024, 768);
1256 if (saa->win.x < 0)
1257 clip_draw_rectangle(clipmap, 0, 0, -saa->win.x, 768);
1258 if (saa->win.y < 0)
1259 clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y);
1265 struct saa7146 *saa = file->private_data;
1272 strcpy(b.name, saa->video_dev.name);
1288 struct video_picture p = saa->picture;
1289 if (saa->win.depth == 8)
1291 if (saa->win.depth == 15)
1293 if (saa->win.depth == 16)
1295 if (saa->win.depth == 24)
1297 if (saa->win.depth == 32)
1311 saa->win.color_fmt = format;
1318 saa->picture = p;
1341 if (saa->win.bpp < 4) {
1347 saa->win.x = vw.x;
1348 saa->win.y = vw.y;
1349 saa->win.width = vw.width;
1350 if (saa->win.width > 768)
1351 saa->win.width = 768;
1352 saa->win.height = vw.height;
1354 if (saa->win.height > 480)
1355 saa->win.height = 480;
1357 if (saa->win.height > 576)
1358 saa->win.height = 576;
1363 saa7146_set_winsize(saa);
1369 if (copy_from_user(saa->dmavid2, vw.clips,
1386 memset(saa->dmavid2, 0, VIDEO_CLIPMAP_SIZE);
1388 make_clip_tab(saa, vcp, vw.clipcount);
1393 if ((saa->cap & 3) && saa->win.vidadr != 0)
1402 vw.x = saa->win.x;
1403 vw.y = saa->win.y;
1404 vw.width = saa->win.width;
1405 vw.height = saa->win.height;
1418 saa->cap &= ~1;
1422 if (saa->win.vidadr == 0 || saa->win.width == 0
1423 || saa->win.height == 0)
1425 saa->cap |= 1;
1434 v.base = (void *)saa->win.vidadr;
1435 v.height = saa->win.sheight;
1436 v.width = saa->win.swidth;
1437 v.depth = saa->win.depth;
1438 v.bytesperline = saa->win.bpl;
1456 saa->win.vidadr = (unsigned long)v.base;
1457 saa->win.sheight = v.height;
1458 saa->win.swidth = v.width;
1459 saa->win.bpp = ((v.depth + 7) & 0x38) / 8;
1460 saa->win.depth = v.depth;
1461 saa->win.bpl = v.bytesperline;
1465 saa->win.bpp, saa->win.bpl));
1466 saa7146_set_winsize(saa);
1478 v = saa->audio_dev;
1496 debiwrite(saa, debNormal,
1499 debiwrite(saa, debNormal,
1502 debiwrite(saa, debNormal,
1507 cs4341_setlevel(saa, 0xff, 0xff);
1509 cs4341_setlevel(saa, 0, 0);
1511 cs4341_setlevel(saa, i, i);
1513 saa->audio_dev = v;
1520 vu.video = saa->video_dev.minor;
1540 set_out_format(saa, pmode.p1);
1543 debiwrite(saa, debNormal, XILINX_CTL0,
1546 set_genlock_offset(saa, pmode.p2);
1549 debiwrite(saa, debNormal,
1551 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
1552 saa->playmode = pmode.mode;
1558 ibm_send_command(saa, IBM_MP2_SINGLE_FRAME,0,0);
1559 if (saa->playmode == pmode.mode) {
1560 debiwrite(saa, debNormal,
1564 saa->playmode = pmode.mode;
1567 ibm_send_command(saa, IBM_MP2_FAST_FORWARD,0,0);
1568 saa->playmode = pmode.mode;
1571 ibm_send_command(saa, IBM_MP2_SLOW_MOTION,
1573 saa->playmode = pmode.mode;
1577 debiwrite(saa, debNormal,
1579 ibm_send_command(saa, IBM_MP2_IMED_NORM_PLAY,
1581 saa->playmode = VID_PLAY_NORMAL;
1584 saa->audhead = saa->audtail = 0;
1585 saa->vidhead = saa->vidtail = 0;
1586 ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,1);
1587 ibm_send_command(saa, IBM_MP2_RESET_AUD_RATE,
1589 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1591 ibm_send_command(saa, IBM_MP2_CHANNEL_SWITCH,
1593 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1595 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
1596 saa->playmode = VID_PLAY_NORMAL;
1599 ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,0);
1600 saa->playmode = pmode.mode;
1603 ibm_send_command(saa, IBM_MP2_SET_STILL_MODE,
1605 saa->playmode = pmode.mode;
1609 saa->boardcfg[1] = 0x13;
1611 saa->boardcfg[1] = 0x23;
1613 saa->boardcfg[1] = 0x43;
1616 debiwrite(saa, debNormal,
1623 saa->boardcfg[5] = pmode.p1;
1624 saa->boardcfg[55] = (pmode.p1 +
1629 saa->boardcfg[4] = pmode.p1;
1630 saa->boardcfg[54] = (pmode.p1 +
1633 set_out_format(saa, CurrentMode);
1635 return do_ibm_reset(saa);
1637 if (saa->endmarktail < saa->endmarkhead) {
1638 if (saa->endmarkhead -
1639 saa->endmarktail < 2)
1641 } else if (saa->endmarkhead <=saa->endmarktail){
1642 if (saa->endmarktail - saa->endmarkhead
1647 saa->endmark[saa->endmarktail] = saa->audtail;
1648 saa->endmarktail++;
1649 if (saa->endmarktail >= MAX_MARKS)
1650 saa->endmarktail = 0;
1664 saa->writemode = mode;
1727 struct saa7146 *saa = file->private_data;
1728 printk(KERN_DEBUG "stradis%d: saa_mmap called\n", saa->nr);
1741 struct saa7146 *saa = file->private_data;
1747 if (saa->writemode == VID_WRITE_MPEG_AUD) {
1748 spin_lock_irqsave(&saa->lock, flags);
1749 if (saa->audhead <= saa->audtail)
1751 (saa->audtail - saa->audhead);
1753 blocksize = saa->audhead - saa->audtail;
1754 spin_unlock_irqrestore(&saa->lock, flags);
1760 interruptible_sleep_on(&saa->audq);
1762 spin_lock_irqsave(&saa->lock, flags);
1763 if (saa->audhead <= saa->audtail) {
1765 (saa->audtail - saa->audhead);
1766 split = 65536 - saa->audtail;
1768 blocksize = saa->audhead - saa->audtail;
1771 spin_unlock_irqrestore(&saa->lock, flags);
1779 if (copy_from_user(saa->audbuf +
1780 saa->audtail, buf, split))
1785 saa->audtail = 0;
1787 if (copy_from_user(saa->audbuf + saa->audtail, buf,
1790 saa->audtail += blocksize;
1793 saa->audtail &= 0xffff;
1794 } else if (saa->writemode == VID_WRITE_MPEG_VID) {
1795 spin_lock_irqsave(&saa->lock, flags);
1796 if (saa->vidhead <= saa->vidtail)
1798 (saa->vidtail - saa->vidhead);
1800 blocksize = saa->vidhead - saa->vidtail;
1801 spin_unlock_irqrestore(&saa->lock, flags);
1807 interruptible_sleep_on(&saa->vidq);
1809 spin_lock_irqsave(&saa->lock, flags);
1810 if (saa->vidhead <= saa->vidtail) {
1812 (saa->vidtail - saa->vidhead);
1813 split = 524288 - saa->vidtail;
1815 blocksize = saa->vidhead - saa->vidtail;
1818 spin_unlock_irqrestore(&saa->lock, flags);
1826 if (copy_from_user(saa->vidbuf +
1827 saa->vidtail, buf, split))
1832 saa->vidtail = 0;
1834 if (copy_from_user(saa->vidbuf + saa->vidtail, buf,
1837 saa->vidtail += blocksize;
1840 saa->vidtail &= 0x7ffff;
1841 } else if (saa->writemode == VID_WRITE_OSD) {
1844 if (copy_from_user(saa->osdbuf, buf, count))
1847 saa->osdhead = 0;
1848 saa->osdtail = count;
1849 debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR, 0, 2);
1850 debiwrite(saa, debNormal, IBM_MP2_OSD_LINK_ADDR, 0, 2);
1851 debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00d, 2);
1852 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
1853 debiread(saa, debNormal,
1867 struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);
1870 file->private_data = saa;
1872 saa->user++;
1873 if (saa->user > 1) {
1877 saa->writemode = VID_WRITE_MPEG_VID; /* default to video */
1884 struct saa7146 *saa = file->private_data;
1885 saa->user--;
1887 if (saa->user > 0) /* still someone using device */
1913 struct saa7146 *saa = pci_get_drvdata(pdev);
1915 saa->endmarkhead = saa->endmarktail = 0;
1916 saa->win.x = saa->win.y = 0;
1917 saa->win.width = saa->win.cropwidth = 720;
1918 saa->win.height = saa->win.cropheight = 480;
1919 saa->win.cropx = saa->win.cropy = 0;
1920 saa->win.bpp = 2;
1921 saa->win.depth = 16;
1922 saa->win.color_fmt = palette2fmt[VIDEO_PALETTE_RGB565];
1923 saa->win.bpl = 1024 * saa->win.bpp;
1924 saa->win.swidth = 1024;
1925 saa->win.sheight = 768;
1926 saa->picture.brightness = 32768;
1927 saa->picture.contrast = 38768;
1928 saa->picture.colour = 32768;
1929 saa->cap = 0;
1930 saa->nr = num;
1931 saa->playmode = VID_PLAY_NORMAL;
1932 memset(saa->boardcfg, 0, 64); /* clear board config area */
1933 saa->saa7146_mem = NULL;
1934 saa->dmavid1 = saa->dmavid2 = saa->dmavid3 = saa->dmaa1in =
1935 saa->dmaa1out = saa->dmaa2in = saa->dmaa2out =
1936 saa->pagevid1 = saa->pagevid2 = saa->pagevid3 = saa->pagea1in =
1937 saa->pagea1out = saa->pagea2in = saa->pagea2out =
1938 saa->pagedebi = saa->dmaRPS1 = saa->dmaRPS2 = saa->pageRPS1 =
1939 saa->pageRPS2 = NULL;
1940 saa->audbuf = saa->vidbuf = saa->osdbuf = saa->dmadebi = NULL;
1941 saa->audhead = saa->vidtail = 0;
1943 init_waitqueue_head(&saa->i2cq);
1944 init_waitqueue_head(&saa->audq);
1945 init_waitqueue_head(&saa->debiq);
1946 init_waitqueue_head(&saa->vidq);
1947 spin_lock_init(&saa->lock);
1955 saa->id = pdev->device;
1956 saa->irq = pdev->irq;
1957 saa->saa7146_adr = pci_resource_start(pdev, 0);
1958 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision);
1960 saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200);
1961 if (saa->saa7146_mem == NULL) {
1967 memcpy(&saa->video_dev, &saa_template, sizeof(saa_template));
1970 retval = request_irq(saa->irq, saa7146_irq, IRQF_SHARED | IRQF_DISABLED,
1971 "stradis", saa);
1976 "in BIOS\n", num, saa->irq);
1981 retval = video_register_device(&saa->video_dev, VFL_TYPE_GRABBER,
1991 iounmap(saa->saa7146_mem);
1998 struct saa7146 *saa = pci_get_drvdata(pdev);
2000 saa->user = 0;
2031 if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) {
2032 dev_err(&pdev->dev, "%d: debi kmalloc failed\n", saa->nr);
2035 saa->audhead = saa->vidhead = saa->osdhead = 0;
2036 saa->audtail = saa->vidtail = saa->osdtail = 0;
2037 if (saa->vidbuf == NULL && (saa->vidbuf = vmalloc(524288)) == NULL) {
2038 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2041 if (saa->audbuf == NULL && (saa->audbuf = vmalloc(65536)) == NULL) {
2042 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2045 if (saa->osdbuf == NULL && (saa->osdbuf = vmalloc(131072)) == NULL) {
2046 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2050 if ((saa->dmavid2 = kzalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) {
2051 dev_err(&pdev->dev, "%d: clip kmalloc failed\n", saa->nr);
2055 saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2);
2056 saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2);
2057 saawrite(virt_to_bus(saa->dmavid2) + VIDEO_CLIPMAP_SIZE,
2063 I2CBusScan(saa);
2067 vfree(saa->osdbuf);
2068 vfree(saa->audbuf);
2069 vfree(saa->vidbuf);
2070 saa->audbuf = saa->osdbuf = saa->vidbuf = NULL;
2078 struct saa7146 *saa = pci_get_drvdata(pdev);
2092 saa->audhead = saa->audtail = saa->osdhead = 0;
2093 saa->vidhead = saa->vidtail = saa->osdtail = 0;
2094 vfree(saa->vidbuf);
2095 vfree(saa->audbuf);
2096 vfree(saa->osdbuf);
2097 kfree(saa->dmavid2);
2098 saa->audbuf = saa->vidbuf = saa->osdbuf = NULL;
2099 saa->dmavid2 = NULL;
2100 kfree(saa->dmadebi);
2101 kfree(saa->dmavid1);
2102 kfree(saa->dmavid3);
2103 kfree(saa->dmaa1in);
2104 kfree(saa->dmaa1out);
2105 kfree(saa->dmaa2in);
2106 kfree(saa->dmaa2out);
2107 kfree(saa->dmaRPS1);
2108 kfree(saa->dmaRPS2);
2109 free_irq(saa->irq, saa);
2110 if (saa->saa7146_mem)
2111 iounmap(saa->saa7146_mem);
2112 if (video_is_registered(&saa->video_dev))
2113 video_unregister_device(&saa->video_dev);