/*
 * stradis.c - stradis 4:2:2 mpeg decoder driver
 *
 * Stradis 4:2:2 MPEG-2 Decoder Driver
 * Copyright (C) 1999 Nathan Laredo <laredo@gnu.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <linux/module.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/pci.h>
#include <linux/signal.h>
#include <asm/io.h>
#include <linux/ioport.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <linux/sched.h>
#include <asm/types.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <asm/uaccess.h>
#include <linux/vmalloc.h>
#include <linux/videodev.h>
#include <media/v4l2-common.h>

#include "saa7146.h"
#include "saa7146reg.h"
#include "ibmmpeg2.h"
#include "saa7121.h"
#include "cs8420.h"

#define DEBUG(x)		/* debug driver */
#undef  IDEBUG			/* debug irq handler */
#undef  MDEBUG			/* debug memory management */

#define SAA7146_MAX 6

static struct saa7146 saa7146s[SAA7146_MAX];

static int saa_num = 0;		/* number of SAA7146s in use */

static int video_nr = -1;
module_param(video_nr, int, 0);
MODULE_LICENSE("GPL");

#define nDebNormal	0x00480000
#define nDebNoInc	0x00480000
#define nDebVideo	0xd0480000
#define nDebAudio	0xd0400000
#define nDebDMA		0x02c80000

#define oDebNormal	0x13c80000
#define oDebNoInc	0x13c80000
#define oDebVideo	0xd1080000
#define oDebAudio	0xd1080000
#define oDebDMA		0x03080000

#define NewCard		(saa->boardcfg[3])
#define ChipControl	(saa->boardcfg[1])
#define NTSCFirstActive	(saa->boardcfg[4])
#define PALFirstActive	(saa->boardcfg[5])
#define NTSCLastActive	(saa->boardcfg[54])
#define PALLastActive	(saa->boardcfg[55])
#define Have2MB		(saa->boardcfg[18] & 0x40)
#define HaveCS8420	(saa->boardcfg[18] & 0x04)
#define IBMMPEGCD20	(saa->boardcfg[18] & 0x20)
#define HaveCS3310	(saa->boardcfg[18] & 0x01)
#define CS3310MaxLvl	((saa->boardcfg[30] << 8) | saa->boardcfg[31])
#define HaveCS4341	(saa->boardcfg[40] == 2)
#define SDIType		(saa->boardcfg[27])
#define CurrentMode	(saa->boardcfg[2])

#define debNormal	(NewCard ? nDebNormal : oDebNormal)
#define debNoInc	(NewCard ? nDebNoInc : oDebNoInc)
#define debVideo	(NewCard ? nDebVideo : oDebVideo)
#define debAudio	(NewCard ? nDebAudio : oDebAudio)
#define debDMA		(NewCard ? nDebDMA : oDebDMA)

#ifdef USE_RESCUE_EEPROM_SDM275
static unsigned char rescue_eeprom[64] = {
	0x00, 0x01, 0x04, 0x13, 0x26, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x43, 0x63,
	0x22, 0x01, 0x29, 0x15, 0x73, 0x00, 0x1f,  'd',  'e',  'c',  'x',  'l',
	 'd',  'v',  'a', 0x02, 0x00, 0x01, 0x00, 0xcc, 0xa4, 0x63, 0x09, 0xe2,
	0x10, 0x00, 0x0a, 0x00, 0x02, 0x02,  'd',  'e',  'c',  'x',  'l',  'a',
	0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,
};
#endif

/* ----------------------------------------------------------------------- */
/* Hardware I2C functions */
static void I2CWipe(struct saa7146 *saa)
{
	int i;
	/* set i2c to ~=100kHz, abort transfer, clear busy */
	saawrite(0x600 | SAA7146_I2C_ABORT, SAA7146_I2C_STATUS);
	saawrite((SAA7146_MC2_UPLD_I2C << 16) |
		 SAA7146_MC2_UPLD_I2C, SAA7146_MC2);
	/* wait for i2c registers to be programmed */
	for (i = 0; i < 1000 &&
	     !(saaread(SAA7146_MC2) & SAA7146_MC2_UPLD_I2C); i++)
		schedule();
	saawrite(0x600, SAA7146_I2C_STATUS);
	saawrite((SAA7146_MC2_UPLD_I2C << 16) |
		 SAA7146_MC2_UPLD_I2C, SAA7146_MC2);
	/* wait for i2c registers to be programmed */
	for (i = 0; i < 1000 &&
	     !(saaread(SAA7146_MC2) & SAA7146_MC2_UPLD_I2C); i++)
		schedule();
	saawrite(0x600, SAA7146_I2C_STATUS);
	saawrite((SAA7146_MC2_UPLD_I2C << 16) |
		 SAA7146_MC2_UPLD_I2C, SAA7146_MC2);
	/* wait for i2c registers to be programmed */
	for (i = 0; i < 1000 &&
	     !(saaread(SAA7146_MC2) & SAA7146_MC2_UPLD_I2C); i++)
		schedule();
}

/* read I2C */
static int I2CRead(struct saa7146 *saa, unsigned char addr,
		   unsigned char subaddr, int dosub)
{
	int i;

	if (saaread(SAA7146_I2C_STATUS) & 0x3c)
		I2CWipe(saa);
	for (i = 0;
		i < 1000 && (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_BUSY);
		i++)
		schedule();
	if (i == 1000)
		I2CWipe(saa);
	if (dosub)
		saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 8) |
			((subaddr & 0xff) << 16) | 0xed, SAA7146_I2C_TRANSFER);
	else
		saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 16) |
			0xf1, SAA7146_I2C_TRANSFER);
	saawrite((SAA7146_MC2_UPLD_I2C << 16) |
		 SAA7146_MC2_UPLD_I2C, SAA7146_MC2);
	/* wait for i2c registers to be programmed */
	for (i = 0; i < 1000 &&
	     !(saaread(SAA7146_MC2) & SAA7146_MC2_UPLD_I2C); i++)
		schedule();
	/* wait for valid data */
	for (i = 0; i < 1000 &&
	     (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_BUSY); i++)
		schedule();
	if (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_ERR)
		return -1;
	if (i == 1000)
		printk("i2c setup read timeout\n");
	saawrite(0x41, SAA7146_I2C_TRANSFER);
	saawrite((SAA7146_MC2_UPLD_I2C << 16) |
		 SAA7146_MC2_UPLD_I2C, SAA7146_MC2);
	/* wait for i2c registers to be programmed */
	for (i = 0; i < 1000 &&
	     !(saaread(SAA7146_MC2) & SAA7146_MC2_UPLD_I2C); i++)
		schedule();
	/* wait for valid data */
	for (i = 0; i < 1000 &&
	     (saaread(SAA7146_I2C_TRANSFER) & SAA7146_I2C_BUSY); i++)
		schedule();
	if (saaread(SAA7146_I2C_TRANSFER) & SAA7146_I2C_ERR)
		return -1;
	if (i == 1000)
		printk("i2c read timeout\n");
	return ((saaread(SAA7146_I2C_TRANSFER) >> 24) & 0xff);
}

/* set both to write both bytes, reset it to write only b1 */

static int I2CWrite(struct saa7146 *saa, unsigned char addr, unsigned char b1,
		    unsigned char b2, int both)
{
	int i;
	u32 data;

	if (saaread(SAA7146_I2C_STATUS) & 0x3c)
		I2CWipe(saa);
	for (i = 0; i < 1000 &&
	     (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_BUSY); i++)
		schedule();
	if (i == 1000)
		I2CWipe(saa);
	data = ((addr & 0xfe) << 24) | ((b1 & 0xff) << 16);
	if (both)
		data |= ((b2 & 0xff) << 8) | 0xe5;
	else
		data |= 0xd1;
	saawrite(data, SAA7146_I2C_TRANSFER);
	saawrite((SAA7146_MC2_UPLD_I2C << 16) | SAA7146_MC2_UPLD_I2C,
		 SAA7146_MC2);
	return 0;
}

static void attach_inform(struct saa7146 *saa, int id)
{
	int i;

	DEBUG(printk(KERN_DEBUG "stradis%d: i2c: device found=%02x\n", saa->nr,
		id));
	if (id == 0xa0) {	/* we have rev2 or later board, fill in info */
		for (i = 0; i < 64; i++)
			saa->boardcfg[i] = I2CRead(saa, 0xa0, i, 1);
#ifdef USE_RESCUE_EEPROM_SDM275
		if (saa->boardcfg[0] != 0) {
			printk("stradis%d: WARNING: EEPROM STORED VALUES HAVE "
				"BEEN IGNORED\n", saa->nr);
			for (i = 0; i < 64; i++)
				saa->boardcfg[i] = rescue_eeprom[i];
		}
#endif
		printk("stradis%d: config =", saa->nr);
		for (i = 0; i < 51; i++) {
			printk(" %02x", saa->boardcfg[i]);
		}
		printk("\n");
	}
}

static void I2CBusScan(struct saa7146 *saa)
{
	int i;
	for (i = 0; i < 0xff; i += 2)
		if ((I2CRead(saa, i, 0, 0)) >= 0)
			attach_inform(saa, i);
}

static int debiwait_maxwait = 0;

static int wait_for_debi_done(struct saa7146 *saa)
{
	int i;

	/* wait for registers to be programmed */
	for (i = 0; i < 100000 &&
	     !(saaread(SAA7146_MC2) & SAA7146_MC2_UPLD_DEBI); i++)
		saaread(SAA7146_MC2);
	/* wait for transfer to complete */
	for (i = 0; i < 500000 &&
	     (saaread(SAA7146_PSR) & SAA7146_PSR_DEBI_S); i++)
		saaread(SAA7146_MC2);

	if (i > debiwait_maxwait)
		printk("wait-for-debi-done maxwait: %d\n",
			debiwait_maxwait = i);

	if (i == 500000)
		return -1;

	return 0;
}

static int debiwrite(struct saa7146 *saa, u32 config, int addr,
	u32 val, int count)
{
	u32 cmd;
	if (count <= 0 || count > 32764)
		return -1;
	if (wait_for_debi_done(saa) < 0)
		return -1;
	saawrite(config, SAA7146_DEBI_CONFIG);
	if (count <= 4)		/* immediate transfer */
		saawrite(val, SAA7146_DEBI_AD);
	else			/* block transfer */
		saawrite(virt_to_bus(saa->dmadebi), SAA7146_DEBI_AD);
	saawrite((cmd = (count << 17) | (addr & 0xffff)), SAA7146_DEBI_COMMAND);
	saawrite((SAA7146_MC2_UPLD_DEBI << 16) | SAA7146_MC2_UPLD_DEBI,
		 SAA7146_MC2);
	return 0;
}

static u32 debiread(struct saa7146 *saa, u32 config, int addr, int count)
{
	u32 result = 0;

	if (count > 32764 || count <= 0)
		return 0;
	if (wait_for_debi_done(saa) < 0)
		return 0;
	saawrite(virt_to_bus(saa->dmadebi), SAA7146_DEBI_AD);
	saawrite((count << 17) | 0x10000 | (addr & 0xffff),
		 SAA7146_DEBI_COMMAND);
	saawrite(config, SAA7146_DEBI_CONFIG);
	saawrite((SAA7146_MC2_UPLD_DEBI << 16) | SAA7146_MC2_UPLD_DEBI,
		 SAA7146_MC2);
	if (count > 4)		/* not an immediate transfer */
		return count;
	wait_for_debi_done(saa);
	result = saaread(SAA7146_DEBI_AD);
	if (count == 1)
		result &= 0xff;
	if (count == 2)
		result &= 0xffff;
	if (count == 3)
		result &= 0xffffff;
	return result;
}

static void do_irq_send_data(struct saa7146 *saa)
{
	int split, audbytes, vidbytes;

	saawrite(SAA7146_PSR_PIN1, SAA7146_IER);
	/* if special feature mode in effect, disable audio sending */
	if (saa->playmode != VID_PLAY_NORMAL)
		saa->audtail = saa->audhead = 0;
	if (saa->audhead <= saa->audtail)
		audbytes = saa->audtail - saa->audhead;
	else
		audbytes = 65536 - (saa->audhead - saa->audtail);
	if (saa->vidhead <= saa->vidtail)
		vidbytes = saa->vidtail - saa->vidhead;
	else
		vidbytes = 524288 - (saa->vidhead - saa->vidtail);
	if (audbytes == 0 && vidbytes == 0 && saa->osdtail == saa->osdhead) {
		saawrite(0, SAA7146_IER);
		return;
	}
	/* if at least 1 block audio waiting and audio fifo isn't full */
	if (audbytes >= 2048 && (debiread(saa, debNormal, IBM_MP2_AUD_FIFO, 2)
			& 0xff) < 60) {
		if (saa->audhead > saa->audtail)
			split = 65536 - saa->audhead;
		else
			split = 0;
		audbytes = 2048;
		if (split > 0 && split < 2048) {
			memcpy(saa->dmadebi, saa->audbuf + saa->audhead, split);
			saa->audhead = 0;
			audbytes -= split;
		} else
			split = 0;
		memcpy(saa->dmadebi + split, saa->audbuf + saa->audhead,
			audbytes);
		saa->audhead += audbytes;
		saa->audhead &= 0xffff;
		debiwrite(saa, debAudio, (NewCard ? IBM_MP2_AUD_FIFO :
			IBM_MP2_AUD_FIFOW), 0, 2048);
		wake_up_interruptible(&saa->audq);
		/* if at least 1 block video waiting and video fifo isn't full */
	} else if (vidbytes >= 30720 && (debiread(saa, debNormal,
						  IBM_MP2_FIFO, 2)) < 16384) {
		if (saa->vidhead > saa->vidtail)
			split = 524288 - saa->vidhead;
		else
			split = 0;
		vidbytes = 30720;
		if (split > 0 && split < 30720) {
			memcpy(saa->dmadebi, saa->vidbuf + saa->vidhead, split);
			saa->vidhead = 0;
			vidbytes -= split;
		} else
			split = 0;
		memcpy(saa->dmadebi + split, saa->vidbuf + saa->vidhead,
			vidbytes);
		saa->vidhead += vidbytes;
		saa->vidhead &= 0x7ffff;
		debiwrite(saa, debVideo, (NewCard ? IBM_MP2_FIFO :
					  IBM_MP2_FIFOW), 0, 30720);
		wake_up_interruptible(&saa->vidq);
	}
	saawrite(SAA7146_PSR_DEBI_S | SAA7146_PSR_PIN1, SAA7146_IER);
}

static void send_osd_data(struct saa7146 *saa)
{
	int size = saa->osdtail - saa->osdhead;
	if (size > 30720)
		size = 30720;
	/* ensure some multiple of 8 bytes is transferred */
	size = 8 * ((size + 8) >> 3);
	if (size) {
		debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR,
			  (saa->osdhead >> 3), 2);
		memcpy(saa->dmadebi, &saa->osdbuf[saa->osdhead], size);
		saa->osdhead += size;
		/* block transfer of next 8 bytes to ~32k bytes */
		debiwrite(saa, debNormal, IBM_MP2_OSD_DATA, 0, size);
	}
	if (saa->osdhead >= saa->osdtail) {
		saa->osdhead = saa->osdtail = 0;
		debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00c, 2);
	}
}

static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs)
{
	struct saa7146 *saa = dev_id;
	u32 stat, astat;
	int count;
	int handled = 0;

	count = 0;
	while (1) {
		/* get/clear interrupt status bits */
		stat = saaread(SAA7146_ISR);
		astat = stat & saaread(SAA7146_IER);
		if (!astat)
			break;
		handled = 1;
		saawrite(astat, SAA7146_ISR);
		if (astat & SAA7146_PSR_DEBI_S) {
			do_irq_send_data(saa);
		}
		if (astat & SAA7146_PSR_PIN1) {
			int istat;
			/* the following read will trigger DEBI_S */
			istat = debiread(saa, debNormal, IBM_MP2_HOST_INT, 2);
			if (istat & 1) {
				saawrite(0, SAA7146_IER);
				send_osd_data(saa);
				saawrite(SAA7146_PSR_DEBI_S |
					 SAA7146_PSR_PIN1, SAA7146_IER);
			}
			if (istat & 0x20) {	/* Video Start */
				saa->vidinfo.frame_count++;
			}
			if (istat & 0x400) {	/* Picture Start */
				/* update temporal reference */
			}
			if (istat & 0x200) {	/* Picture Resolution Change */
				/* read new resolution */
			}
			if (istat & 0x100) {	/* New User Data found */
				/* read new user data */
			}
			if (istat & 0x1000) {	/* new GOP/SMPTE */
				/* read new SMPTE */
			}
			if (istat & 0x8000) {	/* Sequence Start Code */
				/* reset frame counter, load sizes */
				saa->vidinfo.frame_count = 0;
				saa->vidinfo.h_size = 704;
				saa->vidinfo.v_size = 480;
#if 0
				if (saa->endmarkhead != saa->endmarktail) {
					saa->audhead =
						saa->endmark[saa->endmarkhead];
					saa->endmarkhead++;
					if (saa->endmarkhead >= MAX_MARKS)
						saa->endmarkhead = 0;
				}
#endif
			}
			if (istat & 0x4000) {	/* Sequence Error Code */
				if (saa->endmarkhead != saa->endmarktail) {
					saa->audhead =
						saa->endmark[saa->endmarkhead];
					saa->endmarkhead++;
					if (saa->endmarkhead >= MAX_MARKS)
						saa->endmarkhead = 0;
				}
			}
		}
#ifdef IDEBUG
		if (astat & SAA7146_PSR_PPEF) {
			IDEBUG(printk("stradis%d irq: PPEF\n", saa->nr));
		}
		if (astat & SAA7146_PSR_PABO) {
			IDEBUG(printk("stradis%d irq: PABO\n", saa->nr));
		}
		if (astat & SAA7146_PSR_PPED) {
			IDEBUG(printk("stradis%d irq: PPED\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_I1) {
			IDEBUG(printk("stradis%d irq: RPS_I1\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_I0) {
			IDEBUG(printk("stradis%d irq: RPS_I0\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_LATE1) {
			IDEBUG(printk("stradis%d irq: RPS_LATE1\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_LATE0) {
			IDEBUG(printk("stradis%d irq: RPS_LATE0\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_E1) {
			IDEBUG(printk("stradis%d irq: RPS_E1\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_E0) {
			IDEBUG(printk("stradis%d irq: RPS_E0\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_TO1) {
			IDEBUG(printk("stradis%d irq: RPS_TO1\n", saa->nr));
		}
		if (astat & SAA7146_PSR_RPS_TO0) {
			IDEBUG(printk("stradis%d irq: RPS_TO0\n", saa->nr));
		}
		if (astat & SAA7146_PSR_UPLD) {
			IDEBUG(printk("stradis%d irq: UPLD\n", saa->nr));
		}
		if (astat & SAA7146_PSR_DEBI_E) {
			IDEBUG(printk("stradis%d irq: DEBI_E\n", saa->nr));
		}
		if (astat & SAA7146_PSR_I2C_S) {
			IDEBUG(printk("stradis%d irq: I2C_S\n", saa->nr));
		}
		if (astat & SAA7146_PSR_I2C_E) {
			IDEBUG(printk("stradis%d irq: I2C_E\n", saa->nr));
		}
		if (astat & SAA7146_PSR_A2_IN) {
			IDEBUG(printk("stradis%d irq: A2_IN\n", saa->nr));
		}
		if (astat & SAA7146_PSR_A2_OUT) {
			IDEBUG(printk("stradis%d irq: A2_OUT\n", saa->nr));
		}
		if (astat & SAA7146_PSR_A1_IN) {
			IDEBUG(printk("stradis%d irq: A1_IN\n", saa->nr));
		}
		if (astat & SAA7146_PSR_A1_OUT) {
			IDEBUG(printk("stradis%d irq: A1_OUT\n", saa->nr));
		}
		if (astat & SAA7146_PSR_AFOU) {
			IDEBUG(printk("stradis%d irq: AFOU\n", saa->nr));
		}
		if (astat & SAA7146_PSR_V_PE) {
			IDEBUG(printk("stradis%d irq: V_PE\n", saa->nr));
		}
		if (astat & SAA7146_PSR_VFOU) {
			IDEBUG(printk("stradis%d irq: VFOU\n", saa->nr));
		}
		if (astat & SAA7146_PSR_FIDA) {
			IDEBUG(printk("stradis%d irq: FIDA\n", saa->nr));
		}
		if (astat & SAA7146_PSR_FIDB) {
			IDEBUG(printk("stradis%d irq: FIDB\n", saa->nr));
		}
		if (astat & SAA7146_PSR_PIN3) {
			IDEBUG(printk("stradis%d irq: PIN3\n", saa->nr));
		}
		if (astat & SAA7146_PSR_PIN2) {
			IDEBUG(printk("stradis%d irq: PIN2\n", saa->nr));
		}
		if (astat & SAA7146_PSR_PIN0) {
			IDEBUG(printk("stradis%d irq: PIN0\n", saa->nr));
		}
		if (astat & SAA7146_PSR_ECS) {
			IDEBUG(printk("stradis%d irq: ECS\n", saa->nr));
		}
		if (astat & SAA7146_PSR_EC3S) {
			IDEBUG(printk("stradis%d irq: EC3S\n", saa->nr));
		}
		if (astat & SAA7146_PSR_EC0S) {
			IDEBUG(printk("stradis%d irq: EC0S\n", saa->nr));
		}
#endif
		count++;
		if (count > 15)
			printk(KERN_WARNING "stradis%d: irq loop %d\n",
			       saa->nr, count);
		if (count > 20) {
			saawrite(0, SAA7146_IER);
			printk(KERN_ERR
			       "stradis%d: IRQ loop cleared\n", saa->nr);
		}
	}
	return IRQ_RETVAL(handled);
}

static int ibm_send_command(struct saa7146 *saa,
			    int command, int data, int chain)
{
	int i;

	if (chain)
		debiwrite(saa, debNormal, IBM_MP2_COMMAND, (command << 1)| 1,2);
	else
		debiwrite(saa, debNormal, IBM_MP2_COMMAND, command << 1, 2);
	debiwrite(saa, debNormal, IBM_MP2_CMD_DATA, data, 2);
	debiwrite(saa, debNormal, IBM_MP2_CMD_STAT, 1, 2);
	for (i = 0; i < 100 &&
	     (debiread(saa, debNormal, IBM_MP2_CMD_STAT, 2) & 1); i++)
		schedule();
	if (i == 100)
		return -1;
	return 0;
}

static void cs4341_setlevel(struct saa7146 *saa, int left, int right)
{
	I2CWrite(saa, 0x22, 0x03, left > 94 ? 94 : left, 2);
	I2CWrite(saa, 0x22, 0x04, right > 94 ? 94 : right, 2);
}

static void initialize_cs4341(struct saa7146 *saa)
{
	int i;
	for (i = 0; i < 200; i++) {
		/* auto mute off, power on, no de-emphasis */
		/* I2S data up to 24-bit 64xFs internal SCLK */
		I2CWrite(saa, 0x22, 0x01, 0x11, 2);
		/* ATAPI mixer settings */
		I2CWrite(saa, 0x22, 0x02, 0x49, 2);
		/* attenuation left 3db */
		I2CWrite(saa, 0x22, 0x03, 0x00, 2);
		/* attenuation right 3db */
		I2CWrite(saa, 0x22, 0x04, 0x00, 2);
		I2CWrite(saa, 0x22, 0x01, 0x10, 2);
		if (I2CRead(saa, 0x22, 0x02, 1) == 0x49)
			break;
		schedule();
	}
	printk("stradis%d: CS4341 initialized (%d)\n", saa->nr, i);
	return;
}

static void initialize_cs8420(struct saa7146 *saa, int pro)
{
	int i;
	u8 *sequence;
	if (pro)
		sequence = mode8420pro;
	else
		sequence = mode8420con;
	for (i = 0; i < INIT8420LEN; i++)
		I2CWrite(saa, 0x20, init8420[i * 2], init8420[i * 2 + 1], 2);
	for (i = 0; i < MODE8420LEN; i++)
		I2CWrite(saa, 0x20, sequence[i * 2], sequence[i * 2 + 1], 2);
	printk("stradis%d: CS8420 initialized\n", saa->nr);
}

static void initialize_saa7121(struct saa7146 *saa, int dopal)
{
	int i, mod;
	u8 *sequence;
	if (dopal)
		sequence = init7121pal;
	else
		sequence = init7121ntsc;
	mod = saaread(SAA7146_PSR) & 0x08;
	/* initialize PAL/NTSC video encoder */
	for (i = 0; i < INIT7121LEN; i++) {
		if (NewCard) {	/* handle new card encoder differences */
			if (sequence[i * 2] == 0x3a)
				I2CWrite(saa, 0x88, 0x3a, 0x13, 2);
			else if (sequence[i * 2] == 0x6b)
				I2CWrite(saa, 0x88, 0x6b, 0x20, 2);
			else if (sequence[i * 2] == 0x6c)
				I2CWrite(saa, 0x88, 0x6c,
					 dopal ? 0x09 : 0xf5, 2);
			else if (sequence[i * 2] == 0x6d)
				I2CWrite(saa, 0x88, 0x6d,
					 dopal ? 0x20 : 0x00, 2);
			else if (sequence[i * 2] == 0x7a)
				I2CWrite(saa, 0x88, 0x7a,
					 dopal ? (PALFirstActive - 1) :
					 (NTSCFirstActive - 4), 2);
			else if (sequence[i * 2] == 0x7b)
				I2CWrite(saa, 0x88, 0x7b,
					 dopal ? PALLastActive :
					 NTSCLastActive, 2);
			else
				I2CWrite(saa, 0x88, sequence[i * 2],
					 sequence[i * 2 + 1], 2);
		} else {
			if (sequence[i * 2] == 0x6b && mod)
				I2CWrite(saa, 0x88, 0x6b,
					 (sequence[i * 2 + 1] ^ 0x09), 2);
			else if (sequence[i * 2] == 0x7a)
				I2CWrite(saa, 0x88, 0x7a,
					 dopal ? (PALFirstActive - 1) :
					 (NTSCFirstActive - 4), 2);
			else if (sequence[i * 2] == 0x7b)
				I2CWrite(saa, 0x88, 0x7b,
					 dopal ? PALLastActive :
					 NTSCLastActive, 2);
			else
				I2CWrite(saa, 0x88, sequence[i * 2],
					 sequence[i * 2 + 1], 2);
		}
	}
}

static void set_genlock_offset(struct saa7146 *saa, int noffset)
{
	int nCode;
	int PixelsPerLine = 858;
	if (CurrentMode == VIDEO_MODE_PAL)
		PixelsPerLine = 864;
	if (noffset > 500)
		noffset = 500;
	else if (noffset < -500)
		noffset = -500;
	nCode = noffset + 0x100;
	if (nCode == 1)
		nCode = 0x401;
	else if (nCode < 1)
		nCode = 0x400 + PixelsPerLine + nCode;
	debiwrite(saa, debNormal, XILINX_GLDELAY, nCode, 2);
}

static void set_out_format(struct saa7146 *saa, int mode)
{
	initialize_saa7121(saa, (mode == VIDEO_MODE_NTSC ? 0 : 1));
	saa->boardcfg[2] = mode;
	/* do not adjust analog video parameters here, use saa7121 init */
	/* you will affect the SDI output on the new card */
	if (mode == VIDEO_MODE_PAL) {	/* PAL */
		debiwrite(saa, debNormal, XILINX_CTL0, 0x0808, 2);
		mdelay(50);
		saawrite(0x012002c0, SAA7146_NUM_LINE_BYTE1);
		if (NewCard) {
			debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 0xe100, 2);
			mdelay(50);
		}
		debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
			  NewCard ? 0xe500 : 0x6500, 2);
		debiwrite(saa, debNormal, IBM_MP2_DISP_DLY,
			  (1 << 8) |
			  (NewCard ? PALFirstActive : PALFirstActive - 6), 2);
	} else {		/* NTSC */
		debiwrite(saa, debNormal, XILINX_CTL0, 0x0800, 2);
		mdelay(50);
		saawrite(0x00f002c0, SAA7146_NUM_LINE_BYTE1);
		debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
			  NewCard ? 0xe100 : 0x6100, 2);
		debiwrite(saa, debNormal, IBM_MP2_DISP_DLY,
			  (1 << 8) |
			  (NewCard ? NTSCFirstActive : NTSCFirstActive - 6), 2);
	}
}

/* Intialize bitmangler to map from a byte value to the mangled word that
 * must be output to program the Xilinx part through the DEBI port.
 * Xilinx Data Bit->DEBI Bit: 0->15 1->7 2->6 3->12 4->11 5->2 6->1 7->0
 * transfer FPGA code, init IBM chip, transfer IBM microcode
 * rev2 card mangles: 0->7 1->6 2->5 3->4 4->3 5->2 6->1 7->0
 */
static u16 bitmangler[256];

static int initialize_fpga(struct video_code *bitdata)
{
	int i, num, startindex, failure = 0, loadtwo, loadfile = 0;
	u16 *dmabuf;
	u8 *newdma;
	struct saa7146 *saa;

	/* verify fpga code */
	for (startindex = 0; startindex < bitdata->datasize; startindex++)
		if (bitdata->data[startindex] == 255)
			break;
	if (startindex == bitdata->datasize) {
		printk(KERN_INFO "stradis: bad fpga code\n");
		return -1;
	}
	/* initialize all detected cards */
	for (num = 0; num < saa_num; num++) {
		saa = &saa7146s[num];
		if (saa->boardcfg[0] > 20)
			continue;	/* card was programmed */
		loadtwo = (saa->boardcfg[18] & 0x10);
		if (!NewCard)	/* we have an old board */
			for (i = 0; i < 256; i++)
				bitmangler[i] = ((i & 0x01) << 15) |
					((i & 0x02) << 6) | ((i & 0x04) << 4) |
					((i & 0x08) << 9) | ((i & 0x10) << 7) |
					((i & 0x20) >> 3) | ((i & 0x40) >> 5) |
					((i & 0x80) >> 7);
		else		/* else we have a new board */
			for (i = 0; i < 256; i++)
				bitmangler[i] = ((i & 0x01) << 7) |
					((i & 0x02) << 5) | ((i & 0x04) << 3) |
					((i & 0x08) << 1) | ((i & 0x10) >> 1) |
					((i & 0x20) >> 3) | ((i & 0x40) >> 5) |
					((i & 0x80) >> 7);

		dmabuf = (u16 *) saa->dmadebi;
		newdma = (u8 *) saa->dmadebi;
		if (NewCard) {	/* SDM2xxx */
			if (!strncmp(bitdata->loadwhat, "decoder2", 8))
				continue;	/* fpga not for this card */
			if (!strncmp(&saa->boardcfg[42], bitdata->loadwhat, 8))
				loadfile = 1;
			else if (loadtwo && !strncmp(&saa->boardcfg[19],
				       bitdata->loadwhat, 8))
				loadfile = 2;
			else if (!saa->boardcfg[42] && !strncmp("decxl",
					bitdata->loadwhat, 8))
				loadfile = 1;	/* special */
			else
				continue;	/* fpga not for this card */
			if (loadfile != 1 && loadfile != 2)
				continue;	/* skip to next card */
			if (saa->boardcfg[0] && loadfile == 1)
				continue;	/* skip to next card */
			if (saa->boardcfg[0] != 1 && loadfile == 2)
				continue;	/* skip to next card */
			saa->boardcfg[0]++;	/* mark fpga handled */
			printk("stradis%d: loading %s\n", saa->nr,
				bitdata->loadwhat);
			if (loadtwo && loadfile == 2)
				goto send_fpga_stuff;
			/* turn on the Audio interface to set PROG low */
			saawrite(0x00400040, SAA7146_GPIO_CTRL);
			saaread(SAA7146_PSR);	/* ensure posted write */
			/* wait for everyone to reset */
			mdelay(10);
			saawrite(0x00400000, SAA7146_GPIO_CTRL);
		} else {	/* original card */
			if (strncmp(bitdata->loadwhat, "decoder2", 8))
				continue;	/* fpga not for this card */
			/* Pull the Xilinx PROG signal WS3 low */
			saawrite(0x02000200, SAA7146_MC1);
			/* Turn on the Audio interface so can set PROG low */
			saawrite(0x000000c0, SAA7146_ACON1);
			/* Pull the Xilinx INIT signal (GPIO2) low */
			saawrite(0x00400000, SAA7146_GPIO_CTRL);
			/* Make sure everybody resets */
			saaread(SAA7146_PSR);	/* ensure posted write */
			mdelay(10);
			/* Release the Xilinx PROG signal */
			saawrite(0x00000000, SAA7146_ACON1);
			/* Turn off the Audio interface */
			saawrite(0x02000000, SAA7146_MC1);
		}
		/* Release Xilinx INIT signal (WS2) */
		saawrite(0x00000000, SAA7146_GPIO_CTRL);
		/* Wait for the INIT to go High */
		for (i = 0;
			i < 10000 && !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2);
			i++)
			schedule();
		if (i == 1000) {
			printk(KERN_INFO "stradis%d: no fpga INIT\n", saa->nr);
			return -1;
		}
send_fpga_stuff:
		if (NewCard) {
			for (i = startindex; i < bitdata->datasize; i++)
				newdma[i - startindex] =
				    bitmangler[bitdata->data[i]];
			debiwrite(saa, 0x01420000, 0, 0,
				((bitdata->datasize - startindex) + 5));
			if (loadtwo && loadfile == 1) {
				printk("stradis%d: awaiting 2nd FPGA bitfile\n",
				       saa->nr);
				continue;	/* skip to next card */
			}
		} else {
			for (i = startindex; i < bitdata->datasize; i++)
				dmabuf[i - startindex] =
					bitmangler[bitdata->data[i]];
			debiwrite(saa, 0x014a0000, 0, 0,
				((bitdata->datasize - startindex) + 5) * 2);
		}
		for (i = 0;
			i < 1000 && !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2);
			i++)
			schedule();
		if (i == 1000) {
			printk(KERN_INFO "stradis%d: FPGA load failed\n",
			       saa->nr);
			failure++;
			continue;
		}
		if (!NewCard) {
			/* Pull the Xilinx INIT signal (GPIO2) low */
			saawrite(0x00400000, SAA7146_GPIO_CTRL);
			saaread(SAA7146_PSR);	/* ensure posted write */
			mdelay(2);
			saawrite(0x00000000, SAA7146_GPIO_CTRL);
			mdelay(2);
		}
		printk(KERN_INFO "stradis%d: FPGA Loaded\n", saa->nr);
		saa->boardcfg[0] = 26;	/* mark fpga programmed */
		/* set VXCO to its lowest frequency */
		debiwrite(saa, debNormal, XILINX_PWM, 0, 2);
		if (NewCard) {
			/* mute CS3310 */
			if (HaveCS3310)
				debiwrite(saa, debNormal, XILINX_CS3310_CMPLT,
					0, 2);
			/* set VXCO to PWM mode, release reset, blank on */
			debiwrite(saa, debNormal, XILINX_CTL0, 0xffc4, 2);
			mdelay(10);
			/* unmute CS3310 */
			if (HaveCS3310)
				debiwrite(saa, debNormal, XILINX_CTL0,
					0x2020, 2);
		}
		/* set source Black */
		debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2);
		saa->boardcfg[4] = 22;	/* set NTSC First Active Line */
		saa->boardcfg[5] = 23;	/* set PAL First Active Line */
		saa->boardcfg[54] = 2;	/* set NTSC Last Active Line - 256 */
		saa->boardcfg[55] = 54;	/* set PAL Last Active Line - 256 */
		set_out_format(saa, VIDEO_MODE_NTSC);
		mdelay(50);
		/* begin IBM chip init */
		debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 4, 2);
		saaread(SAA7146_PSR);	/* wait for reset */
		mdelay(5);
		debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 0, 2);
		debiread(saa, debNormal, IBM_MP2_CHIP_CONTROL, 2);
		debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 0x10, 2);
		debiwrite(saa, debNormal, IBM_MP2_CMD_ADDR, 0, 2);
		debiwrite(saa, debNormal, IBM_MP2_CHIP_MODE, 0x2e, 2);
		if (NewCard) {
			mdelay(5);
			/* set i2s rate converter to 48KHz */
			debiwrite(saa, debNormal, 0x80c0, 6, 2);
			/* we must init CS8420 first since rev b pulls i2s */
			/* master clock low and CS4341 needs i2s master to */
			/* run the i2c port. */
			if (HaveCS8420)
				/* 0=consumer, 1=pro */
				initialize_cs8420(saa, 0);

			mdelay(5);
			if (HaveCS4341)
				initialize_cs4341(saa);
		}
		debiwrite(saa, debNormal, IBM_MP2_INFC_CTL, 0x48, 2);
		debiwrite(saa, debNormal, IBM_MP2_BEEP_CTL, 0xa000, 2);
		debiwrite(saa, debNormal, IBM_MP2_DISP_LBOR, 0, 2);
		debiwrite(saa, debNormal, IBM_MP2_DISP_TBOR, 0, 2);
		if (NewCard)
			set_genlock_offset(saa, 0);
		debiwrite(saa, debNormal, IBM_MP2_FRNT_ATTEN, 0, 2);
#if 0
		/* enable genlock */
		debiwrite(saa, debNormal, XILINX_CTL0, 0x8000, 2);
#else
		/* disable genlock */
		debiwrite(saa, debNormal, XILINX_CTL0, 0x8080, 2);
#endif
	}

	return failure;
}

static int do_ibm_reset(struct saa7146 *saa)
{
	/* failure if decoder not previously programmed */
	if (saa->boardcfg[0] < 37)
		return -EIO;
	/* mute CS3310 */
	if (HaveCS3310)
		debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, 0, 2);
	/* disable interrupts */
	saawrite(0, SAA7146_IER);
	saa->audhead = saa->audtail = 0;
	saa->vidhead = saa->vidtail = 0;
	/* tristate debi bus, disable debi transfers */
	saawrite(0x00880000, SAA7146_MC1);
	/* ensure posted write */
	saaread(SAA7146_MC1);
	mdelay(50);
	/* re-enable debi transfers */
	saawrite(0x00880088, SAA7146_MC1);
	/* set source Black */
	debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2);
	/* begin IBM chip init */
	set_out_format(saa, CurrentMode);
	debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 4, 2);
	saaread(SAA7146_PSR);	/* wait for reset */
	mdelay(5);
	debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 0, 2);
	debiread(saa, debNormal, IBM_MP2_CHIP_CONTROL, 2);
	debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2);
	debiwrite(saa, debNormal, IBM_MP2_CHIP_MODE, 0x2e, 2);
	if (NewCard) {
		mdelay(5);
		/* set i2s rate converter to 48KHz */
		debiwrite(saa, debNormal, 0x80c0, 6, 2);
		/* we must init CS8420 first since rev b pulls i2s */
		/* master clock low and CS4341 needs i2s master to */
		/* run the i2c port. */
		if (HaveCS8420)
			/* 0=consumer, 1=pro */
			initialize_cs8420(saa, 1);

		mdelay(5);
		if (HaveCS4341)
			initialize_cs4341(saa);
	}
	debiwrite(saa, debNormal, IBM_MP2_INFC_CTL, 0x48, 2);
	debiwrite(saa, debNormal, IBM_MP2_BEEP_CTL, 0xa000, 2);
	debiwrite(saa, debNormal, IBM_MP2_DISP_LBOR, 0, 2);
	debiwrite(saa, debNormal, IBM_MP2_DISP_TBOR, 0, 2);
	if (NewCard)
		set_genlock_offset(saa, 0);
	debiwrite(saa, debNormal, IBM_MP2_FRNT_ATTEN, 0, 2);
	debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2);
	debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2);
	if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER,
			(ChipControl == 0x43 ? 0xe800 : 0xe000), 1)) {
		printk(KERN_ERR "stradis%d: IBM config failed\n", saa->nr);
	}
	if (HaveCS3310) {
		int i = CS3310MaxLvl;
		debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, ((i << 8)| i),2);
	}
	/* start video decoder */
	debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2);
	/* 256k vid, 3520 bytes aud */
	debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, 0x4037, 2);
	debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2);
	ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
	/* enable buffer threshold irq */
	debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00c, 2);
	/* clear pending interrupts */
	debiread(saa, debNormal, IBM_MP2_HOST_INT, 2);
	debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2);

	return 0;
}

/* load the decoder microcode */
static int initialize_ibmmpeg2(struct video_code *microcode)
{
	int i, num;
	struct saa7146 *saa;

	for (num = 0; num < saa_num; num++) {
		saa = &saa7146s[num];
		/* check that FPGA is loaded */
		debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0xa55a, 2);
		i = debiread(saa, debNormal, IBM_MP2_OSD_SIZE, 2);
		if (i != 0xa55a) {
			printk(KERN_INFO "stradis%d: %04x != 0xa55a\n",
				saa->nr, i);
#if 0
			return -1;
#endif
		}
		if (!strncmp(microcode->loadwhat, "decoder.vid", 11)) {
			if (saa->boardcfg[0] > 27)
				continue;	/* skip to next card */
			/* load video control store */
			saa->boardcfg[1] = 0x13;	/* no-sync default */
			debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2);
			debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2);
			for (i = 0; i < microcode->datasize / 2; i++)
				debiwrite(saa, debNormal, IBM_MP2_PROC_IDATA,
					(microcode->data[i * 2] << 8) |
					microcode->data[i * 2 + 1], 2);
			debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2);
			debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2);
			debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
				ChipControl, 2);
			saa->boardcfg[0] = 28;
		}
		if (!strncmp(microcode->loadwhat, "decoder.aud", 11)) {
			if (saa->boardcfg[0] > 35)
				continue;	/* skip to next card */
			/* load audio control store */
			debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2);
			debiwrite(saa, debNormal, IBM_MP2_AUD_IADDR, 0, 2);
			for (i = 0; i < microcode->datasize; i++)
				debiwrite(saa, debNormal, IBM_MP2_AUD_IDATA,
					microcode->data[i], 1);
			debiwrite(saa, debNormal, IBM_MP2_AUD_IADDR, 0, 2);
			debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2);
			debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2);
			debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2);
			if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER,
					0xe000, 1)) {
				printk(KERN_ERR "stradis%d: IBM config "
					"failed\n", saa->nr);
				return -1;
			}
			/* set PWM to center value */
			if (NewCard) {
				debiwrite(saa, debNormal, XILINX_PWM,
					saa->boardcfg[14] +
					(saa->boardcfg[13] << 8), 2);
			} else
				debiwrite(saa, debNormal, XILINX_PWM, 0x46, 2);

			if (HaveCS3310) {
				i = CS3310MaxLvl;
				debiwrite(saa, debNormal, XILINX_CS3310_CMPLT,
					(i << 8) | i, 2);
			}
			printk(KERN_INFO "stradis%d: IBM MPEGCD%d Inited\n",
				saa->nr, 18 + (debiread(saa, debNormal,
				IBM_MP2_CHIP_CONTROL, 2) >> 12));
			/* start video decoder */
			debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
				ChipControl, 2);
			debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, 0x4037,
				2);	/* 256k vid, 3520 bytes aud */
			debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2);
			ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
			/* enable buffer threshold irq */
			debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00c, 2);
			debiread(saa, debNormal, IBM_MP2_HOST_INT, 2);
			/* enable gpio irq */
			saawrite(0x00002000, SAA7146_GPIO_CTRL);
			/* enable decoder output to HPS */
			debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2);
			saa->boardcfg[0] = 37;
		}
	}

	return 0;
}

static u32 palette2fmt[] = {	/* some of these YUV translations are wrong */
	0xffffffff, 0x86000000, 0x87000000, 0x80000000, 0x8100000, 0x82000000,
	0x83000000, 0x00000000, 0x03000000, 0x03000000, 0x0a00000, 0x03000000,
	0x06000000, 0x00000000, 0x03000000, 0x0a000000, 0x0300000
};
static int bpp2fmt[4] = {
	VIDEO_PALETTE_HI240, VIDEO_PALETTE_RGB565, VIDEO_PALETTE_RGB24,
	VIDEO_PALETTE_RGB32
};

/* I wish I could find a formula to calculate these... */
static u32 h_prescale[64] = {
	0x10000000, 0x18040202, 0x18080000, 0x380c0606, 0x38100204, 0x38140808,
	0x38180000, 0x381c0000, 0x3820161c, 0x38242a3b, 0x38281230, 0x382c4460,
	0x38301040, 0x38340080, 0x38380000, 0x383c0000, 0x3840fefe, 0x3844ee9f,
	0x3848ee9f, 0x384cee9f, 0x3850ee9f, 0x38542a3b, 0x38581230, 0x385c0000,
	0x38600000, 0x38640000, 0x38680000, 0x386c0000, 0x38700000, 0x38740000,
	0x38780000, 0x387c0000, 0x30800000, 0x38840000, 0x38880000, 0x388c0000,
	0x38900000, 0x38940000, 0x38980000, 0x389c0000, 0x38a00000, 0x38a40000,
	0x38a80000, 0x38ac0000, 0x38b00000, 0x38b40000, 0x38b80000, 0x38bc0000,
	0x38c00000, 0x38c40000, 0x38c80000, 0x38cc0000, 0x38d00000, 0x38d40000,
	0x38d80000, 0x38dc0000, 0x38e00000, 0x38e40000, 0x38e80000, 0x38ec0000,
	0x38f00000, 0x38f40000, 0x38f80000, 0x38fc0000,
};
static u32 v_gain[64] = {
	0x016000ff, 0x016100ff, 0x016100ff, 0x016200ff, 0x016200ff, 0x016200ff,
	0x016200ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff,
	0x016300ff, 0x016300ff, 0x016300ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
	0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
};

static void saa7146_set_winsize(struct saa7146 *saa)
{
	u32 format;
	int offset, yacl, ysci;
	saa->win.color_fmt = format =
	    (saa->win.depth == 15) ? palette2fmt[VIDEO_PALETTE_RGB555] :
	    palette2fmt[bpp2fmt[(saa->win.bpp - 1) & 3]];
	offset = saa->win.x * saa->win.bpp + saa->win.y * saa->win.bpl;
	saawrite(saa->win.vidadr + offset, SAA7146_BASE_EVEN1);
	saawrite(saa->win.vidadr + offset + saa->win.bpl, SAA7146_BASE_ODD1);
	saawrite(saa->win.bpl * 2, SAA7146_PITCH1);
	saawrite(saa->win.vidadr + saa->win.bpl * saa->win.sheight,
		 SAA7146_PROT_ADDR1);
	saawrite(0, SAA7146_PAGE1);
	saawrite(format | 0x60, SAA7146_CLIP_FORMAT_CTRL);
	offset = (704 / (saa->win.width - 1)) & 0x3f;
	saawrite(h_prescale[offset], SAA7146_HPS_H_PRESCALE);
	offset = (720896 / saa->win.width) / (offset + 1);
	saawrite((offset << 12) | 0x0c, SAA7146_HPS_H_SCALE);
	if (CurrentMode == VIDEO_MODE_NTSC) {
		yacl = /*(480 / saa->win.height - 1) & 0x3f */ 0;
		ysci = 1024 - (saa->win.height * 1024 / 480);
	} else {
		yacl = /*(576 / saa->win.height - 1) & 0x3f */ 0;
		ysci = 1024 - (saa->win.height * 1024 / 576);
	}
	saawrite((1 << 31) | (ysci << 21) | (yacl << 15), SAA7146_HPS_V_SCALE);
	saawrite(v_gain[yacl], SAA7146_HPS_V_GAIN);
	saawrite(((SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_HPS_V |
		SAA7146_MC2_UPLD_HPS_H) << 16) | (SAA7146_MC2_UPLD_DMA1 |
		SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_HPS_H), SAA7146_MC2);
}

/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area
 * bitmap is fixed width, 128 bytes (1024 pixels represented)
 * arranged most-sigificant-bit-left in 32-bit words
 * based on saa7146 clipping hardware, it swaps bytes if LE
 * much of this makes up for egcs brain damage -- so if you
 * are wondering "why did he do this?" it is because the C
 * was adjusted to generate the optimal asm output without
 * writing non-portable __asm__ directives.
 */

static void clip_draw_rectangle(u32 *clipmap, int x, int y, int w, int h)
{
	register int startword, endword;
	register u32 bitsleft, bitsright;
	u32 *temp;
	if (x < 0) {
		w += x;
		x = 0;
	}
	if (y < 0) {
		h += y;
		y = 0;
	}
	if (w <= 0 || h <= 0 || x > 1023 || y > 639)
		return;		/* throw away bad clips */
	if (x + w > 1024)
		w = 1024 - x;
	if (y + h > 640)
		h = 640 - y;
	startword = (x >> 5);
	endword = ((x + w) >> 5);
	bitsleft = (0xffffffff >> (x & 31));
	bitsright = (0xffffffff << (~((x + w) - (endword << 5))));
	temp = &clipmap[(y << 5) + startword];
	w = endword - startword;
	if (!w) {
		bitsleft |= bitsright;
		for (y = 0; y < h; y++) {
			*temp |= bitsleft;
			temp += 32;
		}
	} else {
		for (y = 0; y < h; y++) {
			*temp++ |= bitsleft;
			for (x = 1; x < w; x++)
				*temp++ = 0xffffffff;
			*temp |= bitsright;
			temp += (32 - w);
		}
	}
}

static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr)
{
	int i, width, height;
	u32 *clipmap;

	clipmap = saa->dmavid2;
	if ((width = saa->win.width) > 1023)
		width = 1023;	/* sanity check */
	if ((height = saa->win.height) > 640)
		height = 639;	/* sanity check */
	if (ncr > 0) {		/* rectangles pased */
		/* convert rectangular clips to a bitmap */
		memset(clipmap, 0, VIDEO_CLIPMAP_SIZE);	/* clear map */
		for (i = 0; i < ncr; i++)
			clip_draw_rectangle(clipmap, cr[i].x, cr[i].y,
				cr[i].width, cr[i].height);
	}
	/* clip against viewing window AND screen
	   so we do not have to rely on the user program
	 */
	clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ?
		(saa->win.swidth - saa->win.x) : width, 0, 1024, 768);
	clip_draw_rectangle(clipmap, 0,
		(saa->win.y + height > saa->win.sheight) ?
		(saa->win.sheight - saa->win.y) : height, 1024, 768);
	if (saa->win.x < 0)
		clip_draw_rectangle(clipmap, 0, 0, -saa->win.x, 768);
	if (saa->win.y < 0)
		clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y);
}

static int saa_ioctl(struct inode *inode, struct file *file,
		     unsigned int cmd, unsigned long argl)
{
	struct saa7146 *saa = file->private_data;
	void __user *arg = (void __user *)argl;

	switch (cmd) {
	case VIDIOCGCAP:
		{
			struct video_capability b;
			strcpy(b.name, saa->video_dev.name);
			b.type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY |
				VID_TYPE_CLIPPING | VID_TYPE_FRAMERAM |
				VID_TYPE_SCALES;
			b.channels = 1;
			b.audios = 1;
			b.maxwidth = 768;
			b.maxheight = 576;
			b.minwidth = 32;
			b.minheight = 32;
			if (copy_to_user(arg, &b, sizeof(b)))
				return -EFAULT;
			return 0;
		}
	case VIDIOCGPICT:
		{
			struct video_picture p = saa->picture;
			if (saa->win.depth == 8)
				p.palette = VIDEO_PALETTE_HI240;
			if (saa->win.depth == 15)
				p.palette = VIDEO_PALETTE_RGB555;
			if (saa->win.depth == 16)
				p.palette = VIDEO_PALETTE_RGB565;
			if (saa->win.depth == 24)
				p.palette = VIDEO_PALETTE_RGB24;
			if (saa->win.depth == 32)
				p.palette = VIDEO_PALETTE_RGB32;
			if (copy_to_user(arg, &p, sizeof(p)))
				return -EFAULT;
			return 0;
		}
	case VIDIOCSPICT:
		{
			struct video_picture p;
			u32 format;
			if (copy_from_user(&p, arg, sizeof(p)))
				return -EFAULT;
			if (p.palette < sizeof(palette2fmt) / sizeof(u32)) {
				format = palette2fmt[p.palette];
				saa->win.color_fmt = format;
				saawrite(format | 0x60,
					SAA7146_CLIP_FORMAT_CTRL);
			}
			saawrite(((p.brightness & 0xff00) << 16) |
				((p.contrast & 0xfe00) << 7) |
				((p.colour & 0xfe00) >> 9), SAA7146_BCS_CTRL);
			saa->picture = p;
			/* upload changed registers */
			saawrite(((SAA7146_MC2_UPLD_HPS_H |
				SAA7146_MC2_UPLD_HPS_V) << 16) |
				SAA7146_MC2_UPLD_HPS_H |
				SAA7146_MC2_UPLD_HPS_V, SAA7146_MC2);
			return 0;
		}
	case VIDIOCSWIN:
		{
			struct video_window vw;
			struct video_clip *vcp = NULL;

			if (copy_from_user(&vw, arg, sizeof(vw)))
				return -EFAULT;

			/* stop capture */
			if (vw.flags || vw.width < 16 || vw.height < 16) {
				saawrite((SAA7146_MC1_TR_E_1 << 16),
					SAA7146_MC1);
				return -EINVAL;
			}
			/* 32-bit align start and adjust width */
			if (saa->win.bpp < 4) {
				int i = vw.x;
				vw.x = (vw.x + 3) & ~3;
				i = vw.x - i;
				vw.width -= i;
			}
			saa->win.x = vw.x;
			saa->win.y = vw.y;
			saa->win.width = vw.width;
			if (saa->win.width > 768)
				saa->win.width = 768;
			saa->win.height = vw.height;
			if (CurrentMode == VIDEO_MODE_NTSC) {
				if (saa->win.height > 480)
					saa->win.height = 480;
			} else {
				if (saa->win.height > 576)
					saa->win.height = 576;
			}

			/* stop capture */
			saawrite((SAA7146_MC1_TR_E_1 << 16), SAA7146_MC1);
			saa7146_set_winsize(saa);

			/*
			 *    Do any clips.
			 */
			if (vw.clipcount < 0) {
				if (copy_from_user(saa->dmavid2, vw.clips,
						VIDEO_CLIPMAP_SIZE))
					return -EFAULT;
			} else if (vw.clipcount > 16384) {
				return -EINVAL;
			} else if (vw.clipcount > 0) {
				vcp = vmalloc(sizeof(struct video_clip) *
					vw.clipcount);
				if (vcp == NULL)
					return -ENOMEM;
				if (copy_from_user(vcp, vw.clips,
						sizeof(struct video_clip) *
						vw.clipcount)) {
					vfree(vcp);
					return -EFAULT;
				}
			} else	/* nothing clipped */
				memset(saa->dmavid2, 0, VIDEO_CLIPMAP_SIZE);

			make_clip_tab(saa, vcp, vw.clipcount);
			if (vw.clipcount > 0)
				vfree(vcp);

			/* start capture & clip dma if we have an address */
			if ((saa->cap & 3) && saa->win.vidadr != 0)
				saawrite(((SAA7146_MC1_TR_E_1 |
					SAA7146_MC1_TR_E_2) << 16) | 0xffff,
					SAA7146_MC1);
			return 0;
		}
	case VIDIOCGWIN:
		{
			struct video_window vw;
			vw.x = saa->win.x;
			vw.y = saa->win.y;
			vw.width = saa->win.width;
			vw.height = saa->win.height;
			vw.chromakey = 0;
			vw.flags = 0;
			if (copy_to_user(arg, &vw, sizeof(vw)))
				return -EFAULT;
			return 0;
		}
	case VIDIOCCAPTURE:
		{
			int v;
			if (copy_from_user(&v, arg, sizeof(v)))
				return -EFAULT;
			if (v == 0) {
				saa->cap &= ~1;
				saawrite((SAA7146_MC1_TR_E_1 << 16),
					SAA7146_MC1);
			} else {
				if (saa->win.vidadr == 0 || saa->win.width == 0
						|| saa->win.height == 0)
					return -EINVAL;
				saa->cap |= 1;
				saawrite((SAA7146_MC1_TR_E_1 << 16) | 0xffff,
					SAA7146_MC1);
			}
			return 0;
		}
	case VIDIOCGFBUF:
		{
			struct video_buffer v;
			v.base = (void *)saa->win.vidadr;
			v.height = saa->win.sheight;
			v.width = saa->win.swidth;
			v.depth = saa->win.depth;
			v.bytesperline = saa->win.bpl;
			if (copy_to_user(arg, &v, sizeof(v)))
				return -EFAULT;
			return 0;

		}
	case VIDIOCSFBUF:
		{
			struct video_buffer v;
			if (!capable(CAP_SYS_ADMIN))
				return -EPERM;
			if (copy_from_user(&v, arg, sizeof(v)))
				return -EFAULT;
			if (v.depth != 8 && v.depth != 15 && v.depth != 16 &&
			    v.depth != 24 && v.depth != 32 && v.width > 16 &&
			    v.height > 16 && v.bytesperline > 16)
				return -EINVAL;
			if (v.base)
				saa->win.vidadr = (unsigned long)v.base;
			saa->win.sheight = v.height;
			saa->win.swidth = v.width;
			saa->win.bpp = ((v.depth + 7) & 0x38) / 8;
			saa->win.depth = v.depth;
			saa->win.bpl = v.bytesperline;

			DEBUG(printk("Display at %p is %d by %d, bytedepth %d, "
					"bpl %d\n", v.base, v.width, v.height,
					saa->win.bpp, saa->win.bpl));
			saa7146_set_winsize(saa);
			return 0;
		}
	case VIDIOCKEY:
		{
			/* Will be handled higher up .. */
			return 0;
		}

	case VIDIOCGAUDIO:
		{
			struct video_audio v;
			v = saa->audio_dev;
			v.flags &= ~(VIDEO_AUDIO_MUTE | VIDEO_AUDIO_MUTABLE);
			v.flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME;
			strcpy(v.name, "MPEG");
			v.mode = VIDEO_SOUND_STEREO;
			if (copy_to_user(arg, &v, sizeof(v)))
				return -EFAULT;
			return 0;
		}
	case VIDIOCSAUDIO:
		{
			struct video_audio v;
			int i;
			if (copy_from_user(&v, arg, sizeof(v)))
				return -EFAULT;
			i = (~(v.volume >> 8)) & 0xff;
			if (!HaveCS4341) {
				if (v.flags & VIDEO_AUDIO_MUTE)
					debiwrite(saa, debNormal,
						IBM_MP2_FRNT_ATTEN, 0xffff, 2);
				if (!(v.flags & VIDEO_AUDIO_MUTE))
					debiwrite(saa, debNormal,
						IBM_MP2_FRNT_ATTEN, 0x0000, 2);
				if (v.flags & VIDEO_AUDIO_VOLUME)
					debiwrite(saa, debNormal,
						IBM_MP2_FRNT_ATTEN,
						(i << 8) | i, 2);
			} else {
				if (v.flags & VIDEO_AUDIO_MUTE)
					cs4341_setlevel(saa, 0xff, 0xff);
				if (!(v.flags & VIDEO_AUDIO_MUTE))
					cs4341_setlevel(saa, 0, 0);
				if (v.flags & VIDEO_AUDIO_VOLUME)
					cs4341_setlevel(saa, i, i);
			}
			saa->audio_dev = v;
			return 0;
		}

	case VIDIOCGUNIT:
		{
			struct video_unit vu;
			vu.video = saa->video_dev.minor;
			vu.vbi = VIDEO_NO_UNIT;
			vu.radio = VIDEO_NO_UNIT;
			vu.audio = VIDEO_NO_UNIT;
			vu.teletext = VIDEO_NO_UNIT;
			if (copy_to_user(arg, &vu, sizeof(vu)))
				return -EFAULT;
			return 0;
		}
	case VIDIOCSPLAYMODE:
		{
			struct video_play_mode pmode;
			if (copy_from_user((void *)&pmode, arg,
					sizeof(struct video_play_mode)))
				return -EFAULT;
			switch (pmode.mode) {
			case VID_PLAY_VID_OUT_MODE:
				if (pmode.p1 != VIDEO_MODE_NTSC &&
						pmode.p1 != VIDEO_MODE_PAL)
					return -EINVAL;
				set_out_format(saa, pmode.p1);
				return 0;
			case VID_PLAY_GENLOCK:
				debiwrite(saa, debNormal, XILINX_CTL0,
					pmode.p1 ? 0x8000 : 0x8080, 2);
				if (NewCard)
					set_genlock_offset(saa, pmode.p2);
				return 0;
			case VID_PLAY_NORMAL:
				debiwrite(saa, debNormal,
					IBM_MP2_CHIP_CONTROL, ChipControl, 2);
				ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
				saa->playmode = pmode.mode;
				return 0;
			case VID_PLAY_PAUSE:
				/* IBM removed the PAUSE command */
				/* they say use SINGLE_FRAME now */
			case VID_PLAY_SINGLE_FRAME:
				ibm_send_command(saa, IBM_MP2_SINGLE_FRAME,0,0);
				if (saa->playmode == pmode.mode) {
					debiwrite(saa, debNormal,
						IBM_MP2_CHIP_CONTROL,
						ChipControl, 2);
				}
				saa->playmode = pmode.mode;
				return 0;
			case VID_PLAY_FAST_FORWARD:
				ibm_send_command(saa, IBM_MP2_FAST_FORWARD,0,0);
				saa->playmode = pmode.mode;
				return 0;
			case VID_PLAY_SLOW_MOTION:
				ibm_send_command(saa, IBM_MP2_SLOW_MOTION,
					pmode.p1, 0);
				saa->playmode = pmode.mode;
				return 0;
			case VID_PLAY_IMMEDIATE_NORMAL:
				/* ensure transfers resume */
				debiwrite(saa, debNormal,
					IBM_MP2_CHIP_CONTROL, ChipControl, 2);
				ibm_send_command(saa, IBM_MP2_IMED_NORM_PLAY,
					0, 0);
				saa->playmode = VID_PLAY_NORMAL;
				return 0;
			case VID_PLAY_SWITCH_CHANNELS:
				saa->audhead = saa->audtail = 0;
				saa->vidhead = saa->vidtail = 0;
				ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,1);
				ibm_send_command(saa, IBM_MP2_RESET_AUD_RATE,
					0, 1);
				debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
					0, 2);
				ibm_send_command(saa, IBM_MP2_CHANNEL_SWITCH,
					0, 1);
				debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
					ChipControl, 2);
				ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
				saa->playmode = VID_PLAY_NORMAL;
				return 0;
			case VID_PLAY_FREEZE_FRAME:
				ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,0);
				saa->playmode = pmode.mode;
				return 0;
			case VID_PLAY_STILL_MODE:
				ibm_send_command(saa, IBM_MP2_SET_STILL_MODE,
					0, 0);
				saa->playmode = pmode.mode;
				return 0;
			case VID_PLAY_MASTER_MODE:
				if (pmode.p1 == VID_PLAY_MASTER_NONE)
					saa->boardcfg[1] = 0x13;
				else if (pmode.p1 == VID_PLAY_MASTER_VIDEO)
					saa->boardcfg[1] = 0x23;
				else if (pmode.p1 == VID_PLAY_MASTER_AUDIO)
					saa->boardcfg[1] = 0x43;
				else
					return -EINVAL;
				debiwrite(saa, debNormal,
					  IBM_MP2_CHIP_CONTROL, ChipControl, 2);
				return 0;
			case VID_PLAY_ACTIVE_SCANLINES:
				if (CurrentMode == VIDEO_MODE_PAL) {
					if (pmode.p1 < 1 || pmode.p2 > 625)
						return -EINVAL;
					saa->boardcfg[5] = pmode.p1;
					saa->boardcfg[55] = (pmode.p1 +
						(pmode.p2 / 2) - 1) & 0xff;
				} else {
					if (pmode.p1 < 4 || pmode.p2 > 525)
						return -EINVAL;
					saa->boardcfg[4] = pmode.p1;
					saa->boardcfg[54] = (pmode.p1 +
						(pmode.p2 / 2) - 4) & 0xff;
				}
				set_out_format(saa, CurrentMode);
			case VID_PLAY_RESET:
				return do_ibm_reset(saa);
			case VID_PLAY_END_MARK:
				if (saa->endmarktail < saa->endmarkhead) {
					if (saa->endmarkhead -
							saa->endmarktail < 2)
						return -ENOSPC;
				} else if (saa->endmarkhead <=saa->endmarktail){
					if (saa->endmarktail - saa->endmarkhead
							> (MAX_MARKS - 2))
						return -ENOSPC;
				} else
					return -ENOSPC;
				saa->endmark[saa->endmarktail] = saa->audtail;
				saa->endmarktail++;
				if (saa->endmarktail >= MAX_MARKS)
					saa->endmarktail = 0;
			}
			return -EINVAL;
		}
	case VIDIOCSWRITEMODE:
		{
			int mode;
			if (copy_from_user((void *)&mode, arg, sizeof(int)))
				return -EFAULT;
			if (mode == VID_WRITE_MPEG_AUD ||
					mode == VID_WRITE_MPEG_VID ||
					mode == VID_WRITE_CC ||
					mode == VID_WRITE_TTX ||
					mode == VID_WRITE_OSD) {
				saa->writemode = mode;
				return 0;
			}
			return -EINVAL;
		}
	case VIDIOCSMICROCODE:
		{
			struct video_code ucode;
			__u8 *udata;
			int i;
			if (copy_from_user(&ucode, arg, sizeof(ucode)))
				return -EFAULT;
			if (ucode.datasize > 65536 || ucode.datasize < 1024 ||
					strncmp(ucode.loadwhat, "dec", 3))
				return -EINVAL;
			if ((udata = vmalloc(ucode.datasize)) == NULL)
				return -ENOMEM;
			if (copy_from_user(udata, ucode.data, ucode.datasize)) {
				vfree(udata);
				return -EFAULT;
			}
			ucode.data = udata;
			if (!strncmp(ucode.loadwhat, "decoder.aud", 11) ||
				!strncmp(ucode.loadwhat, "decoder.vid", 11))
				i = initialize_ibmmpeg2(&ucode);
			else
				i = initialize_fpga(&ucode);
			vfree(udata);
			if (i)
				return -EINVAL;
			return 0;

		}
	case VIDIOCGCHAN:	/* this makes xawtv happy */
		{
			struct video_channel v;
			if (copy_from_user(&v, arg, sizeof(v)))
				return -EFAULT;
			v.flags = VIDEO_VC_AUDIO;
			v.tuners = 0;
			v.type = VID_TYPE_MPEG_DECODER;
			v.norm = CurrentMode;
			strcpy(v.name, "MPEG2");
			if (copy_to_user(arg, &v, sizeof(v)))
				return -EFAULT;
			return 0;
		}
	case VIDIOCSCHAN:	/* this makes xawtv happy */
		{
			struct video_channel v;
			if (copy_from_user(&v, arg, sizeof(v)))
				return -EFAULT;
			/* do nothing */
			return 0;
		}
	default:
		return -ENOIOCTLCMD;
	}
	return 0;
}

static int saa_mmap(struct file *file, struct vm_area_struct *vma)
{
	struct saa7146 *saa = file->private_data;
	printk(KERN_DEBUG "stradis%d: saa_mmap called\n", saa->nr);
	return -EINVAL;
}

static ssize_t saa_read(struct file *file, char __user * buf,
	size_t count, loff_t * ppos)
{
	return -EINVAL;
}

static ssize_t saa_write(struct file *file, const char __user * buf,
	size_t count, loff_t * ppos)
{
	struct saa7146 *saa = file->private_data;
	unsigned long todo = count;
	int blocksize, split;
	unsigned long flags;

	while (todo > 0) {
		if (saa->writemode == VID_WRITE_MPEG_AUD) {
			spin_lock_irqsave(&saa->lock, flags);
			if (saa->audhead <= saa->audtail)
				blocksize = 65536 -
					(saa->audtail - saa->audhead);
			else
				blocksize = saa->audhead - saa->audtail;
			spin_unlock_irqrestore(&saa->lock, flags);
			if (blocksize < 16384) {
				saawrite(SAA7146_PSR_DEBI_S |
					SAA7146_PSR_PIN1, SAA7146_IER);
				saawrite(SAA7146_PSR_PIN1, SAA7146_PSR);
				/* wait for buffer space to open */
				interruptible_sleep_on(&saa->audq);
			}
			spin_lock_irqsave(&saa->lock, flags);
			if (saa->audhead <= saa->audtail) {
				blocksize = 65536 -
					(saa->audtail - saa->audhead);
				split = 65536 - saa->audtail;
			} else {
				blocksize = saa->audhead - saa->audtail;
				split = 65536;
			}
			spin_unlock_irqrestore(&saa->lock, flags);
			blocksize--;
			if (blocksize > todo)
				blocksize = todo;
			/* double check that we really have space */
			if (!blocksize)
				return -ENOSPC;
			if (split < blocksize) {
				if (copy_from_user(saa->audbuf +
						saa->audtail, buf, split))
					return -EFAULT;
				buf += split;
				todo -= split;
				blocksize -= split;
				saa->audtail = 0;
			}
			if (copy_from_user(saa->audbuf + saa->audtail, buf,
					blocksize))
				return -EFAULT;
			saa->audtail += blocksize;
			todo -= blocksize;
			buf += blocksize;
			saa->audtail &= 0xffff;
		} else if (saa->writemode == VID_WRITE_MPEG_VID) {
			spin_lock_irqsave(&saa->lock, flags);
			if (saa->vidhead <= saa->vidtail)
				blocksize = 524288 -
					(saa->vidtail - saa->vidhead);
			else
				blocksize = saa->vidhead - saa->vidtail;
			spin_unlock_irqrestore(&saa->lock, flags);
			if (blocksize < 65536) {
				saawrite(SAA7146_PSR_DEBI_S |
					SAA7146_PSR_PIN1, SAA7146_IER);
				saawrite(SAA7146_PSR_PIN1, SAA7146_PSR);
				/* wait for buffer space to open */
				interruptible_sleep_on(&saa->vidq);
			}
			spin_lock_irqsave(&saa->lock, flags);
			if (saa->vidhead <= saa->vidtail) {
				blocksize = 524288 -
					(saa->vidtail - saa->vidhead);
				split = 524288 - saa->vidtail;
			} else {
				blocksize = saa->vidhead - saa->vidtail;
				split = 524288;
			}
			spin_unlock_irqrestore(&saa->lock, flags);
			blocksize--;
			if (blocksize > todo)
				blocksize = todo;
			/* double check that we really have space */
			if (!blocksize)
				return -ENOSPC;
			if (split < blocksize) {
				if (copy_from_user(saa->vidbuf +
						saa->vidtail, buf, split))
					return -EFAULT;
				buf += split;
				todo -= split;
				blocksize -= split;
				saa->vidtail = 0;
			}
			if (copy_from_user(saa->vidbuf + saa->vidtail, buf,
					blocksize))
				return -EFAULT;
			saa->vidtail += blocksize;
			todo -= blocksize;
			buf += blocksize;
			saa->vidtail &= 0x7ffff;
		} else if (saa->writemode == VID_WRITE_OSD) {
			if (count > 131072)
				return -ENOSPC;
			if (copy_from_user(saa->osdbuf, buf, count))
				return -EFAULT;
			buf += count;
			saa->osdhead = 0;
			saa->osdtail = count;
			debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR, 0, 2);
			debiwrite(saa, debNormal, IBM_MP2_OSD_LINK_ADDR, 0, 2);
			debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00d, 2);
			debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
				debiread(saa, debNormal,
					IBM_MP2_DISP_MODE, 2) | 1, 2);
			/* trigger osd data transfer */
			saawrite(SAA7146_PSR_DEBI_S |
				 SAA7146_PSR_PIN1, SAA7146_IER);
			saawrite(SAA7146_PSR_PIN1, SAA7146_PSR);
		}
	}
	return count;
}

static int saa_open(struct inode *inode, struct file *file)
{
	struct video_device *vdev = video_devdata(file);
	struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);

	file->private_data = saa;

	saa->user++;
	if (saa->user > 1)
		return 0;	/* device open already, don't reset */
	saa->writemode = VID_WRITE_MPEG_VID;	/* default to video */
	return 0;
}

static int saa_release(struct inode *inode, struct file *file)
{
	struct saa7146 *saa = file->private_data;
	saa->user--;

	if (saa->user > 0)	/* still someone using device */
		return 0;
	saawrite(0x007f0000, SAA7146_MC1);	/* stop all overlay dma */
	return 0;
}

static struct file_operations saa_fops = {
	.owner = THIS_MODULE,
	.open = saa_open,
	.release = saa_release,
	.ioctl = saa_ioctl,
	.compat_ioctl = v4l_compat_ioctl32,
	.read = saa_read,
	.llseek = no_llseek,
	.write = saa_write,
	.mmap = saa_mmap,
};

/* template for video_device-structure */
static struct video_device saa_template = {
	.name = "SAA7146A",
	.type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY,
	.hardware = VID_HARDWARE_SAA7146,
	.fops = &saa_fops,
	.minor = -1,
};

static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
{
	int retval;
	struct saa7146 *saa = pci_get_drvdata(pdev);

	saa->endmarkhead = saa->endmarktail = 0;
	saa->win.x = saa->win.y = 0;
	saa->win.width = saa->win.cropwidth = 720;
	saa->win.height = saa->win.cropheight = 480;
	saa->win.cropx = saa->win.cropy = 0;
	saa->win.bpp = 2;
	saa->win.depth = 16;
	saa->win.color_fmt = palette2fmt[VIDEO_PALETTE_RGB565];
	saa->win.bpl = 1024 * saa->win.bpp;
	saa->win.swidth = 1024;
	saa->win.sheight = 768;
	saa->picture.brightness = 32768;
	saa->picture.contrast = 38768;
	saa->picture.colour = 32768;
	saa->cap = 0;
	saa->nr = num;
	saa->playmode = VID_PLAY_NORMAL;
	memset(saa->boardcfg, 0, 64);	/* clear board config area */
	saa->saa7146_mem = NULL;
	saa->dmavid1 = saa->dmavid2 = saa->dmavid3 = saa->dmaa1in =
	    saa->dmaa1out = saa->dmaa2in = saa->dmaa2out =
	    saa->pagevid1 = saa->pagevid2 = saa->pagevid3 = saa->pagea1in =
	    saa->pagea1out = saa->pagea2in = saa->pagea2out =
	    saa->pagedebi = saa->dmaRPS1 = saa->dmaRPS2 = saa->pageRPS1 =
	    saa->pageRPS2 = NULL;
	saa->audbuf = saa->vidbuf = saa->osdbuf = saa->dmadebi = NULL;
	saa->audhead = saa->vidtail = 0;

	init_waitqueue_head(&saa->i2cq);
	init_waitqueue_head(&saa->audq);
	init_waitqueue_head(&saa->debiq);
	init_waitqueue_head(&saa->vidq);
	spin_lock_init(&saa->lock);

	retval = pci_enable_device(pdev);
	if (retval) {
		dev_err(&pdev->dev, "%d: pci_enable_device failed!\n", num);
		goto err;
	}

	saa->id = pdev->device;
	saa->irq = pdev->irq;
	saa->video_dev.minor = -1;
	saa->saa7146_adr = pci_resource_start(pdev, 0);
	pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision);

	saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200);
	if (saa->saa7146_mem == NULL) {
		dev_err(&pdev->dev, "%d: ioremap failed!\n", num);
		retval = -EIO;
		goto err;
	}

	memcpy(&saa->video_dev, &saa_template, sizeof(saa_template));
	saawrite(0, SAA7146_IER);	/* turn off all interrupts */

	retval = request_irq(saa->irq, saa7146_irq, IRQF_SHARED | IRQF_DISABLED,
		"stradis", saa);
	if (retval == -EINVAL)
		dev_err(&pdev->dev, "%d: Bad irq number or handler\n", num);
	else if (retval == -EBUSY)
		dev_err(&pdev->dev, "%d: IRQ %ld busy, change your PnP config "
			"in BIOS\n", num, saa->irq);
	if (retval < 0)
		goto errio;

	pci_set_master(pdev);
	retval = video_register_device(&saa->video_dev, VFL_TYPE_GRABBER,
		video_nr);
	if (retval < 0) {
		dev_err(&pdev->dev, "%d: error in registering video device!\n",
			num);
		goto errio;
	}

	return 0;
errio:
	iounmap(saa->saa7146_mem);
err:
	return retval;
}

static int __devinit init_saa7146(struct pci_dev *pdev)
{
	struct saa7146 *saa = pci_get_drvdata(pdev);

	saa->user = 0;
	/* reset the saa7146 */
	saawrite(0xffff0000, SAA7146_MC1);
	mdelay(5);
	/* enable debi and i2c transfers and pins */
	saawrite(((SAA7146_MC1_EDP | SAA7146_MC1_EI2C |
		   SAA7146_MC1_TR_E_DEBI) << 16) | 0xffff, SAA7146_MC1);
	/* ensure proper state of chip */
	saawrite(0x00000000, SAA7146_PAGE1);
	saawrite(0x00f302c0, SAA7146_NUM_LINE_BYTE1);
	saawrite(0x00000000, SAA7146_PAGE2);
	saawrite(0x01400080, SAA7146_NUM_LINE_BYTE2);
	saawrite(0x00000000, SAA7146_DD1_INIT);
	saawrite(0x00000000, SAA7146_DD1_STREAM_B);
	saawrite(0x00000000, SAA7146_DD1_STREAM_A);
	saawrite(0x00000000, SAA7146_BRS_CTRL);
	saawrite(0x80400040, SAA7146_BCS_CTRL);
	saawrite(0x0000e000 /*| (1<<29) */ , SAA7146_HPS_CTRL);
	saawrite(0x00000060, SAA7146_CLIP_FORMAT_CTRL);
	saawrite(0x00000000, SAA7146_ACON1);
	saawrite(0x00000000, SAA7146_ACON2);
	saawrite(0x00000600, SAA7146_I2C_STATUS);
	saawrite(((SAA7146_MC2_UPLD_D1_B | SAA7146_MC2_UPLD_D1_A |
		SAA7146_MC2_UPLD_BRS | SAA7146_MC2_UPLD_HPS_H |
		SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_DMA2 |
		SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_I2C) << 16) | 0xffff,
		SAA7146_MC2);
	/* setup arbitration control registers */
	saawrite(0x1412121a, SAA7146_PCI_BT_V1);

	/* allocate 32k dma buffer + 4k for page table */
	if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) {
		dev_err(&pdev->dev, "%d: debi kmalloc failed\n", saa->nr);
		goto err;
	}
#if 0
	saa->pagedebi = saa->dmadebi + 32768;	/* top 4k is for mmu */
	saawrite(virt_to_bus(saa->pagedebi) /*|0x800 */ , SAA7146_DEBI_PAGE);
	for (i = 0; i < 12; i++)	/* setup mmu page table */
		saa->pagedebi[i] = virt_to_bus((saa->dmadebi + i * 4096));
#endif
	saa->audhead = saa->vidhead = saa->osdhead = 0;
	saa->audtail = saa->vidtail = saa->osdtail = 0;
	if (saa->vidbuf == NULL && (saa->vidbuf = vmalloc(524288)) == NULL) {
		dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
		goto err;
	}
	if (saa->audbuf == NULL && (saa->audbuf = vmalloc(65536)) == NULL) {
		dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
		goto errfree;
	}
	if (saa->osdbuf == NULL && (saa->osdbuf = vmalloc(131072)) == NULL) {
		dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
		goto errfree;
	}
	/* allocate 81920 byte buffer for clipping */
	if ((saa->dmavid2 = kzalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) {
		dev_err(&pdev->dev, "%d: clip kmalloc failed\n", saa->nr);
		goto errfree;
	}
	/* setup clipping registers */
	saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2);
	saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2);
	saawrite(virt_to_bus(saa->dmavid2) + VIDEO_CLIPMAP_SIZE,
		 SAA7146_PROT_ADDR2);
	saawrite(256, SAA7146_PITCH2);
	saawrite(4, SAA7146_PAGE2);	/* dma direction: read, no byteswap */
	saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2,
		 SAA7146_MC2);
	I2CBusScan(saa);

	return 0;
errfree:
	vfree(saa->osdbuf);
	vfree(saa->audbuf);
	vfree(saa->vidbuf);
	saa->audbuf = saa->osdbuf = saa->vidbuf = NULL;
err:
	return -ENOMEM;
}

static void stradis_release_saa(struct pci_dev *pdev)
{
	u8 command;
	struct saa7146 *saa = pci_get_drvdata(pdev);

	/* turn off all capturing, DMA and IRQs */
	saawrite(0xffff0000, SAA7146_MC1);	/* reset chip */
	saawrite(0, SAA7146_MC2);
	saawrite(0, SAA7146_IER);
	saawrite(0xffffffffUL, SAA7146_ISR);

	/* disable PCI bus-mastering */
	pci_read_config_byte(pdev, PCI_COMMAND, &command);
	command &= ~PCI_COMMAND_MASTER;
	pci_write_config_byte(pdev, PCI_COMMAND, command);

	/* unmap and free memory */
	saa->audhead = saa->audtail = saa->osdhead = 0;
	saa->vidhead = saa->vidtail = saa->osdtail = 0;
	vfree(saa->vidbuf);
	vfree(saa->audbuf);
	vfree(saa->osdbuf);
	kfree(saa->dmavid2);
	saa->audbuf = saa->vidbuf = saa->osdbuf = NULL;
	saa->dmavid2 = NULL;
	kfree(saa->dmadebi);
	kfree(saa->dmavid1);
	kfree(saa->dmavid3);
	kfree(saa->dmaa1in);
	kfree(saa->dmaa1out);
	kfree(saa->dmaa2in);
	kfree(saa->dmaa2out);
	kfree(saa->dmaRPS1);
	kfree(saa->dmaRPS2);
	free_irq(saa->irq, saa);
	if (saa->saa7146_mem)
		iounmap(saa->saa7146_mem);
	if (saa->video_dev.minor != -1)
		video_unregister_device(&saa->video_dev);
}

static int __devinit stradis_probe(struct pci_dev *pdev,
	const struct pci_device_id *ent)
{
	int retval = -EINVAL;

	if (saa_num >= SAA7146_MAX)
		goto err;

	if (!pdev->subsystem_vendor)
		dev_info(&pdev->dev, "%d: rev1 decoder\n", saa_num);
	else
		dev_info(&pdev->dev, "%d: SDM2xx found\n", saa_num);

	pci_set_drvdata(pdev, &saa7146s[saa_num]);

	retval = configure_saa7146(pdev, saa_num);
	if (retval) {
		dev_err(&pdev->dev, "%d: error in configuring\n", saa_num);
		goto err;
	}

	if (init_saa7146(pdev) < 0) {
		dev_err(&pdev->dev, "%d: error in initialization\n", saa_num);
		retval = -EIO;
		goto errrel;
	}

	saa_num++;

	return 0;
errrel:
	stradis_release_saa(pdev);
err:
	return retval;
}

static void __devexit stradis_remove(struct pci_dev *pdev)
{
	stradis_release_saa(pdev);
}

static struct pci_device_id stradis_pci_tbl[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146) },
	{ 0 }
};

MODULE_DEVICE_TABLE(pci, stradis_pci_tbl);

static struct pci_driver stradis_driver = {
	.name = "stradis",
	.id_table = stradis_pci_tbl,
	.probe = stradis_probe,
	.remove = __devexit_p(stradis_remove)
};

static int __init stradis_init(void)
{
	int retval;

	saa_num = 0;

	retval = pci_register_driver(&stradis_driver);
	if (retval)
		printk(KERN_ERR "stradis: Unable to register pci driver.\n");

	return retval;
}

static void __exit stradis_exit(void)
{
	pci_unregister_driver(&stradis_driver);
	printk(KERN_INFO "stradis: module cleanup complete\n");
}

module_init(stradis_init);
module_exit(stradis_exit);
