linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/14] firmware update for av7110 dvb driver
  2003-10-08 13:28 [PATCH 1/14] LinuxTV.org DVB driver update Michael Hunold
@ 2003-10-08 13:28 ` Michael Hunold
  2003-10-08 13:28   ` [PATCH 3/14] add new DVB-T frontend driver Michael Hunold
  2003-10-08 14:45   ` [PATCH 2/14] firmware update for av7110 dvb driver Marcel Holtmann
  2003-10-10 20:15 ` [PATCH 1/14] LinuxTV.org DVB driver update Stephen Hemminger
  1 sibling, 2 replies; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

... send to Linus only. (You don't want a 150kB bzip2 compressed firmware blob, don't you? In case you do, drop me a line.)


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 1/14] LinuxTV.org DVB driver update
@ 2003-10-08 13:28 Michael Hunold
  2003-10-08 13:28 ` [PATCH 2/14] firmware update for av7110 dvb driver Michael Hunold
  2003-10-10 20:15 ` [PATCH 1/14] LinuxTV.org DVB driver update Stephen Hemminger
  0 siblings, 2 replies; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

Hi Linus,

this is the periodical patchset bomb to keep the DVB subsystem and the
various DVB drivers from the LinuxTV.org CVS in sync with 2.6.

There are 13 individual patches, all have detailed patch desriptions in
the top of the file. There is some fuzziness, mainly due to the "video-buf"
updates from Gerd Knorr yesterday.

Please apply.

Thanks
Michael.


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 3/14] add new DVB-T frontend driver
  2003-10-08 13:28 ` [PATCH 2/14] firmware update for av7110 dvb driver Michael Hunold
@ 2003-10-08 13:28   ` Michael Hunold
  2003-10-08 13:28     ` [PATCH 4/14] video capture updates for saa7146 core Michael Hunold
  2003-10-08 14:45   ` [PATCH 2/14] firmware update for av7110 dvb driver Marcel Holtmann
  1 sibling, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] add new DVB-T frontend driver sp887x.c
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/frontends/Makefile linux-2.6.0-test5/drivers/media/dvb/frontends/Makefile
--- xx-linux-2.6.0-test5/drivers/media/dvb/frontends/Makefile	2003-09-10 11:28:54.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/frontends/Makefile	2003-09-09 09:24:21.000000000 +0200
@@ -15,3 +15,4 @@
 obj-$(CONFIG_DVB_MT312) += mt312.o
 obj-$(CONFIG_DVB_VES1820) += ves1820.o
 obj-$(CONFIG_DVB_TDA1004X) += tda1004x.o
+obj-$(CONFIG_DVB_SP887X) += sp887x.o
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/frontends/sp887x.c linux-2.6.0-test5/drivers/media/dvb/frontends/sp887x.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/frontends/sp887x.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-test5/drivers/media/dvb/frontends/sp887x.c	2003-09-07 17:40:35.000000000 +0200
@@ -0,0 +1,610 @@
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+
+#include "dvb_frontend.h"
+#include "dvb_compat.h"
+
+
+#if 0
+#define dprintk(x...) printk(x)
+#else
+#define dprintk(x...)
+#endif
+
+#if 0
+#define LOG(dir,addr,buf,len) 					\
+	do {							\
+		int i;						\
+		printk("%s (%02x):", dir, addr & 0xff);		\
+		for (i=0; i<len; i++)				\
+			printk(" 0x%02x,", buf[i] & 0xff);	\
+		printk("\n");					\
+	} while (0)
+#else
+#define LOG(dir,addr,buf,len)
+#endif
+
+
+static
+struct dvb_frontend_info sp887x_info = {
+	.name = "Microtune MT7072DTF",
+	.type = FE_OFDM,
+	.frequency_min =  50500000,
+	.frequency_max = 858000000,
+	.frequency_stepsize = 166666,
+	.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
+		FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_RECOVER
+};
+
+
+
+static
+int i2c_writebytes (struct dvb_frontend *fe, u8 addr, u8 *buf, u8 len)
+{
+	struct dvb_i2c_bus *i2c = fe->i2c;
+	struct i2c_msg msg = { addr: addr, flags: 0, buf: buf, len: len };
+	int err;
+
+	LOG("i2c_writebytes", msg.addr, msg.buf, msg.len);
+
+	if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
+		printk ("%s: i2c write error (addr %02x, err == %i)\n",
+			__FUNCTION__, addr, err);
+		return -EREMOTEIO;
+	}
+
+	return 0;
+}
+
+
+
+static
+int sp887x_writereg (struct dvb_frontend *fe, u16 reg, u16 data)
+{
+	struct dvb_i2c_bus *i2c = fe->i2c;
+	u8 b0 [] = { reg >> 8 , reg & 0xff, data >> 8, data & 0xff };
+	struct i2c_msg msg = { .addr = 0x70, .flags = 0, .buf = b0, .len = 4 };
+	int ret;
+
+	LOG("sp887x_writereg", msg.addr, msg.buf, msg.len);
+
+	if ((ret = i2c->xfer(i2c, &msg, 1)) != 1) {
+		/**
+		 *  in case of soft reset we ignore ACK errors...
+		 */
+		if (!(reg == 0xf1a && data == 0x000 && 
+			(ret == -EREMOTEIO || ret == -EFAULT)))
+		{
+			printk("%s: writereg error "
+			       "(reg %03x, data %03x, ret == %i)\n",
+			       __FUNCTION__, reg & 0xffff, data & 0xffff, ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+
+static
+u16 sp887x_readreg (struct dvb_frontend *fe, u16 reg)
+{
+	struct dvb_i2c_bus *i2c = fe->i2c;
+	u8 b0 [] = { reg >> 8 , reg & 0xff };
+	u8 b1 [2];
+	int ret;
+	struct i2c_msg msg[] = {{ .addr = 0x70, .flags = 0, .buf = b0, .len = 2 },
+		         { .addr = 0x70, .flags = I2C_M_RD, .buf = b1, .len = 2 }};
+
+	LOG("sp887x_readreg (w)", msg[0].addr, msg[0].buf, msg[0].len);
+	LOG("sp887x_readreg (r)", msg[1].addr, msg[1].buf, msg[1].len);
+
+	if ((ret = i2c->xfer(i2c, msg, 2)) != 2)
+		printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+
+	return (((b1[0] << 8) | b1[1]) & 0xfff);
+}
+
+
+static
+void sp887x_microcontroller_stop (struct dvb_frontend *fe)
+{
+	sp887x_writereg(fe, 0xf08, 0x000);
+	sp887x_writereg(fe, 0xf09, 0x000);		
+
+	/* microcontroller STOP */
+	sp887x_writereg(fe, 0xf00, 0x000);
+}
+
+
+static
+void sp887x_microcontroller_start (struct dvb_frontend *fe)
+{
+	sp887x_writereg(fe, 0xf08, 0x000);
+	sp887x_writereg(fe, 0xf09, 0x000);		
+
+	/* microcontroller START */
+	sp887x_writereg(fe, 0xf00, 0x001);
+}
+
+
+static
+void sp887x_setup_agc (struct dvb_frontend *fe)
+{
+	/* setup AGC parameters */
+	sp887x_writereg(fe, 0x33c, 0x054);
+	sp887x_writereg(fe, 0x33b, 0x04c);
+	sp887x_writereg(fe, 0x328, 0x000);
+	sp887x_writereg(fe, 0x327, 0x005);
+	sp887x_writereg(fe, 0x326, 0x001);
+	sp887x_writereg(fe, 0x325, 0x001);
+	sp887x_writereg(fe, 0x324, 0x001);
+	sp887x_writereg(fe, 0x318, 0x050);
+	sp887x_writereg(fe, 0x317, 0x3fe);
+	sp887x_writereg(fe, 0x316, 0x001);
+	sp887x_writereg(fe, 0x313, 0x005);
+	sp887x_writereg(fe, 0x312, 0x002);
+	sp887x_writereg(fe, 0x306, 0x000);
+	sp887x_writereg(fe, 0x303, 0x000);
+}
+
+
+#include "sp887x_firm.h"
+
+#define BLOCKSIZE 30
+
+/**
+ *  load firmware and setup MPEG interface...
+ */
+static
+int sp887x_initial_setup (struct dvb_frontend *fe)
+{
+	u8 buf [BLOCKSIZE];
+	int i;
+
+	/* soft reset */
+	sp887x_writereg(fe, 0xf1a, 0x000);
+
+	sp887x_microcontroller_stop (fe);
+
+	printk ("%s: firmware upload... ", __FUNCTION__);
+
+	/* setup write pointer to -1 (end of memory) */
+	/* bit 0x8000 in address is set to enable 13bit mode */
+	sp887x_writereg(fe, 0x8f08, 0x1fff);
+
+	/* dummy write (wrap around to start of memory) */
+	sp887x_writereg(fe, 0x8f0a, 0x0000);
+
+	for (i=0; i<sizeof(sp887x_firm); i+=BLOCKSIZE) {
+		int c = BLOCKSIZE;
+		int err;
+
+		if (i+c > sizeof(sp887x_firm))
+			c = sizeof(sp887x_firm) - i;
+
+		/* bit 0x8000 in address is set to enable 13bit mode */
+		/* bit 0x4000 enables multibyte read/write transfers */
+		/* write register is 0xf0a */
+		buf[0] = 0xcf;
+		buf[1] = 0x0a;
+
+		memcpy(&buf[2], &sp887x_firm[i], c);
+
+		if ((err = i2c_writebytes (fe, 0x70, buf, c+2)) < 0) {
+			printk ("failed.\n");
+			printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err);
+			return err;
+		}
+	}
+
+	/* don't write RS bytes between packets */
+	sp887x_writereg(fe, 0xc13, 0x001);
+
+	/* suppress clock if (!data_valid) */
+	sp887x_writereg(fe, 0xc14, 0x000);
+
+	/* setup MPEG interface... */
+	sp887x_writereg(fe, 0xc1a, 0x872);
+	sp887x_writereg(fe, 0xc1b, 0x001);
+	sp887x_writereg(fe, 0xc1c, 0x000); /* parallel mode (serial mode == 1) */
+	sp887x_writereg(fe, 0xc1a, 0x871);
+
+	/* ADC mode, 2 for MT8872, 3 for SP8870/SP8871 */
+	sp887x_writereg(fe, 0x301, 0x002);
+
+	sp887x_setup_agc(fe);
+
+	/* bit 0x010: enable data valid signal */
+	sp887x_writereg(fe, 0xd00, 0x010);
+	sp887x_writereg(fe, 0x0d1, 0x000);
+
+	printk ("done.\n");
+	return 0;
+};
+
+
+/**
+ *  returns the actual tuned center frequency which can be used
+ *  to initialise the AFC registers
+ */
+static
+int tsa5060_setup_pll (struct dvb_frontend *fe, int freq)
+{
+	u8 cfg, cpump, band_select;
+	u8 buf [4];
+	u32 div;
+
+	div = (36000000 + freq + 83333) / 166666;
+	cfg = 0x88;
+
+	cpump = freq < 175000000 ? 2 : freq < 390000000 ? 1 :
+		freq < 470000000 ? 2 : freq < 750000000 ? 2 : 3;
+
+	band_select = freq < 175000000 ? 0x0e : freq < 470000000 ? 0x05 : 0x03;
+
+	buf [0] = (div >> 8) & 0x7f;
+	buf [1] = div & 0xff;
+	buf [2] = ((div >> 10) & 0x60) | cfg;
+	buf [3] = cpump | band_select;
+
+	/* open i2c gate for PLL message transmission... */
+	sp887x_writereg(fe, 0x206, 0x001);
+	i2c_writebytes(fe, 0x60, buf, 4);
+	sp887x_writereg(fe, 0x206, 0x000);
+
+	return (div * 166666 - 36000000);
+}
+
+
+
+static
+int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
+{
+	int known_parameters = 1;
+	
+	*reg0xc05 = 0x000;
+
+	switch (p->u.ofdm.constellation) {
+	case QPSK:
+		break;
+	case QAM_16:
+		*reg0xc05 |= (1 << 10);
+		break;
+	case QAM_64:
+		*reg0xc05 |= (2 << 10);
+		break;
+	case QAM_AUTO:
+		known_parameters = 0;
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	switch (p->u.ofdm.hierarchy_information) {
+	case HIERARCHY_NONE:
+		break;
+	case HIERARCHY_1:
+		*reg0xc05 |= (1 << 7);
+		break;
+	case HIERARCHY_2:
+		*reg0xc05 |= (2 << 7);
+		break;
+	case HIERARCHY_4:
+		*reg0xc05 |= (3 << 7);
+		break;
+	case HIERARCHY_AUTO:
+		known_parameters = 0;
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	switch (p->u.ofdm.code_rate_HP) {
+	case FEC_1_2:
+		break;
+	case FEC_2_3:
+		*reg0xc05 |= (1 << 3);
+		break;
+	case FEC_3_4:
+		*reg0xc05 |= (2 << 3);
+		break;
+	case FEC_5_6:
+		*reg0xc05 |= (3 << 3);
+		break;
+	case FEC_7_8:
+		*reg0xc05 |= (4 << 3);
+		break;
+	case FEC_AUTO:
+		known_parameters = 0;
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	if (known_parameters)
+		*reg0xc05 |= (2 << 1);	/* use specified parameters */
+	else
+		*reg0xc05 |= (1 << 1);	/* enable autoprobing */
+
+	return 0;
+}
+
+
+/**
+ *  estimates division of two 24bit numbers,
+ *  derived from the ves1820/stv0299 driver code
+ */
+static
+void divide (int n, int d, int *quotient_i, int *quotient_f)
+{
+	unsigned int q, r;
+
+	r = (n % d) << 8;
+	q = (r / d);
+
+	if (quotient_i)
+		*quotient_i = q;
+
+	if (quotient_f) {
+		r = (r % d) << 8;
+		q = (q << 8) | (r / d);
+		r = (r % d) << 8;
+		*quotient_f = (q << 8) | (r / d);
+	}
+}
+
+
+static
+void sp887x_correct_offsets (struct dvb_frontend *fe,
+			     struct dvb_frontend_parameters *p,
+			     int actual_freq)
+{
+	static const u32 srate_correction [] = { 1879617, 4544878, 8098561 };
+	int bw_index = p->u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
+	int freq_offset = actual_freq - p->frequency;
+	int sysclock = 61003; //[kHz]
+	int ifreq = 36000000;
+	int freq;
+	int frequency_shift;
+
+	if (p->inversion == INVERSION_ON)
+		freq = ifreq - freq_offset;
+	else
+		freq = ifreq + freq_offset;
+
+	divide(freq / 333, sysclock, NULL, &frequency_shift);
+
+	if (p->inversion == INVERSION_ON)
+		frequency_shift = -frequency_shift;
+
+	/* sample rate correction */
+	sp887x_writereg(fe, 0x319, srate_correction[bw_index] >> 12);
+	sp887x_writereg(fe, 0x31a, srate_correction[bw_index] & 0xfff);
+
+	/* carrier offset correction */
+	sp887x_writereg(fe, 0x309, frequency_shift >> 12);
+	sp887x_writereg(fe, 0x30a, frequency_shift & 0xfff);
+}
+
+
+static
+int sp887x_setup_frontend_parameters (struct dvb_frontend *fe,
+				      struct dvb_frontend_parameters *p)
+{
+	int actual_freq, err;
+	u16 val, reg0xc05;
+
+	if (p->u.ofdm.bandwidth != BANDWIDTH_8_MHZ &&
+	    p->u.ofdm.bandwidth != BANDWIDTH_7_MHZ &&
+	    p->u.ofdm.bandwidth != BANDWIDTH_6_MHZ)
+		return -EINVAL;
+	
+	if ((err = configure_reg0xc05(p, &reg0xc05)))
+		return err;
+
+	sp887x_microcontroller_stop(fe);
+
+	actual_freq = tsa5060_setup_pll(fe, p->frequency);
+
+	/* read status reg in order to clear pending irqs */
+	sp887x_readreg(fe, 0x200);
+
+	sp887x_correct_offsets(fe, p, actual_freq);
+
+	/* filter for 6/7/8 Mhz channel */
+	if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
+		val = 2;
+	else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
+		val = 1;
+	else
+		val = 0;
+
+	sp887x_writereg(fe, 0x311, val);
+
+	/* scan order: 2k first = 0, 8k first = 1 */
+	if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K)
+		sp887x_writereg(fe, 0x338, 0x000);
+	else
+		sp887x_writereg(fe, 0x338, 0x001);
+
+	sp887x_writereg(fe, 0xc05, reg0xc05);
+
+	if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
+		val = 2 << 3;
+	else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
+		val = 3 << 3;
+	else
+		val = 0 << 3;
+
+	/* enable OFDM and SAW bits as lock indicators in sync register 0xf17,
+	 * optimize algorithm for given bandwidth...
+	 */
+	sp887x_writereg(fe, 0xf14, 0x160 | val);
+	sp887x_writereg(fe, 0xf15, 0x000);
+
+	sp887x_microcontroller_start(fe);
+	return 0;
+}
+
+
+static
+int sp887x_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+{
+        switch (cmd) {
+        case FE_GET_INFO:
+		memcpy (arg, &sp887x_info, sizeof(struct dvb_frontend_info));
+		break;
+
+        case FE_READ_STATUS:
+	{
+		u16 snr12 = sp887x_readreg(fe, 0xf16);
+		u16 sync0x200 = sp887x_readreg(fe, 0x200);
+		u16 sync0xf17 = sp887x_readreg(fe, 0xf17);
+		fe_status_t *status = arg;
+
+		*status = 0;
+
+		if (snr12 > 0x00f)
+			*status |= FE_HAS_SIGNAL;
+
+		//if (sync0x200 & 0x004)
+		//	*status |= FE_HAS_SYNC | FE_HAS_CARRIER;
+
+		//if (sync0x200 & 0x008)
+		//	*status |= FE_HAS_VITERBI;
+
+		if ((sync0xf17 & 0x00f) == 0x002) {
+			*status |= FE_HAS_LOCK;
+			*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_CARRIER;
+		}
+
+		if (sync0x200 & 0x001) {	/* tuner adjustment requested...*/
+			int steps = (sync0x200 >> 4) & 0x00f;
+			if (steps & 0x008)
+				steps = -steps;
+			dprintk("sp887x: implement tuner adjustment (%+i steps)!!\n",
+			       steps);
+		}
+
+		break;
+
+	}
+
+        case FE_READ_BER:
+	{
+		u32* ber = arg;
+		*ber = (sp887x_readreg(fe, 0xc08) & 0x3f) |
+		       (sp887x_readreg(fe, 0xc07) << 6);
+		sp887x_writereg(fe, 0xc08, 0x000);
+		sp887x_writereg(fe, 0xc07, 0x000);
+		if (*ber >= 0x3fff0)
+			*ber = ~0;
+		break;
+
+	}
+
+        case FE_READ_SIGNAL_STRENGTH:		// FIXME: correct registers ?
+	{
+		u16 snr12 = sp887x_readreg(fe, 0xf16);
+		u32 signal = 3 * (snr12 << 4);
+		*((u16*) arg) = (signal < 0xffff) ? signal : 0xffff;
+		break;
+	}
+
+        case FE_READ_SNR:
+	{
+		u16 snr12 = sp887x_readreg(fe, 0xf16);
+		*(u16*) arg = (snr12 << 4) | (snr12 >> 8);
+		break;
+	}
+
+	case FE_READ_UNCORRECTED_BLOCKS:
+	{
+		u32 *ublocks = (u32 *) arg;
+		*ublocks = sp887x_readreg(fe, 0xc0c);
+		if (*ublocks == 0xfff)
+			*ublocks = ~0;
+		break;
+	}
+
+        case FE_SET_FRONTEND:
+		return sp887x_setup_frontend_parameters(fe, arg);
+
+	case FE_GET_FRONTEND:  // FIXME: read known values back from Hardware...
+		break;
+
+        case FE_SLEEP:
+		/* tristate TS output and disable interface pins */
+		sp887x_writereg(fe, 0xc18, 0x000);
+		break;
+
+        case FE_INIT:
+		if (fe->data == NULL) {	  /* first time initialisation... */
+			fe->data = (void*) ~0;
+			sp887x_initial_setup (fe);
+		}
+		/* enable TS output and interface pins */
+		sp887x_writereg(fe, 0xc18, 0x00d);
+		break;
+
+	default:
+		return -EOPNOTSUPP;
+        };
+
+        return 0;
+}
+
+
+
+static
+int sp887x_attach (struct dvb_i2c_bus *i2c)
+{
+	struct i2c_msg msg = { addr: 0x70, flags: 0, buf: NULL, len: 0 };
+
+	dprintk ("%s\n", __FUNCTION__);
+
+	if (i2c->xfer (i2c, &msg, 1) != 1)
+                return -ENODEV;
+
+	dvb_register_frontend (sp887x_ioctl, i2c, NULL, &sp887x_info);
+
+	return 0;
+}
+
+
+static
+void sp887x_detach (struct dvb_i2c_bus *i2c)
+{
+	dprintk ("%s\n", __FUNCTION__);
+	dvb_unregister_frontend (sp887x_ioctl, i2c);
+}
+
+
+static
+int __init init_sp887x (void)
+{
+	dprintk ("%s\n", __FUNCTION__);
+	return dvb_register_i2c_device (NULL, sp887x_attach, sp887x_detach);
+}
+
+
+static
+void __exit exit_sp887x (void)
+{
+	dprintk ("%s\n", __FUNCTION__);
+	dvb_unregister_i2c_device (sp887x_attach);
+}
+
+
+module_init(init_sp887x);
+module_exit(exit_sp887x);
+
+
+MODULE_DESCRIPTION("sp887x DVB-T demodulator driver");
+MODULE_LICENSE("GPL");
+
+


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 4/14] video capture updates for saa7146 core
  2003-10-08 13:28   ` [PATCH 3/14] add new DVB-T frontend driver Michael Hunold
@ 2003-10-08 13:28     ` Michael Hunold
  2003-10-08 13:28       ` [PATCH 5/14] multiple device *read* opens support Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] some Kconfig simplifications
- [DVB] FIELD_ALTERNATE capture was broken, add a "wait for vbi" command before actually waiting for the field change
- [DVB] improvements regarding streaming capture to gfx card memory.
- [DVB] captured frames could only be page aligned. fixed.
- [DVB] fix pgtable_build_single, it should work for all kinds of buffers now (system memory (kernel/user) and gfx-memory)
- [DVB] Fix bytesperline-calculation for V4L2_FIELD_ALTERNATE vs. V4L2_FIELD_INTERLACED capture
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/common/Kconfig linux-2.6.0-test5/drivers/media/common/Kconfig
--- xx-linux-2.6.0-test5/drivers/media/common/Kconfig	2003-09-10 11:28:54.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/common/Kconfig	2003-07-29 12:01:11.000000000 +0200
@@ -1,11 +1,8 @@
 config VIDEO_SAA7146
-        tristate
-        default y if DVB_AV7110=y || DVB_BUDGET=y || DVB_BUDGET_AV=y || VIDEO_MXB=y || VIDEO_DPC=y || VIDEO_HEXIUM_ORION=y || VIDEO_HEXIUM_GEMINI=y
-        default m if DVB_AV7110=m || DVB_BUDGET=m || DVB_BUDGET_AV=m || VIDEO_MXB=m || VIDEO_DPC=m || VIDEO_HEXIUM_ORION=m || VIDEO_HEXIUM_GEMINI=m
+	def_tristate DVB_AV7110 || DVB_BUDGET || DVB_BUDGET_AV || \
+		     VIDEO_MXB || VIDEO_DPC || VIDEO_HEXIUM_ORION || \
+		     VIDEO_HEXIUM_GEMINI
         depends on VIDEO_DEV && PCI && I2C
-
 config VIDEO_VIDEOBUF
-        tristate
-        default y if VIDEO_SAA7134=y || VIDEO_BT848=y || VIDEO_SAA7146=y
-        default m if VIDEO_SAA7134=m || VIDEO_BT848=m || VIDEO_SAA7146=m
+	def_tristate VIDEO_SAA7134 || VIDEO_BT848 || VIDEO_SAA7146
         depends on VIDEO_DEV
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/common/saa7146_core.c linux-2.6.0-test5/drivers/media/common/saa7146_core.c
--- xx-linux-2.6.0-test5/drivers/media/common/saa7146_core.c	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/common/saa7146_core.c	2003-08-21 15:13:41.000000000 +0200
@@ -139,34 +139,42 @@
 	return 0;
 }
 
-void saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length )
+void saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt,
+	struct scatterlist *list, int sglen  )
 {
 	u32   *ptr, fill;
+	int nr_pages = 0;
 	int   i,p;
 
-//fm	DEB_EE(("pci:%p, pt:%p, sl:%p, len:%d\n",pci,pt,list,length));
+	BUG_ON( 0 == sglen);
 
 	/* if we have a user buffer, the first page may not be
 	   aligned to a page boundary. */
 	pt->offset = list->offset;
 
 	ptr = pt->cpu;
-	for (i = 0; i < length; i++, list++) {
+	for (i = 0; i < sglen; i++, list++) {
+/*
+		printk("i:%d, adr:0x%08x, len:%d, offset:%d\n", i,sg_dma_address(list), sg_dma_len(list), list->offset);
+*/
 		for (p = 0; p * 4096 < list->length; p++, ptr++) {
-			*ptr = sg_dma_address(list) - list->offset;
+			*ptr = sg_dma_address(list) + p * 4096;
+			nr_pages++;
 		}
 	}
 
 
 	/* safety; fill the page table up with the last valid page */
 	fill = *(ptr-1);
-	for(;i<1024;i++) {
+	for(i=nr_pages;i<1024;i++) {
 		*ptr++ = fill;
 	}
+
 /*
 	ptr = pt->cpu;
-	for(j=0;j<60;j++) {
-		printk("ptr1 %d: 0x%08x\n",j,ptr[j]);
+	printk("offset: %d\n",pt->offset);
+	for(i=0;i<5;i++) {
+		printk("ptr1 %d: 0x%08x\n",i,ptr[i]);
 	}
 */
 }
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/common/saa7146_fops.c linux-2.6.0-test5/drivers/media/common/saa7146_fops.c
--- xx-linux-2.6.0-test5/drivers/media/common/saa7146_fops.c	2003-09-10 11:29:20.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/common/saa7146_fops.c	2003-07-31 14:25:06.000000000 +0200
@@ -304,6 +304,7 @@
 			return videobuf_poll_stream(file, &fh->vbi_q, wait);
 		q = &fh->vbi_q;
 	} else {
+		DEB_D(("using video queue.\n"));
 		q = &fh->video_q;
 	}
 
@@ -311,14 +312,17 @@
 		buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
 
 	if (!buf) {
+		DEB_D(("buf == NULL!\n"));
 		return POLLERR;
 	}
 
 	poll_wait(file, &buf->done, wait);
 	if (buf->state == STATE_DONE || buf->state == STATE_ERROR) {
+		DEB_D(("poll succeeded!\n"));
 		return POLLIN|POLLRDNORM;
 	}
 
+	DEB_D(("nothing to poll for, buf->state:%d\n",buf->state));
 	return 0;
 }
 
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/common/saa7146_hlp.c linux-2.6.0-test5/drivers/media/common/saa7146_hlp.c
--- xx-linux-2.6.0-test5/drivers/media/common/saa7146_hlp.c	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/common/saa7146_hlp.c	2003-08-11 13:13:10.000000000 +0200
@@ -742,6 +742,7 @@
 
 	int width = buf->fmt->width;
 	int height = buf->fmt->height;
+	int bytesperline = buf->fmt->bytesperline;
 	enum v4l2_field field = buf->fmt->field;
 
 	int depth = sfmt->depth;
@@ -749,7 +750,11 @@
 	DEB_CAP(("[size=%dx%d,fields=%s]\n",
 		width,height,v4l2_field_names[field]));
 
+	if( bytesperline != 0) {
+		vdma1.pitch = bytesperline*2;
+	} else {
 	vdma1.pitch		= (width*depth*2)/8;
+	}
 	vdma1.num_line_byte	= ((vv->standard->v_field<<16) + vv->standard->h_pixels);
 	vdma1.base_page		= buf->pt[0].dma | ME1;
 	
@@ -799,6 +804,8 @@
 	vdma2->pitch	= width;
 	vdma3->pitch	= width;
 
+	/* fixme: look at bytesperline! */
+
 	if( 0 != vv->vflip ) {
 		vdma2->prot_addr	= buf->pt[1].offset;
 		vdma2->base_even	= ((vdma2->pitch/2)*height)+buf->pt[1].offset;
@@ -871,6 +878,8 @@
 	DEB_CAP(("[size=%dx%d,fields=%s]\n",
 		width,height,v4l2_field_names[field]));
 
+	/* fixme: look at bytesperline! */
+
 	/* fixme: what happens for user space buffers here?. The offsets are
 	   most likely wrong, this version here only works for page-aligned
 	   buffers, modifications to the pagetable-functions are necessary...*/
@@ -997,8 +1006,10 @@
 		WRITE_RPS0(CMD_PAUSE | o_wait);
 	WRITE_RPS0(CMD_PAUSE | e_wait);
 	} else if ( vv->last_field == V4L2_FIELD_TOP ) {
+		WRITE_RPS0(CMD_PAUSE | (vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? MASK_10 : MASK_09));
 	WRITE_RPS0(CMD_PAUSE | o_wait);
 	} else if ( vv->last_field == V4L2_FIELD_BOTTOM ) {
+		WRITE_RPS0(CMD_PAUSE | (vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? MASK_10 : MASK_09));
 		WRITE_RPS0(CMD_PAUSE | e_wait);
 	}
 
@@ -1033,16 +1044,6 @@
 
 	DEB_CAP(("buf:%p, next:%p\n",buf,next));
 
-/*
-	printk("vdma%d.base_even:     0x%08x\n", 1,saa7146_read(dev,BASE_EVEN1));
-	printk("vdma%d.base_odd:      0x%08x\n", 1,saa7146_read(dev,BASE_ODD1));
-	printk("vdma%d.prot_addr:     0x%08x\n", 1,saa7146_read(dev,PROT_ADDR1));
-	printk("vdma%d.base_page:     0x%08x\n", 1,saa7146_read(dev,BASE_PAGE1));
-	printk("vdma%d.pitch:         0x%08x\n", 1,saa7146_read(dev,PITCH1));
-	printk("vdma%d.num_line_byte: 0x%08x\n", 1,saa7146_read(dev,NUM_LINE_BYTE1));
-	printk("vdma%d => vptr      : 0x%08x\n", 1,saa7146_read(dev,PCI_VDP1));
-*/
-
 	vdma1_prot_addr = saa7146_read(dev, PROT_ADDR1);
 	if( 0 == vdma1_prot_addr ) {
 		/* clear out beginning of streaming bit (rps register 0)*/
@@ -1069,6 +1070,16 @@
 		program_capture_engine(dev,0);
 	}
 
+/*
+	printk("vdma%d.base_even:     0x%08x\n", 1,saa7146_read(dev,BASE_EVEN1));
+	printk("vdma%d.base_odd:      0x%08x\n", 1,saa7146_read(dev,BASE_ODD1));
+	printk("vdma%d.prot_addr:     0x%08x\n", 1,saa7146_read(dev,PROT_ADDR1));
+	printk("vdma%d.base_page:     0x%08x\n", 1,saa7146_read(dev,BASE_PAGE1));
+	printk("vdma%d.pitch:         0x%08x\n", 1,saa7146_read(dev,PITCH1));
+	printk("vdma%d.num_line_byte: 0x%08x\n", 1,saa7146_read(dev,NUM_LINE_BYTE1));
+	printk("vdma%d => vptr      : 0x%08x\n", 1,saa7146_read(dev,PCI_VDP1));
+*/
+
 	/* write the address of the rps-program */
 	saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle);
 
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/common/saa7146_video.c linux-2.6.0-test5/drivers/media/common/saa7146_video.c
--- xx-linux-2.6.0-test5/drivers/media/common/saa7146_video.c	2003-09-10 11:29:20.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/common/saa7146_video.c	2003-08-26 22:30:46.000000000 +0200
@@ -169,6 +169,7 @@
 		struct saa7146_format *fmt;
 		enum v4l2_field field;
 		int maxw, maxh;
+		int calc_bpl;
 
 		DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n",dev,fh));
 
@@ -211,8 +212,18 @@
 			f->fmt.pix.width = maxw;
 		if (f->fmt.pix.height > maxh)
 			f->fmt.pix.height = maxh;
-		f->fmt.pix.sizeimage =
-			(f->fmt.pix.width * f->fmt.pix.height * fmt->depth)/8;
+
+		calc_bpl = (f->fmt.pix.width * fmt->depth)/8;
+
+		if (f->fmt.pix.bytesperline < calc_bpl)
+			f->fmt.pix.bytesperline = calc_bpl;
+			
+		if (f->fmt.pix.bytesperline > (2*PAGE_SIZE * fmt->depth)/8) /* arbitrary constraint */
+			f->fmt.pix.bytesperline = calc_bpl;
+			
+		f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * f->fmt.pix.height;
+		DEB_D(("w:%d, h:%d, bytesperline:%d, sizeimage:%d\n",f->fmt.pix.width,f->fmt.pix.height,f->fmt.pix.bytesperline,f->fmt.pix.sizeimage));
+
 		return 0;
 	}
 	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
@@ -359,41 +370,41 @@
 
 static struct v4l2_queryctrl controls[] = {
 	{
-		.id            = V4L2_CID_BRIGHTNESS,
-		.name          = "Brightness",
-		.minimum       = 0,
-		.maximum       = 255,
-		.step          = 1,
-		.default_value = 128,
-		.type          = V4L2_CTRL_TYPE_INTEGER,
+		id:            V4L2_CID_BRIGHTNESS,
+		name:          "Brightness",
+		minimum:       0,
+		maximum:       255,
+		step:          1,
+		default_value: 128,
+		type:          V4L2_CTRL_TYPE_INTEGER,
 	},{
-		.id            = V4L2_CID_CONTRAST,
-		.name          = "Contrast",
-		.minimum       = 0,
-		.maximum       = 127,
-		.step          = 1,
-		.default_value = 64,
-		.type          = V4L2_CTRL_TYPE_INTEGER,
+		id:            V4L2_CID_CONTRAST,
+		name:          "Contrast",
+		minimum:       0,
+		maximum:       127,
+		step:          1,
+		default_value: 64,
+		type:          V4L2_CTRL_TYPE_INTEGER,
 	},{
-		.id            = V4L2_CID_SATURATION,
-		.name          = "Saturation",
-		.minimum       = 0,
-		.maximum       = 127,
-		.step          = 1,
-		.default_value = 64,
-		.type          = V4L2_CTRL_TYPE_INTEGER,
+		id:            V4L2_CID_SATURATION,
+		name:          "Saturation",
+		minimum:       0,
+		maximum:       127,
+		step:          1,
+		default_value: 64,
+		type:          V4L2_CTRL_TYPE_INTEGER,
 	},{
-		.id            = V4L2_CID_VFLIP,
-		.name          = "Vertical flip",
-		.minimum       = 0,
-		.maximum       = 1,
-		.type          = V4L2_CTRL_TYPE_BOOLEAN,
+		id:            V4L2_CID_VFLIP,
+		name:          "Vertical flip",
+		minimum:       0,
+		maximum:       1,
+		type:          V4L2_CTRL_TYPE_BOOLEAN,
 	},{
-		.id            = V4L2_CID_HFLIP,
-		.name          = "Horizontal flip",
-		.minimum       = 0,
-		.maximum       = 1,
-		.type          = V4L2_CTRL_TYPE_BOOLEAN,
+		id:            V4L2_CID_HFLIP,
+		name:          "Horizontal flip",
+		minimum:       0,
+		maximum:       1,
+		type:          V4L2_CTRL_TYPE_BOOLEAN,
 	},
 };
 static int NUM_CONTROLS = sizeof(controls)/sizeof(struct v4l2_queryctrl);
@@ -549,7 +560,7 @@
 	int length = buf->vb.dma.sglen;
 	struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
 
-	DEB_EE(("dev:%p, buf:%p\n",dev,buf));
+	DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length));
 
 	if( 0 != IS_PLANAR(sfmt->trans)) {
 		struct saa7146_pgtable *pt1 = &buf->pt[0];
@@ -729,6 +740,81 @@
 	return 0;
 }
 
+/* capturing to framebuffer */
+
+int overlay_reqbufs(struct saa7146_dev *dev, struct v4l2_requestbuffers *req)
+{
+/*	struct saa7146_fh *fh = file->private_data;
+
+	if (req->count > VIDEO_MAX_FRAME)
+		req->count = VIDEO_MAX_FRAME;
+
+	*size = fh->video_fmt.sizeimage;
+
+*/
+	return 0;
+}
+int overlay_querybuf(struct saa7146_dev *dev, struct v4l2_buffer *buf)
+{
+	return 0;
+}
+int overlay_qbuf(struct saa7146_dev *dev, struct v4l2_buffer *b)
+{
+/*	if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
+		DEB_D(("index %d out of bounds.\n",b->index));
+		goto -EINVAL;
+	}
+	
+	buf = q->bufs[b->index];
+	if (NULL == buf) {
+		printk("videobuf_qbuf: NULL == buf\n");
+		goto done;
+	}
+	if (0 == buf->baddr) {
+		printk("videobuf_qbuf: 0 == buf->baddr\n");
+		goto done;
+	}
+	if (buf->state == STATE_QUEUED ||
+	    buf->state == STATE_ACTIVE) {
+		printk("videobuf_qbuf: already queued or activated.\n");
+		goto done;
+	}
+
+	field = videobuf_next_field(q);
+	retval = q->ops->buf_prepare(file,buf,field);
+	if (0 != retval) {
+		printk("videobuf_qbuf: buf_prepare() failed.\n");
+		goto done;
+	}
+	
+	list_add_tail(&buf->stream,&q->stream);
+	if (q->streaming) {
+		spin_lock_irqsave(q->irqlock,flags);
+		q->ops->buf_queue(file,buf);
+		spin_unlock_irqrestore(q->irqlock,flags);
+	}
+	retval = 0;
+	
+ done:
+	up(&q->lock);
+	return retval;
+*/
+	return 0;
+}
+int overlay_dqbuf(struct saa7146_dev *dev, struct v4l2_buffer *buf)
+{
+	return 0;
+}
+int overlay_streamon(struct saa7146_dev *dev)
+{
+	return 0;
+}
+int overlay_streamoff(struct saa7146_dev *dev)
+{
+	return 0;
+}
+
+
 /*
  * This function is _not_ called directly, but from
  * video_generic_ioctl (and maybe others).  userspace
@@ -794,7 +880,7 @@
 		
                 strcpy(cap->driver, "saa7146 v4l2");
 		strlcpy(cap->card, dev->ext->name, sizeof(cap->card));
-		sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
+		sprintf(cap->bus_info,"PCI:%s",dev->pci->slot_name);
 		cap->version = SAA7146_VERSION_CODE;
 		cap->capabilities =
 			V4L2_CAP_VIDEO_CAPTURE |
@@ -884,8 +970,11 @@
 			
 		ctrl = ctrl_by_id(c->id);
 		if( NULL == ctrl ) {
+			return -EINVAL;
+/*
 			c->flags = V4L2_CTRL_FLAG_DISABLED;	
 			return 0;
+*/
 		}
 
 		DEB_EE(("VIDIOC_QUERYCTRL: id:%d\n",c->id));
@@ -1037,44 +1126,71 @@
 		return err;
 	}
 	case VIDIOC_REQBUFS: {
-		DEB_D(("VIDIOC_REQBUFS \n"));
-		return videobuf_reqbufs(file,q,arg);
+		struct v4l2_requestbuffers *req = arg;
+		DEB_D(("VIDIOC_REQBUFS, type:%d\n",req->type));
+/*
+		if( req->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+			return overlay_reqbufs(dev,req);
+		} 
+*/
+		return videobuf_reqbufs(file,q,req);
 	}
 	case VIDIOC_QUERYBUF: {
-		DEB_D(("VIDIOC_QUERYBUF \n"));
-		return videobuf_querybuf(q,arg);
+		struct v4l2_buffer *buf = arg;
+		DEB_D(("VIDIOC_QUERYBUF, type:%d, offset:%d\n",buf->type,buf->m.offset));
+/* 		if( buf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+			return overlay_querybuf(dev,buf);
+		} 
+ */		return videobuf_querybuf(q,buf);
 	}
 	case VIDIOC_QBUF: {
-		struct v4l2_buffer *b = arg;
+		struct v4l2_buffer *buf = arg;
 		int ret = 0;
-		ret = videobuf_qbuf(file,q,b);
-		DEB_D(("VIDIOC_QBUF: ret:%d, index:%d\n",ret,b->index));
+/* 		if( buf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+			return overlay_qbuf(dev,buf);
+		} 
+ */		ret = videobuf_qbuf(file,q,buf);
+		DEB_D(("VIDIOC_QBUF: ret:%d, index:%d\n",ret,buf->index));
 		return ret;
 	}
 	case VIDIOC_DQBUF: {
-		struct v4l2_buffer *b = arg;
+		struct v4l2_buffer *buf = arg;
 		int ret = 0;
-		ret = videobuf_dqbuf(file,q,b);
-		DEB_D(("VIDIOC_DQBUF: ret:%d, index:%d\n",ret,b->index));
+/* 		if( buf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+			return overlay_dqbuf(dev,buf);
+		} 
+ */		ret = videobuf_dqbuf(file,q,buf);
+		DEB_D(("VIDIOC_DQBUF: ret:%d, index:%d\n",ret,buf->index));
 		return ret;
 	}
 	case VIDIOC_STREAMON: {
-		DEB_D(("VIDIOC_STREAMON \n"));
+		int *type = arg;
+		DEB_D(("VIDIOC_STREAMON, type:%d\n",*type));
+
 		if( 0 != ops->capture_begin ) {
 			if( 0 != (err = ops->capture_begin(fh))) {
 				return err;
 			}
 		}
+/* 		if( *type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+			err = overlay_streamon(dev);
+		} else { */
 		err = videobuf_streamon(file,q);
+/* 		} */
 		return err;
 	}
 	case VIDIOC_STREAMOFF: {
-		DEB_D(("VIDIOC_STREAMOFF \n"));
+		int *type = arg;
+
+		DEB_D(("VIDIOC_STREAMOFF, type:%d\n",*type));
 		if( 0 != ops->capture_end ) {
 			ops->capture_end(fh);
 		}
-		err = videobuf_streamoff(file,q);
-		return 0;
+/* 		if( *type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+			return overlay_streamoff(dev);
+		} 
+ */		err = videobuf_streamoff(file,q);
+		return err;
 	}
 	case VIDIOCGMBUF:
 	{
@@ -1134,6 +1250,8 @@
 	struct saa7146_buf *buf = (struct saa7146_buf *)vb;
 	int size,err = 0;
 
+	DEB_CAP(("vbuf:%p\n",vb));
+
 	/* sanity checks */
 	if (fh->video_fmt.width  < 64 ||
 	    fh->video_fmt.height < 64 ||
@@ -1152,6 +1270,7 @@
 	DEB_CAP(("buffer_prepare [size=%dx%d,bytes=%d,fields=%s]\n",
 		fh->video_fmt.width,fh->video_fmt.height,size,v4l2_field_names[fh->video_fmt.field]));
 	if (buf->vb.width  != fh->video_fmt.width  ||
+	    buf->vb.bytesperline != fh->video_fmt.bytesperline ||
 	    buf->vb.height != fh->video_fmt.height ||
 	    buf->vb.size   != size ||
 	    buf->vb.field  != field      ||
@@ -1163,6 +1282,7 @@
 	if (STATE_NEEDS_INIT == buf->vb.state) {
 		struct saa7146_format *sfmt;
 		
+		buf->vb.bytesperline  = fh->video_fmt.bytesperline;
 		buf->vb.width  = fh->video_fmt.width;
 		buf->vb.height = fh->video_fmt.height;
 		buf->vb.size   = size;
@@ -1280,6 +1400,7 @@
 	fh->video_fmt.width = 384;
 	fh->video_fmt.height = 288;
 	fh->video_fmt.pixelformat = V4L2_PIX_FMT_BGR24;
+	fh->video_fmt.bytesperline = 0;
 	fh->video_fmt.field = V4L2_FIELD_ANY;
 	sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
 	fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8;


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 5/14] multiple device *read* opens support
  2003-10-08 13:28     ` [PATCH 4/14] video capture updates for saa7146 core Michael Hunold
@ 2003-10-08 13:28       ` Michael Hunold
  2003-10-08 13:28         ` [PATCH 6/14] update copyright and licensing Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] allow multiple read device opens
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h	2003-08-25 12:16:12.000000000 +0200
@@ -55,12 +58,18 @@
 struct dvb_device {
 	struct list_head list_head;
 	struct file_operations *fops;
+ 
+ 
+ 
 	struct dvb_adapter *adapter;
 	int type;
 	u32 id;
 
-	int users;
+	/* in theory, 'users' can vanish now,
+	   but I don't want to change too much now... */
+	int readers;
 	int writers;
+	int users;
 
         /* don't really need those !? -- FIXME: use video_usercopy  */
         int (*kernel_ioctl)(struct inode *inode, struct file *file,
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.c linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.c	2003-09-10 11:29:20.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.c	2003-08-21 10:53:19.000000000 +0200
@@ -112,7 +121,11 @@
 	if (!dvbdev->users)
                 return -EBUSY;
 
-	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
+	if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
+                if (!dvbdev->readers)
+		        return -EBUSY;
+		dvbdev->readers--;
+	} else {
                 if (!dvbdev->writers)
 		        return -EBUSY;
 		dvbdev->writers--;
@@ -130,8 +143,11 @@
 	if (!dvbdev)
                 return -ENODEV;
 
-	if ((file->f_flags & O_ACCMODE) != O_RDONLY)
+	if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
+		dvbdev->readers++;
+	} else {
 		dvbdev->writers++;
+	}
 
 	dvbdev->users++;
 	return 0;
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.c linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.c	2003-09-10 11:28:54.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.c	2003-09-09 09:24:21.000000000 +0200
@@ -870,6 +886,7 @@
 	static const struct dvb_device dvbdev_template = {
 		.users = ~0,
 		.writers = 1,
+		.readers = (~0)-1,
 		.fops = &dvb_frontend_fops,
 		.kernel_ioctl = dvb_frontend_ioctl
 	};



^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 6/14] update copyright and licensing
  2003-10-08 13:28       ` [PATCH 5/14] multiple device *read* opens support Michael Hunold
@ 2003-10-08 13:28         ` Michael Hunold
  2003-10-08 13:28           ` [PATCH 7/14] usual c99 initializer fixes Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] - fix copyright stuff in various files:
  - remove e-mail addresses that don't exist anymore, but of course keep the names
  - change license from GPL to LGPL in dvb_i2c.h (Convergence code)
  - change license from GPL to LGPL in dvb_ringbuffer.h (ack by original author Oliver Endriss)
  - add LGPL license to dvb_functions
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/demux.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/demux.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/demux.h	2003-07-14 05:32:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/demux.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,4 +1,5 @@
-/* demux.h 
+/* 
+ * demux.h 
  *
  * Copyright (c) 2002 Convergence GmbH
  * 
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dmxdev.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dmxdev.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dmxdev.h	2003-07-14 05:39:29.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dmxdev.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,9 +1,8 @@
 /* 
  * dmxdev.h
  *
- * Copyright (C) 2000 Ralph  Metzler <ralph@convergence.de>
- *                  & Marcus Metzler <marcus@convergence.de>
-                      for convergence integrated media GmbH
+ * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
+ *                    for convergence integrated media GmbH
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvbdev.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,9 +1,8 @@
 /* 
  * dvbdev.h
  *
- * Copyright (C) 2000 Ralph  Metzler <ralph@convergence.de>
- *                  & Marcus Metzler <marcus@convergence.de>
-                      for convergence integrated media GmbH
+ * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
+ *                    for convergence integrated media GmbH
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Lesser Public License
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_ringbuffer.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_ringbuffer.h	2003-07-14 05:39:26.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_ringbuffer.h	2003-08-25 12:16:12.000000000 +0200
@@ -5,28 +5,22 @@
  * Copyright (C) 2003 Oliver Endriss 
  * 
  * based on code originally found in av7110.c:
- * Copyright (C) 1999-2002 Ralph  Metzler 
- *                       & Marcus Metzler for convergence integrated media GmbH
+ * Copyright (C) 1999-2002 Ralph Metzler & Marcus Metzler
+ *                         for convergence integrated media GmbH
  *
  * 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
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
  * 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
+ * You should have received a copy of the GNU Lesser General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- * 
- *
- * the project's page is at http://www.linuxtv.org/dvb/
  */
 
 #ifndef _DVB_RINGBUFFER_H_
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_net.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_net.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_net.h	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_net.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,8 +1,7 @@
 /* 
  * dvb_net.h
  *
- * Copyright (C) 2001 Convergence integrated media GmbH
- *                    Ralph Metzler <ralph@convergence.de>
+ * Copyright (C) 2001 Ralph Metzler for convergence integrated media GmbH
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_i2c.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_i2c.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_i2c.h	2003-07-14 05:31:51.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_i2c.h	2003-08-25 12:16:12.000000000 +0200
@@ -4,8 +4,8 @@
  * Copyright (C) 2002 Holger Waechtler for convergence integrated media GmbH
  *
  * 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
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
  * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,10 +13,9 @@
  * 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
+ * You should have received a copy of the GNU Lesser General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
  */
 
 #ifndef _DVB_I2C_H_
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_functions.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_functions.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_functions.h	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_functions.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,3 +1,26 @@
+/* 
+ * dvb_functions.h: isolate some Linux specific stuff from the dvb-core
+ *                  that can't be expressed as a one-liner
+ *                  in order to make porting to other environments easier
+ *
+ * Copyright (C) 2003 Convergence GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Lesser Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * 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 Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
 #ifndef __DVB_FUNCTIONS_H__
 #define __DVB_FUNCTIONS_H__
 
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_demux.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_demux.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_demux.h	2003-07-14 05:32:44.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_demux.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,8 +1,7 @@
 /* 
- * dvb_demux.h - DVB kernel demux API
+ * dvb_demux.h: DVB kernel demux API
  *
- * Copyright (C) 2000-2001 Marcus Metzler <marcus@convergence.de>
- *                       & Ralph  Metzler <ralph@convergence.de>
+ * Copyright (C) 2000-2001 Marcus Metzler & Ralph Metzler
  *                         for convergence integrated media GmbH
  *
  * This program is free software; you can redistribute it and/or
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_filter.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_filter.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_filter.h	2003-07-14 05:31:51.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_filter.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,3 +1,23 @@
+/*
+ * dvb_filter.h
+ *
+ * Copyright (C) 2003 Convergence GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * 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 Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
 #ifndef _DVB_FILTER_H_
 #define _DVB_FILTER_H_
 
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.h linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.h
--- xx-linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.h	2003-07-14 05:38:37.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/dvb-core/dvb_frontend.h	2003-08-25 12:16:12.000000000 +0200
@@ -1,9 +1,9 @@
 /* 
- * dvb-core.h
+ * dvb_frontend.h
+ *
+ * Copyright (C) 2001 Ralph Metzler for convergence integrated media GmbH
+ *                    overhauled by Holger Waechtler for Convergence GmbH
  *
- * Copyright (C) 2001 Ralph  Metzler <ralph@convergence.de>
- *                    overhauled by Holger Waechtler <holger@convergence.de>
- *                    for convergence integrated media GmbH
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 7/14] usual c99 initializer fixes
  2003-10-08 13:28         ` [PATCH 6/14] update copyright and licensing Michael Hunold
@ 2003-10-08 13:28           ` Michael Hunold
  2003-10-08 13:28             ` [PATCH 8/14] various patches for non-av7110 dvb-drivers Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] the usual c99 initialization fixes all over the DVB place
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c	2003-09-10 10:58:29.000000000 +0200
@@ -2608,8 +2615,23 @@
  ****************************************************************************/
 
 static struct v4l2_input inputs[2] = {
-	{ 0,	"DVB",		V4L2_INPUT_TYPE_CAMERA,	1, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 
-	{ 1,	"ANALOG",	V4L2_INPUT_TYPE_TUNER,	2, 1, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+	{	
+		.index 		= 0,
+		.name 		= "DVB",
+		.type		= V4L2_INPUT_TYPE_CAMERA,
+		.audioset 	= 1,
+		.tuner		= 0, /* ignored */
+		.std		= V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
+		.status		= 0,
+	}, { 
+		.index 		= 1,
+		.name 		= "ANALOG",
+		.type		= V4L2_INPUT_TYPE_TUNER,
+		.audioset 	= 2,
+		.tuner		= 0,
+		.std		= V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
+		.status		= 0,
+	}
 };
 
 /* taken from ves1820.c */
@@ -4629,19 +4673,45 @@
 /* FIXME: these values are experimental values that look better than the
    values from the latest "official" driver -- at least for me... (MiHu) */
 static struct saa7146_standard standard[] = {
-	{ "PAL", V4L2_STD_PAL, 0x15, 288, 576, 0x4a, 708, 709, 576, 768 },
-//	{ "PAL", V4L2_STD_PAL, 0x15, 288, 576, 0x3a, 720, 721, 576, 768 },
-	{ "NTSC", V4L2_STD_NTSC, 0x10, 244, 480, 0x40, 708, 709, 480, 640 },
+	{
+		.name	= "PAL", 	.id		= V4L2_STD_PAL_BG,
+		.v_offset	= 0x15,	.v_field 	= 288,		.v_calc	= 576,
+		.h_offset	= 0x4a,	.h_pixels 	= 708,		.h_calc	= 709,
+		.v_max_out	= 576,	.h_max_out	= 768,
+	}, {
+		.name	= "NTSC", 	.id		= V4L2_STD_NTSC,
+		.v_offset	= 0x10,	.v_field 	= 244,		.v_calc	= 480,
+		.h_offset	= 0x40,	.h_pixels 	= 708,		.h_calc	= 709,
+		.v_max_out	= 480,	.h_max_out	= 640,
+	}
 };
 
 static struct saa7146_standard analog_standard[] = {
-	{ "PAL", V4L2_STD_PAL, 0x18, 288, 576, 0x08, 708, 709, 576, 768 },
-	{ "NTSC", V4L2_STD_NTSC, 0x10, 244, 480, 0x40, 708, 709, 480, 640 },
+	{
+		.name	= "PAL", 	.id		= V4L2_STD_PAL_BG,
+		.v_offset	= 0x18,	.v_field 	= 288,		.v_calc	= 576,
+		.h_offset	= 0x08,	.h_pixels 	= 708,		.h_calc	= 709,
+		.v_max_out	= 576,	.h_max_out	= 768,
+	}, {
+		.name	= "NTSC", 	.id		= V4L2_STD_NTSC,
+		.v_offset	= 0x10,	.v_field 	= 244,		.v_calc	= 480,
+		.h_offset	= 0x40,	.h_pixels 	= 708,		.h_calc	= 709,
+		.v_max_out	= 480,	.h_max_out	= 640,
+	}
 };
 
 static struct saa7146_standard dvb_standard[] = {
-	{ "PAL", V4L2_STD_PAL, 0x14, 288, 576, 0x4a, 708, 709, 576, 768 },
-	{ "NTSC", V4L2_STD_NTSC, 0x10, 244, 480, 0x40, 708, 709, 480, 640 },
+	{
+		.name	= "PAL", 	.id		= V4L2_STD_PAL_BG,
+		.v_offset	= 0x14,	.v_field 	= 288,		.v_calc	= 576,
+		.h_offset	= 0x4a,	.h_pixels 	= 708,		.h_calc	= 709,
+		.v_max_out	= 576,	.h_max_out	= 768,
+	}, {
+		.name	= "NTSC", 	.id		= V4L2_STD_NTSC,
+		.v_offset	= 0x10,	.v_field 	= 244,		.v_calc	= 480,
+		.h_offset	= 0x40,	.h_pixels 	= 708,		.h_calc	= 709,
+		.v_max_out	= 480,	.h_max_out	= 640,
+	}
 };
 
 static struct saa7146_extension av7110_extension;


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 9/14] various av7110 dvb-driver updates
  2003-10-08 13:28             ` [PATCH 8/14] various patches for non-av7110 dvb-drivers Michael Hunold
@ 2003-10-08 13:28               ` Michael Hunold
  2003-10-08 13:28                 ` [PATCH 10/14] update dvb frontend drivers Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

Sorry: have a look at patch 12 for details!
-[DVB] various av7110 updates
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/ttpci/av7110.c	2003-09-10 10:58:29.000000000 +0200
@@ -40,9 +40,9 @@
 #include <linux/delay.h>
 #include <linux/fs.h>
 #include <linux/timer.h>
+#include <linux/poll.h>
 #include <linux/unistd.h>
 #include <linux/byteorder/swabb.h>
-#include <linux/poll.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <stdarg.h>
@@ -196,17 +197,22 @@
 	return result;
 }
 
-/* DEBI during interrupt */
 
-/* fixme: val can be a pointer to a memory or an u32 value -- this 
-   won't work on 64bit platforms! */
+/* DEBI during interrupt */
+/* single word writes */
 static inline void iwdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count)
 {
-        if (count>4 && val)
-                memcpy(av7110->debi_virt, (char *) val, count);
         debiwrite(av7110, config, addr, val, count);
 }
 
+/* buffer writes */
+static inline void mwdebi(struct av7110 *av7110, u32 config, int addr, char *val, int count)
+{
+	memcpy(av7110->debi_virt, val, count);
+        debiwrite(av7110, config, addr, 0, count);
+}
+
+
 static inline u32 irdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count)
 {
         u32 res;
@@ -1915,8 +1922,8 @@
                 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0)
                         return -1;
                 DEB_D(("Writing DRAM block %d\n",i));
-                iwdebi(av7110, DEBISWAB, bootblock,
-                       i*(BOOT_MAX_SIZE)+(u32)data,
+                mwdebi(av7110, DEBISWAB, bootblock,
+                       ((char*)data) + i*(BOOT_MAX_SIZE),
                        BOOT_MAX_SIZE);
                 bootblock^=0x1400;
                 iwdebi(av7110, DEBISWAB, BOOT_BASE, swab32(base), 4);
@@ -1929,9 +1936,9 @@
                 if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0)
                         return -1;
                 if (rest>4)
-                        iwdebi(av7110, DEBISWAB, bootblock, i*(BOOT_MAX_SIZE)+(u32)data, rest);
+                        mwdebi(av7110, DEBISWAB, bootblock, ((char*)data) + i*(BOOT_MAX_SIZE), rest);
                 else
-                        iwdebi(av7110, DEBISWAB, bootblock, i*(BOOT_MAX_SIZE)-4+(u32)data, rest+4);
+                        mwdebi(av7110, DEBISWAB, bootblock, ((char*)data) + i*(BOOT_MAX_SIZE) - 4, rest+4);
                 
                 iwdebi(av7110, DEBISWAB, BOOT_BASE, swab32(base), 4);
                 iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, rest, 2);
@@ -2015,7 +2022,7 @@
         //saa7146_setgpio(dev, DEBI_DONE_LINE, SAA7146_GPIO_INPUT);
         //saa7146_setgpio(dev, 3, SAA7146_GPIO_INPUT);
 
-        iwdebi(av7110, DEBISWAB, DPRAM_BASE, (u32) bootcode, sizeof(bootcode));
+	mwdebi(av7110, DEBISWAB, DPRAM_BASE, bootcode, sizeof(bootcode));
         iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
         
         wait_for_debi_done(av7110);
@@ -2033,7 +2040,7 @@
         
         DEB_D(("bootarm: load dpram code\n"));
 
-	iwdebi(av7110, DEBISWAB, DPRAM_BASE, (u32) Dpram, sizeof(Dpram));
+	mwdebi(av7110, DEBISWAB, DPRAM_BASE, Dpram, sizeof(Dpram));
 
 	wait_for_debi_done(av7110);
 
@@ -2742,7 +2764,7 @@
 
 		DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index));
 
-		if( 0 == av7110->has_analog_tuner || av7110->current_input != 1 ) {
+		if( 0 == av7110->has_analog_tuner || t->index != 0 ) {
 			return -EINVAL;
 		}
 
@@ -3257,7 +3279,7 @@
 	DEB_EE(("av7110: fwstc = %04hx %04hx %04hx %04hx\n",
 			fwstc[0], fwstc[1], fwstc[2], fwstc[3]));
 
-	*stc =  (((uint64_t)(~fwstc[2]) & 1) << 32) |
+	*stc =  (((uint64_t) ((fwstc[3] & 0x8000) >> 15)) << 32) |
 		(((uint64_t)fwstc[1])     << 16) | ((uint64_t)fwstc[0]);
 	*base = 1;
 
@@ -3630,17 +3652,22 @@
 
 	DEB_EE(("av7110: %p\n",av7110));
 
+	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
 	poll_wait(file, &av7110->avout.queue, wait);
+	}
+	
 	poll_wait(file, &av7110->video_events.wait_queue, wait);
 
 	if (av7110->video_events.eventw != av7110->video_events.eventr)
 		mask = POLLPRI;
 
+	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
 	if (av7110->playing) {
                 if (FREE_COND)
                         mask |= (POLLOUT | POLLWRNORM);
         } else /* if not playing: may play if asked for */
                 mask |= (POLLOUT | POLLWRNORM);
+	}
 
         return mask;
 }
@@ -3653,6 +3680,10 @@
 
 	DEB_EE(("av7110: %p\n",av7110));
 
+	if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
+		return -EPERM;
+	}
+
         if (av7110->videostate.stream_source!=VIDEO_SOURCE_MEMORY) 
                 return -EPERM;
 
@@ -3690,6 +3721,10 @@
                 n=MIN_IFRAME/len+1;
         }
 
+	/* setting n always > 1, fixes problems when playing stillframes
+	   consisting of I- and P-Frames */
+	n=MIN_IFRAME/len+1;
+	
 	/* FIXME: nonblock? */
 	dvb_play(av7110, iframe_header, sizeof(iframe_header), 0, 1, 0);
 
@@ -3711,9 +3746,12 @@
         
 	DEB_EE(("av7110: %p\n",av7110));
 
-        if (((file->f_flags&O_ACCMODE)==O_RDONLY) &&
-            (cmd!=VIDEO_GET_STATUS))
+        if ((file->f_flags&O_ACCMODE)==O_RDONLY) {
+		if ( cmd!=VIDEO_GET_STATUS && cmd!=VIDEO_GET_EVENT && 
+		     cmd!=VIDEO_GET_SIZE ) {
                 return -EPERM;
+		}
+	}
         
         switch (cmd) {
         case VIDEO_STOP:
@@ -4027,15 +4065,17 @@
 
         if ((err=dvb_generic_open(inode, file))<0)
                 return err;
+
+	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
         dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
         dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
         av7110->video_blank=1;
         av7110->audiostate.AV_sync_state=1;
         av7110->videostate.stream_source=VIDEO_SOURCE_DEMUX;
 
-	if ((file->f_flags & O_ACCMODE) != O_RDONLY)
 		/*  empty event queue */
 		av7110->video_events.eventr = av7110->video_events.eventw = 0;
+	}
 
         return 0;
 }
@@ -4047,7 +4087,10 @@
 
 	DEB_EE(("av7110: %p\n",av7110));
 
+	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
         AV_Stop(av7110, RP_VIDEO);
+	}
+
         return dvb_generic_release(inode, file);
 }
 
@@ -4094,7 +4137,8 @@
 
 static struct dvb_device dvbdev_video = {
 	.priv		= 0,
-	.users		= 1,
+	.users		= 6,
+	.readers	= 5,	/* arbitrary */
 	.writers	= 1,
 	.fops		= &dvb_video_fops,
 	.kernel_ioctl	= dvb_video_ioctl,
@@ -4660,6 +4730,7 @@
 MAKE_AV7110_INFO(unkwn1, "Technotrend/Hauppauge PCI rev?(unknown1)?");
 MAKE_AV7110_INFO(unkwn2, "Technotrend/Hauppauge PCI rev?(unknown2)?");
 MAKE_AV7110_INFO(nexus,  "Technotrend/Hauppauge Nexus PCI DVB-S");
+MAKE_AV7110_INFO(dvboc11,"Octal/Technotrend DVB-C for iTV");
 
 static struct pci_device_id pci_tbl[] = {
 	MAKE_EXTENSION_PCI(fs_1_5, 0x110a, 0xffff),
@@ -4676,6 +4747,7 @@
 	MAKE_EXTENSION_PCI(unkwn1, 0xffc2, 0x0000),
 	MAKE_EXTENSION_PCI(unkwn2, 0x00a1, 0x00a1),
 	MAKE_EXTENSION_PCI(nexus,  0x00a1, 0xa1a0),
+	MAKE_EXTENSION_PCI(dvboc11,0x13c2, 0x000a),
 	{
 		.vendor    = 0,
 	}


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 8/14] various patches for non-av7110 dvb-drivers
  2003-10-08 13:28           ` [PATCH 7/14] usual c99 initializer fixes Michael Hunold
@ 2003-10-08 13:28             ` Michael Hunold
  2003-10-08 13:28               ` [PATCH 9/14] various av7110 dvb-driver updates Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] patch by Jon Burgess to fix DMA issues
- [DVB] reduce the number of dropped TS packets when an error is detected (Jon Burgess)
- [DVB] use budget-ci driver for new TT DVB-T cards with onboard MSP430.
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-ci.c linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-ci.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-ci.c	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-ci.c	2003-09-09 09:24:21.000000000 +0200
@@ -357,10 +363,12 @@
 static struct saa7146_extension budget_extension; 
 
 MAKE_BUDGET_INFO(ttbci,	"TT-Budget/WinTV-NOVA-CI PCI",	BUDGET_TT_HW_DISEQC);
+MAKE_BUDGET_INFO(ttbt2,	"TT-Budget/WinTV-NOVA-T  PCI",	BUDGET_TT);
 
 static struct pci_device_id pci_tbl[] = {
 	MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c),
 	MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f),
+	MAKE_EXTENSION_PCI(ttbt2,  0x13c2, 0x1011),
 	{
 		.vendor    = 0,
 	}
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-core.c linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-core.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-core.c	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/ttpci/budget-core.c	2003-09-09 09:24:21.000000000 +0200
@@ -46,12 +46,12 @@
         mdelay(10);
 
         saa7146_write(dev, BASE_ODD3, 0);
-        saa7146_write(dev, BASE_EVEN3, TS_WIDTH*TS_HEIGHT/2);
+        saa7146_write(dev, BASE_EVEN3, 0);
         saa7146_write(dev, PROT_ADDR3, TS_WIDTH*TS_HEIGHT);	
         saa7146_write(dev, BASE_PAGE3, budget->pt.dma |ME1|0x90);
         saa7146_write(dev, PITCH3, TS_WIDTH);
 
-        saa7146_write(dev, NUM_LINE_BYTE3, ((TS_HEIGHT/2)<<16)|TS_WIDTH);
+        saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT<<16)|TS_WIDTH);
       	saa7146_write(dev, MC2, (MASK_04 | MASK_20));
      	saa7146_write(dev, MC1, (MASK_04 | MASK_20)); // DMA3 on
 
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/budget.c linux-2.6.0-test5/drivers/media/dvb/ttpci/budget.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/ttpci/budget.c	2003-09-10 11:28:41.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/ttpci/budget.c	2003-09-09 09:24:21.000000000 +0200
@@ -192,7 +192,6 @@
 MAKE_BUDGET_INFO(ttbs,	"TT-Budget/WinTV-NOVA-S  PCI",	BUDGET_TT);
 MAKE_BUDGET_INFO(ttbc,	"TT-Budget/WinTV-NOVA-C  PCI",	BUDGET_TT);
 MAKE_BUDGET_INFO(ttbt,	"TT-Budget/WinTV-NOVA-T  PCI",	BUDGET_TT);
-MAKE_BUDGET_INFO(ttbt2,	"TT-Budget/WinTV-NOVA-T  PCI",	BUDGET_TT);
 MAKE_BUDGET_INFO(satel,	"SATELCO Multimedia PCI",	BUDGET_TT_HW_DISEQC);
 /* Uncomment for Budget Patch */
 /*MAKE_BUDGET_INFO(fs_1_3,"Siemens/Technotrend/Hauppauge PCI rev1.3+Budget_Patch", BUDGET_PATCH);*/
@@ -203,7 +202,6 @@
 	MAKE_EXTENSION_PCI(ttbs,  0x13c2, 0x1003),
 	MAKE_EXTENSION_PCI(ttbc,  0x13c2, 0x1004),
 	MAKE_EXTENSION_PCI(ttbt,  0x13c2, 0x1005),
-	MAKE_EXTENSION_PCI(ttbt2,  0x13c2, 0x1011),	
 	MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
 	{
 		.vendor    = 0,



^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 10/14] update dvb frontend drivers
  2003-10-08 13:28               ` [PATCH 9/14] various av7110 dvb-driver updates Michael Hunold
@ 2003-10-08 13:28                 ` Michael Hunold
  2003-10-08 13:28                   ` [PATCH 11/14] Kconfig and Makefile updates, inspired by Adrian Bunk and Roman Zippel Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] add budget driver as possible client of the ves1820 frontend driver
- [DVB] fix wrong include in sp887x.c frontend driver
- [DVB] fix wrong chip description in tda1004xh  frontend driver
- [DVB] fixed detection of stv0299 if chip is in standby mode
- [DVB] change some #ifdef to #if, for easier debug enable/disable
- [DVB] ves1820: patch by Peter Bieringer: nicer log output
- [DVB] ves1820: allow PWM (tuner calibaration) value from EEPROM to be overridden on command line (based on patch by Peter Bieringer). New module paramters: "pwm" (max 4 ints, range -1..0xff) and "verbose" (to print AFC value aftger tuning).
diff -uNrwB --new-file xx-linux-2.6.0-test5/drivers/media/dvb/frontends/ves1820.c linux-2.6.0-test5/drivers/media/dvb/frontends/ves1820.c
--- xx-linux-2.6.0-test5/drivers/media/dvb/frontends/ves1820.c	2003-09-10 11:29:20.000000000 +0200
+++ linux-2.6.0-test5/drivers/media/dvb/frontends/ves1820.c	2003-08-25 12:16:12.000000000 +0200
@@ -173,7 +173,8 @@
 	if (tuner_type == 0xff)     /*  PLL not reachable over i2c ...  */
 		return 0;
 
-	if (strstr (fe->i2c->adapter->name, "Technotrend"))
+	if (strstr (fe->i2c->adapter->name, "Technotrend") ||
+	    strstr (fe->i2c->adapter->name, "TT-Budget"))
 		ifreq = 35937500;
 	else
 		ifreq = 36125000;
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/frontends/sp887x.c linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/sp887x.c
--- linux-2.6.0-test6/drivers/media/dvb/frontends/sp887x.c	2003-10-01 12:25:24.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/sp887x.c	2003-09-16 10:01:00.000000000 +0200
@@ -4,7 +4,7 @@
 #include <linux/i2c.h>
 
 #include "dvb_frontend.h"
-#include "dvb_compat.h"
+#include "dvb_functions.h"
 
 
 #if 0
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/frontends/tda1004x.c linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/tda1004x.c
--- linux-2.6.0-test6/drivers/media/dvb/frontends/tda1004x.c	2003-10-01 12:20:37.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/tda1004x.c	2003-09-10 11:59:54.000000000 +0200
@@ -1,5 +1,5 @@
   /*
-     Driver for Philips tda1004x OFDM Frontend
+     Driver for Philips tda1004xh OFDM Frontend
 
      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
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/frontends/stv0299.c linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/stv0299.c
--- linux-2.6.0-test6/drivers/media/dvb/frontends/stv0299.c	2003-10-01 12:20:37.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/stv0299.c	2003-09-29 16:04:08.000000000 +0200
@@ -913,7 +913,10 @@
 static int uni0299_attach (struct dvb_i2c_bus *i2c)
 {
         long tuner_type;
-	u8 id = stv0299_readreg (i2c, 0x00);
+	u8 id;
+ 
+	stv0299_writereg (i2c, 0x02, 0x00); /* standby off */
+	id = stv0299_readreg (i2c, 0x00);
 
 	dprintk ("%s: id == 0x%02x\n", __FUNCTION__, id);
 
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/frontends/mt312.c linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/mt312.c
--- linux-2.6.0-test6/drivers/media/dvb/frontends/mt312.c	2003-10-01 12:20:37.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/mt312.c	2003-09-16 10:01:00.000000000 +0200
@@ -85,7 +85,7 @@
 		printk(KERN_ERR "%s: ret == %d\n", __FUNCTION__, ret);
 		return -EREMOTEIO;
 	}
-#ifdef MT312_DEBUG
+#if MT312_DEBUG
 	{
 		int i;
 		printk(KERN_INFO "R(%d):", reg & 0x7f);
@@ -106,7 +106,7 @@
 	u8 buf[count + 1];
 	struct i2c_msg msg;
 
-#ifdef MT312_DEBUG
+#if MT312_DEBUG
 	{
 		int i;
 		printk(KERN_INFO "W(%d):", reg & 0x7f);
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/frontends/ves1820.c linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/ves1820.c
--- linux-2.6.0-test6/drivers/media/dvb/frontends/ves1820.c	2003-10-01 12:25:36.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/ves1820.c	2003-10-01 13:01:43.000000000 +0200
@@ -36,6 +36,9 @@
 #define dprintk(x...)
 #endif
 
+#define MAX_UNITS 4
+static int pwm[MAX_UNITS] = { -1, -1, -1, -1 };
+static int verbose;
 
 /**
  *  since we need only a few bits to store internal state we don't allocate
@@ -116,9 +119,9 @@
 	ret = i2c->xfer (i2c, &msg, 1);
 
 	if (ret != 1)
-		dprintk("%s: writereg error "
+		printk("DVB: VES1820(%d): %s, writereg error "
 			"(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
-			__FUNCTION__, reg, data, ret);
+			fe->i2c->adapter->num, __FUNCTION__, reg, data, ret);
 
 	dvb_delay(10);
 	return (ret != 1) ? -EREMOTEIO : 0;
@@ -138,7 +141,8 @@
 	ret = i2c->xfer (i2c, msg, 2);
 
 	if (ret != 2)
-		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+		printk("DVB: VES1820(%d): %s: readreg error (ret == %i)\n",
+				fe->i2c->adapter->num, __FUNCTION__, ret);
 
 	return b1[0];
 }
@@ -152,7 +156,8 @@
         ret = i2c->xfer (i2c, &msg, 1);
 
         if (ret != 1)
-                printk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
+                printk("DVB: VES1820(%d): %s: i/o error (ret == %i)\n",
+				i2c->adapter->num, __FUNCTION__, ret);
 
         return (ret != 1) ? -EREMOTEIO : 0;
 }
@@ -233,7 +238,7 @@
 {
 	int i;
         
-        dprintk("VES1820: init chip\n");
+        dprintk("DVB: VES1820(%d): init chip\n", fe->i2c->adapter->num);
 
         ves1820_writereg (fe, 0, 0);
 
@@ -409,10 +414,11 @@
 		if (sync & 2)
 			/* AFC only valid when carrier has been recovered */
 			afc = ves1820_readreg(fe, 0x19);
-		printk ("%s: AFC (%d) %dHz\n", __FILE__, afc,
+		if (verbose)
+			printk ("DVB: VES1820(%d): AFC (%d) %dHz\n",
+					fe->i2c->adapter->num, afc,
 				-((s32)(p->u.qam.symbol_rate >> 3) * afc >> 7));
 
-
 		p->inversion = reg0 & 0x20 ? INVERSION_OFF : INVERSION_ON;
 		p->u.qam.modulation = ((reg0 >> 2) & 7) + QAM_16;
 
@@ -450,15 +456,14 @@
 
 	if (i2c->xfer(i2c, &msg1, 1) == 1) {
 		type = 0;
-		printk ("%s: setup for tuner spXXXX\n", __FILE__);
+		printk ("DVB: VES1820(%d): setup for tuner spXXXX\n", i2c->adapter->num);
 	} else if (i2c->xfer(i2c, &msg2, 1) == 1) {
 		type = 1;
-		printk ("%s: setup for tuner sp5659c\n", __FILE__);
+		printk ("DVB: VES1820(%d): setup for tuner sp5659c\n", i2c->adapter->num);
 	} else {
 		type = -1;
-		printk ("%s: unknown PLL, "
-			"please report to <linuxdvb@linuxtv.org>!!\n",
-			__FILE__);
+		printk ("DVB: VES1820(%d): unknown PLL, "
+			"please report to <linuxdvb@linuxtv.org>!!\n", i2c->adapter->num);
 	}
 
 	return type;
@@ -474,7 +479,7 @@
 
 	i2c->xfer (i2c, msg, 2);
 
-	dprintk("VES1820: pwm=%02x\n", pwm);
+	printk("DVB: VES1820(%d): pwm=0x%02x\n", i2c->adapter->num, pwm);
 
 	if (pwm == 0xff)
 		pwm = 0x48;
@@ -514,6 +519,12 @@
 	if ((tuner_type = probe_tuner(i2c)) < 0)
 		return -ENODEV;
 
+	if ((i2c->adapter->num < MAX_UNITS) && pwm[i2c->adapter->num] != -1) {
+		printk("DVB: VES1820(%d): pwm=0x%02x (user specified)\n",
+				i2c->adapter->num, pwm[i2c->adapter->num]);
+		SET_PWM(data, pwm[i2c->adapter->num]);
+	}
+	else
 	SET_PWM(data, read_pwm(i2c));
 	SET_REG0(data, ves1820_inittab[0]);
 	SET_TUNER(data, tuner_type);
@@ -533,6 +544,10 @@
 
 static int __init init_ves1820 (void)
 {
+	int i;
+	for (i = 0; i < MAX_UNITS; i++)
+		if (pwm[i] < -1 || pwm[i] > 255)
+			return -EINVAL;
 	return dvb_register_i2c_device (THIS_MODULE,
 					ves1820_attach, ves1820_detach);
 }
@@ -547,6 +562,11 @@
 module_init(init_ves1820);
 module_exit(exit_ves1820);
 
+MODULE_PARM(pwm, "1-" __MODULE_STRING(MAX_UNITS) "i");
+MODULE_PARM_DESC(pwm, "override PWM value stored in EEPROM (tuner calibration)");
+MODULE_PARM(verbose, "i");
+MODULE_PARM_DESC(verbose, "print AFC offset after tuning for debugging the PWM setting");
+
 MODULE_DESCRIPTION("VES1820 DVB-C frontend driver");
 MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
 MODULE_LICENSE("GPL");


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 12/14] some more av7110 dvb-driver updates
  2003-10-08 13:28                   ` [PATCH 11/14] Kconfig and Makefile updates, inspired by Adrian Bunk and Roman Zippel Michael Hunold
@ 2003-10-08 13:28                     ` Michael Hunold
  2003-10-08 13:29                       ` [PATCH 13/14] fix v4l1 backward compatibility in saa7146 driver Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] some progress on DVB-C analog module: experimentally fix frequency offset, initialize msp3400 for analog TV sound
- [DVB] Reduce the number of dropped TS packets when an error is detected (Jon Burgess)
- [DVB] If somebody calls G_TUNER for a DVB-C card w/ analog module, then check for the selected tuner, not if the currently selected channel has a tuner.
- [DVB] play_iframe may be used to play stillpicture frames, that can either by complete i-frames or partial p-frames. In any case, the av7110 needs about 400kB of video data, before the internal video decoder starts displaying anything. for stillframes, this is bad, so we  *always* loop writing the frame until the magic amount is reached. stupid, but works...
- [DVB] applied 64bit fixes by Pedro Miguel Teixeira <pmsjt@warner.homeip.net
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/dvb-core/dvb_demux.c linux-2.6.0-test6-cvs/drivers/media/dvb/dvb-core/dvb_demux.c
--- linux-2.6.0-test6/drivers/media/dvb/dvb-core/dvb_demux.c	2003-10-01 12:20:38.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/dvb-core/dvb_demux.c	2003-09-23 11:59:02.000000000 +0200
@@ -391,7 +393,9 @@
 	spin_lock(&demux->lock);
 
 	while (count--) {
+               	if(buf[0] == 0x47) {
 		dvb_dmx_swfilter_packet(demux, buf);
+		}
 		buf += 188;
 	}
 
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/ttpci/av7110.h linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/av7110.h
--- linux-2.6.0-test6/drivers/media/dvb/ttpci/av7110.h	2003-10-01 12:20:38.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/av7110.h	2003-09-29 16:04:08.000000000 +0200
@@ -399,14 +399,14 @@
 
         struct dvb_device       dvb_dev;
         struct dvb_net               dvb_net;
-	struct video_device	vd;
+	struct video_device	v4l_dev;
 
         struct saa7146_dev	*dev;
 
 	struct dvb_i2c_bus	*i2c_bus;	
 	char			*card_name;
 
-	/* support for analog module of dvb-c */
+	/* support for analog module of dvb-c */
 	int			has_analog_tuner;
 	int			current_input;
 	u32			current_freq;
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/ttpci/budget-core.c linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/budget-core.c
--- linux-2.6.0-test6/drivers/media/dvb/ttpci/budget-core.c	2003-10-01 12:25:32.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/budget-core.c	2003-09-23 11:59:37.000000000 +0200
@@ -80,14 +80,11 @@
 		return;
 
         if (newdma > olddma) { /* no wraparound, dump olddma..newdma */
-               	if(mem[olddma] == 0x47)
                         dvb_dmx_swfilter_packets(&budget->demux, 
         	                mem+olddma, (newdma-olddma) / 188);
         } else { /* wraparound, dump olddma..buflen and 0..newdma */
-                if(mem[olddma] == 0x47)
 	                dvb_dmx_swfilter_packets(&budget->demux,
         	                mem+olddma, (TS_BUFLEN-olddma) / 188);
-                if(mem[0] == 0x47)
                         dvb_dmx_swfilter_packets(&budget->demux,
                                 mem, newdma / 188);
         }
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/ttpci/av7110.c linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/av7110.c
--- linux-2.6.0-test6/drivers/media/dvb/ttpci/av7110.c	2003-10-01 12:25:33.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/av7110.c	2003-10-01 12:27:23.000000000 +0200
@@ -609,7 +611,7 @@
                      enum dmx_success success,
                      struct av7110 *av7110)
 {
-	DEB_EE(("av7110: %p\n",av7110));
+	DEB_INT(("av7110: %p\n",av7110));
 
         if (!dvbdmxfilter->feed->demux->dmx.frontend)
                 return 0;
@@ -1324,17 +1326,43 @@
  * Firmware commands 
  ****************************************************************************/
 
+/* msp3400 i2c subaddresses */
+#define MSP_WR_DEM 0x10
+#define MSP_RD_DEM 0x11
+#define MSP_WR_DSP 0x12
+#define MSP_RD_DSP 0x13
+
 static inline int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val)
 {
         u8 msg[5]={ dev, reg>>8, reg&0xff, val>>8 , val&0xff }; 
         struct dvb_i2c_bus *i2c = av7110->i2c_bus;
-        struct i2c_msg msgs;
+        struct i2c_msg msgs = { .flags = 0, .addr = 0x40, .len = 5, .buf = msg};
 
-        msgs.flags=0;
-        msgs.addr=0x40;
-        msgs.len=5;
-        msgs.buf=msg;
-        return i2c->xfer(i2c, &msgs, 1);
+        if (i2c->xfer(i2c, &msgs, 1) != 1) {
+		printk("av7110(%d): %s(%u = %u) failed\n",
+				av7110->dvb_adapter->num, __FUNCTION__, reg, val);
+		return -EIO;
+	}
+	return 0;
+}
+
+static inline int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val)
+{
+        u8 msg1[3]={ dev, reg>>8, reg&0xff };
+        u8 msg2[2];
+        struct dvb_i2c_bus *i2c = av7110->i2c_bus;
+        struct i2c_msg msgs[2] = {
+		{ .flags = 0,        .addr = 0x40, .len = 3, .buf = msg1},
+		{ .flags = I2C_M_RD, .addr = 0x40, .len = 2, .buf = msg2}
+	};
+
+        if (i2c->xfer(i2c, msgs, 2) != 2) {
+		printk("av7110(%d): %s(%u) failed\n",
+				av7110->dvb_adapter->num, __FUNCTION__, reg);
+		return -EIO;
+	}
+	*val = (msg2[0] << 8) | msg2[1];
+	return 0;
 }
 
 static inline int SendDAC(struct av7110 *av7110, u8 addr, u8 data)
@@ -1375,9 +1403,9 @@
 		if (vol > 0) {
 		       balance = ((volright-volleft) * 127) / vol;
 		}
-		msp_writereg(av7110, 0x12, 0x0001, balance << 8);
-		msp_writereg(av7110, 0x12, 0x0000, val); /* loudspeaker */
-		msp_writereg(av7110, 0x12, 0x0006, val); /* headphonesr */
+		msp_writereg(av7110, MSP_WR_DSP, 0x0001, balance << 8);
+		msp_writereg(av7110, MSP_WR_DSP, 0x0000, val); /* loudspeaker */
+		msp_writereg(av7110, MSP_WR_DSP, 0x0006, val); /* headphonesr */
 		return 0;
         }
         return 0;
@@ -2623,7 +2651,7 @@
 		.status		= 0,
 	}, { 
 		.index 		= 1,
-		.name 		= "ANALOG",
+		.name 		= "Television",
 		.type		= V4L2_INPUT_TYPE_TUNER,
 		.audioset 	= 2,
 		.tuner		= 0,
@@ -2672,9 +2700,9 @@
 
  	DEB_EE(("av7710: freq: 0x%08x\n",freq));
 
-	/* magic number: 56. tuning with the frequency given by v4l2
-	   is always off by 56*62.5 kHz...*/
-	div = freq + 56;
+	/* magic number: 614. tuning with the frequency given by v4l2
+	   is always off by 614*62.5 = 38375 kHz...*/
+	div = freq + 614;
 
 	buf[0] = (div >> 8) & 0x7f;
 	buf[1] = div & 0xff;
@@ -2697,13 +2725,18 @@
 static struct saa7146_standard dvb_standard[];
 static struct saa7146_standard standard[];
 
+static struct v4l2_audio msp3400_v4l2_audio = {
+	.index = 0,
+	.name = "Television",
+	.capability = V4L2_AUDCAP_STEREO
+};
+
 int av7110_dvb_c_switch(struct saa7146_fh *fh)
 {
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_vv *vv = dev->vv_data;
 	struct av7110 *av7110 = (struct av7110*)dev->ext_priv;
-	u16 buf[3] = { ((COMTYPE_AUDIODAC << 8) + ADSwitch), 1, 1 };
-
+	u16 adswitch;
 	u8 band = 0;
 	int source, sync;
 	struct saa7146_fh *ov_fh = NULL;
@@ -2718,23 +2751,36 @@
 	}
 
 	if( 0 != av7110->current_input ) {
-		buf[2] = 0;
+		adswitch = 1;
 		band = 0x68; /* analog band */
 		source = SAA7146_HPS_SOURCE_PORT_B;
 		sync = SAA7146_HPS_SYNC_PORT_B;
 		memcpy(standard,analog_standard,sizeof(struct saa7146_standard)*2);
+		printk("av7110: switching to analog TV\n");
+		msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
+		msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
+		msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
+		msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
+		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
+		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
 	} else {
-		buf[2] = 1;
+		adswitch = 0;
 		band = 0x28; /* digital band */	
 		source = SAA7146_HPS_SOURCE_PORT_A;
 		sync = SAA7146_HPS_SYNC_PORT_A;
 		memcpy(standard,dvb_standard,sizeof(struct saa7146_standard)*2);
+		printk("av7110: switching DVB mode\n");
+		msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source
+		msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0220); // headphone source
+		msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0220); // SCART 1 source
+		msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
+		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
+		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x7f00); // SCART 1 volume
 	}
 
 	/* hmm, this does not do anything!? */
-	if (OutCommand(av7110, buf, 3)) {
+	if (outcom(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, adswitch))
 		printk("ADSwitch error\n");
-	}
 
 	if( 0 != ves1820_writereg(dev, 0x0f, band )) {
 		printk("setting band in demodulator failed.\n");
@@ -2759,6 +2805,8 @@
 	case VIDIOC_G_TUNER:
 	{
 		struct v4l2_tuner *t = arg;
+		u16 stereo_det;
+		s8 stereo;
 
 		DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index));
 
@@ -2770,21 +2818,39 @@
 		strcpy(t->name, "Television");
 
 		t->type = V4L2_TUNER_ANALOG_TV;
-		t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
+		t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO |
+			V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
 		t->rangelow = 772;	/* 48.25 MHZ / 62.5 kHz = 772, see fi1216mk2-specs, page 2 */
 		t->rangehigh = 13684;	/* 855.25 MHz / 62.5 kHz = 13684 */
 		/* FIXME: add the real signal strength here */
 		t->signal = 0xffff;
 		t->afc = 0;		
-		/* fixme: real autodetection here */
+
+msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det);
+printk("VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det);
+
+		msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det);
+		printk("VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det);
+		stereo = (s8)(stereo_det >> 8);
+		if (stereo > 0x10) {
+			/* stereo */
 		t->rxsubchans 	= V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO;
+			t->audmode = V4L2_TUNER_MODE_STEREO;
+		}
+		else if (stereo < -0x10) {
+			/* bilingual*/
+			t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
+			 t->audmode = V4L2_TUNER_MODE_LANG1;
+		}
+		else /* mono */
+			t->rxsubchans = V4L2_TUNER_SUB_MONO;
 
 		return 0;
 	}
 	case VIDIOC_S_TUNER:
 	{
 		struct v4l2_tuner *t = arg;
-		
+		u16 fm_matrix, src;
 		DEB_EE(("VIDIOC_S_TUNER: %d\n", t->index));
 
 		if( 0 == av7110->has_analog_tuner || av7110->current_input != 1 ) {
@@ -2793,23 +2859,31 @@
 
 
 		switch(t->audmode) {
-			case V4L2_TUNER_MODE_STEREO: {
+		case V4L2_TUNER_MODE_STEREO:
 				DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n"));
+			fm_matrix = 0x3001; // stereo
+			src = 0x0020;
 				break;
-			}
-			case V4L2_TUNER_MODE_LANG1: {
+		case V4L2_TUNER_MODE_LANG1:
 				DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n"));
+			fm_matrix = 0x3000; // mono
+			src = 0x0000;
 				break;
-			}
-			case V4L2_TUNER_MODE_LANG2: {
+		case V4L2_TUNER_MODE_LANG2:
 				DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG2\n"));
+			fm_matrix = 0x3000; // mono
+			src = 0x0010;
 				break;
-			}
-			default: { /* case V4L2_TUNER_MODE_MONO: {*/
+		default: /* case V4L2_TUNER_MODE_MONO: {*/
 				DEB_D(("VIDIOC_S_TUNER: TDA9840_SET_MONO\n"));
+			fm_matrix = 0x3000; // mono
+			src = 0x0030;
 				break;
 			}
-		}
+		msp_writereg(av7110, MSP_WR_DSP, 0x000e, fm_matrix);
+		msp_writereg(av7110, MSP_WR_DSP, 0x0008, src);
+		msp_writereg(av7110, MSP_WR_DSP, 0x0009, src);
+		msp_writereg(av7110, MSP_WR_DSP, 0x000a, src);
 
 		return 0;
 	}
@@ -2842,10 +2916,18 @@
 		if (V4L2_TUNER_ANALOG_TV != f->type)
 			return -EINVAL;
 
+		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0xffe0); // fast mute
+		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0xffe0);
+
 		/* tune in desired frequency */			
 		tuner_set_tv_freq(dev, f->frequency);
 		av7110->current_freq = f->frequency;
 
+		msp_writereg(av7110, MSP_WR_DSP, 0x0015, 0x003f); // start stereo detection
+		msp_writereg(av7110, MSP_WR_DSP, 0x0015, 0x0000);
+		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
+		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
+
 		return 0;
 	}
 	case VIDIOC_ENUMINPUT:
@@ -2893,6 +2975,22 @@
 		av7110->current_input = input;
 		return av7110_dvb_c_switch(fh);
 	}	
+	case VIDIOC_G_AUDIO:
+	{
+		struct v4l2_audio *a = arg;
+
+		DEB_EE(("VIDIOC_G_AUDIO: %d\n", a->index));
+		if (a->index != 0)
+			return -EINVAL;
+		memcpy(a, &msp3400_v4l2_audio, sizeof(struct v4l2_audio));
+		break;
+	}
+	case VIDIOC_S_AUDIO:
+	{
+		struct v4l2_audio *a = arg;
+		DEB_EE(("VIDIOC_S_AUDIO: %d\n", a->index));
+		break;
+	}
 	default:
 		printk("no such ioctl\n");
 		return -ENOIOCTLCMD;
@@ -4366,9 +4464,46 @@
 	{ VIDIOC_S_FREQUENCY, 	SAA7146_EXCLUSIVE },
 	{ VIDIOC_G_TUNER, 	SAA7146_EXCLUSIVE },
 	{ VIDIOC_S_TUNER, 	SAA7146_EXCLUSIVE },
+	{ VIDIOC_G_AUDIO,	SAA7146_EXCLUSIVE },
+	{ VIDIOC_S_AUDIO,	SAA7146_EXCLUSIVE },
 	{ 0, 0 }
 };
 
+static u8 saa7113_init_regs[] = {
+	0x02, 0xd0,
+	0x03, 0x23,
+	0x04, 0x00,
+	0x05, 0x00,
+	0x06, 0xe9,
+	0x07, 0x0d,
+	0x08, 0x98,
+	0x09, 0x02,
+	0x0a, 0x80,
+	0x0b, 0x40,
+	0x0c, 0x40,
+	0x0d, 0x00,
+	0x0e, 0x01,
+	0x0f, 0x7c,
+	0x10, 0x48,
+	0x11, 0x0c,
+	0x12, 0x8b,
+	0x13, 0x1a,
+	0x14, 0x00,
+	0x15, 0x00,
+	0x16, 0x00,
+	0x17, 0x00,
+	0x18, 0x00,
+	0x19, 0x00,
+	0x1a, 0x00,
+	0x1b, 0x00,
+	0x1c, 0x00,
+	0x1d, 0x00,
+	0x1e, 0x00,
+
+	0xff
+};
+
+
 static struct saa7146_ext_vv av7110_vv_data_st;
 static struct saa7146_ext_vv av7110_vv_data_c;
 
@@ -4404,7 +4539,7 @@
 		return -1;
 	}
 
-	if (saa7146_register_device(&av7110->vd, dev, "av7110", VFL_TYPE_GRABBER)) {
+	if (saa7146_register_device(&av7110->v4l_dev, dev, "av7110", VFL_TYPE_GRABBER)) {
 		ERR(("cannot register capture device. skipping.\n"));
 		saa7146_vv_release(dev);
 		kfree(av7110);
@@ -4424,7 +4559,7 @@
 						av7110->dvb_adapter, 0);
 
 	if (!av7110->i2c_bus) {
-		saa7146_unregister_device(&av7110->vd, dev);
+		saa7146_unregister_device(&av7110->v4l_dev, dev);
 		saa7146_vv_release(dev);
 		dvb_unregister_adapter (av7110->dvb_adapter);
 		kfree(av7110);
@@ -4532,36 +4667,65 @@
 	/**
 	 * some special handling for the Siemens DVB-C cards...
 	 */
-	} else if (i2c_writereg(av7110, 0x80, 0x0, 0x80)==1) {
-			i2c_writereg(av7110, 0x80, 0x0, 0);
+	} else if (i2c_writereg(av7110, 0x80, 0x0, 0x80) == 1
+			&& i2c_writereg(av7110, 0x80, 0x0, 0) == 1) {
+		u16 version1, version2;
 		printk ("av7110(%d): DVB-C analog module detected, "
 			"initializing MSP3400\n",
 			av7110->dvb_adapter->num);
 		av7110->adac_type = DVB_ADAC_MSP;
-		dvb_delay(100);
-			msp_writereg(av7110, 0x12, 0x0013, 0x0c00);
-			msp_writereg(av7110, 0x12, 0x0000, 0x7f00); // loudspeaker + headphone
-			msp_writereg(av7110, 0x12, 0x0008, 0x0220); // loudspeaker source
-			msp_writereg(av7110, 0x12, 0x0004, 0x7f00); // loudspeaker volume
-			msp_writereg(av7110, 0x12, 0x000a, 0x0220); // SCART 1 source
-			msp_writereg(av7110, 0x12, 0x0007, 0x7f00); // SCART 1 volume
-			msp_writereg(av7110, 0x12, 0x000d, 0x4800); // prescale SCART
+		dvb_delay(100); // the probing above resets the msp...
+		msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1);
+		msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2);
+		printk("av7110(%d): MSP3400 version 0x%04x 0x%04x\n",
+			av7110->dvb_adapter->num, version1, version2);
+		msp_writereg(av7110, MSP_WR_DSP, 0x0013, 0x0c00);
+		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
+		msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source
+		msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0220); // headphone source
+		msp_writereg(av7110, MSP_WR_DSP, 0x0004, 0x7f00); // loudspeaker volume
+		msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0220); // SCART 1 source
+		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x7f00); // SCART 1 volume
+		msp_writereg(av7110, MSP_WR_DSP, 0x000d, 0x4800); // prescale SCART
 		
 		if (i2c_writereg(av7110, 0x48, 0x01, 0x00)!=1) {
 			INFO(("saa7113 not accessible.\n"));
-		} else {
+		}
+		else {
+			u8 *i = saa7113_init_regs;
 			av7110->has_analog_tuner = 1;
 			/* init the saa7113 */
-			i2c_writereg(av7110, 0x48, 0x02, 0xd0); i2c_writereg(av7110, 0x48, 0x03, 0x23); i2c_writereg(av7110, 0x48, 0x04, 0x00);
-			i2c_writereg(av7110, 0x48, 0x05, 0x00); i2c_writereg(av7110, 0x48, 0x06, 0xe9); i2c_writereg(av7110, 0x48, 0x07, 0x0d);
-			i2c_writereg(av7110, 0x48, 0x08, 0x98); i2c_writereg(av7110, 0x48, 0x09, 0x02); i2c_writereg(av7110, 0x48, 0x0a, 0x80);
-			i2c_writereg(av7110, 0x48, 0x0b, 0x40); i2c_writereg(av7110, 0x48, 0x0c, 0x40); i2c_writereg(av7110, 0x48, 0x0d, 0x00);
-			i2c_writereg(av7110, 0x48, 0x0e, 0x01);	i2c_writereg(av7110, 0x48, 0x0f, 0x7c); i2c_writereg(av7110, 0x48, 0x10, 0x48);
-			i2c_writereg(av7110, 0x48, 0x11, 0x0c);	i2c_writereg(av7110, 0x48, 0x12, 0x8b);	i2c_writereg(av7110, 0x48, 0x13, 0x10);
-			i2c_writereg(av7110, 0x48, 0x14, 0x00);	i2c_writereg(av7110, 0x48, 0x15, 0x00);	i2c_writereg(av7110, 0x48, 0x16, 0x00);
-			i2c_writereg(av7110, 0x48, 0x17, 0x00);	i2c_writereg(av7110, 0x48, 0x18, 0x00);	i2c_writereg(av7110, 0x48, 0x19, 0x00);
-			i2c_writereg(av7110, 0x48, 0x1a, 0x00);	i2c_writereg(av7110, 0x48, 0x1b, 0x00);	i2c_writereg(av7110, 0x48, 0x1c, 0x00);
-			i2c_writereg(av7110, 0x48, 0x1d, 0x00);	i2c_writereg(av7110, 0x48, 0x1e, 0x00);
+			while (*i != 0xff) {
+				if (i2c_writereg(av7110, 0x48, i[0], i[1]) != 1) {
+					printk("av7110(%d): saa7113 initialization failed",
+							av7110->dvb_adapter->num);
+					break;
+				}
+				i += 2;
+			}
+			/* setup msp for analog sound: B/G Dual-FM */
+			msp_writereg(av7110, MSP_WR_DEM, 0x00bb, 0x02d0); // AD_CV
+			msp_writereg(av7110, MSP_WR_DEM, 0x0001,  3); // FIR1
+			msp_writereg(av7110, MSP_WR_DEM, 0x0001, 18); // FIR1
+			msp_writereg(av7110, MSP_WR_DEM, 0x0001, 27); // FIR1
+			msp_writereg(av7110, MSP_WR_DEM, 0x0001, 48); // FIR1
+			msp_writereg(av7110, MSP_WR_DEM, 0x0001, 66); // FIR1
+			msp_writereg(av7110, MSP_WR_DEM, 0x0001, 72); // FIR1
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005,  4); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005, 64); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005,  0); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005,  3); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005, 18); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005, 27); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005, 48); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005, 66); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0005, 72); // FIR2
+			msp_writereg(av7110, MSP_WR_DEM, 0x0083, 0xa000); // MODE_REG
+			msp_writereg(av7110, MSP_WR_DEM, 0x0093, 0x00aa); // DCO1_LO 5.74MHz
+			msp_writereg(av7110, MSP_WR_DEM, 0x009b, 0x04fc); // DCO1_HI
+			msp_writereg(av7110, MSP_WR_DEM, 0x00a3, 0x038e); // DCO2_LO 5.5MHz
+			msp_writereg(av7110, MSP_WR_DEM, 0x00ab, 0x04c6); // DCO2_HI
+			msp_writereg(av7110, MSP_WR_DEM, 0x0056, 0); // LOAD_REG 1/2
 		}	
 
 		memcpy(standard,dvb_standard,sizeof(struct saa7146_standard)*2);
@@ -4569,13 +4733,13 @@
       		saa7146_write(dev, DD1_STREAM_B, 0x00000000);
 		saa7146_write(dev, DD1_INIT, 0x0200700);
 		saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
-
-
-	} else if (dev->pci->subsystem_vendor == 0x110a) {
+	}
+	else if (dev->pci->subsystem_vendor == 0x110a) {
 		printk("av7110(%d): DVB-C w/o analog module detected\n",
 			av7110->dvb_adapter->num);
 		av7110->adac_type = DVB_ADAC_NONE;
-	} else {
+	}
+	else {
 		av7110->adac_type = adac;
 		printk("av7110(%d): adac type set to %d\n",
 			av7110->dvb_adapter->num, av7110->adac_type);
@@ -4603,7 +4767,7 @@
 		kfree(av7110);
 
 	/* FIXME: error handling is pretty bogus: memory does not get freed...*/
-	saa7146_unregister_device(&av7110->vd, dev);
+	saa7146_unregister_device(&av7110->v4l_dev, dev);
 	saa7146_vv_release(dev);
 
 	dvb_unregister_i2c_bus (master_xfer,av7110->i2c_bus->adapter,
@@ -4619,7 +4783,7 @@
 	struct av7110 *av7110 = (struct av7110*)saa->ext_priv;
 	DEB_EE(("av7110: %p\n",av7110));
 
-	saa7146_unregister_device(&av7110->vd, saa);
+	saa7146_unregister_device(&av7110->v4l_dev, saa);
 
 	av7110->arm_rmmod=1;
 	wake_up_interruptible(&av7110->arm_wait);
@@ -4658,7 +4822,7 @@
 {
 	struct av7110 *av7110 = (struct av7110*)dev->ext_priv;
 
-	DEB_EE(("dev: %p, av7110: %p\n",dev,av7110));
+	DEB_INT(("dev: %p, av7110: %p\n",dev,av7110));
 
 	if (*isr & MASK_19)
 		tasklet_schedule (&av7110->debi_tasklet);


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 11/14] Kconfig and Makefile updates, inspired by Adrian Bunk and Roman Zippel
  2003-10-08 13:28                 ` [PATCH 10/14] update dvb frontend drivers Michael Hunold
@ 2003-10-08 13:28                   ` Michael Hunold
  2003-10-08 13:28                     ` [PATCH 12/14] some more av7110 dvb-driver updates Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:28 UTC (permalink / raw)
  To: linux-kernel

- [DVB] split up saa7146 compilation in core part (saa7146.o) and video+vbi part (saa7146_vv). some drivers need both (av7110.c), some drivers only need the core stuff (budget*.c)
- [DVB] add entry for sp887x DVB-T modulator to corresponding Kconfig
- [DVB] use new SELECT facility of Kconfig, first mentioned by Adrian Bunk and Roman Zippel in DVB subsystem
- [DVB] use SELECT in media/video/Kconfig, too.
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/common/Kconfig linux-2.6.0-test6-cvs/drivers/media/common/Kconfig
--- linux-2.6.0-test6/drivers/media/common/Kconfig	2003-10-01 12:25:26.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/common/Kconfig	2003-10-01 12:12:33.000000000 +0200
@@ -1,8 +1,12 @@
 config VIDEO_SAA7146
-	def_tristate DVB_AV7110 || DVB_BUDGET || DVB_BUDGET_AV || \
-		     VIDEO_MXB || VIDEO_DPC || VIDEO_HEXIUM_ORION || \
-		     VIDEO_HEXIUM_GEMINI
-        depends on VIDEO_DEV && PCI && I2C
+        tristate
+	select I2C
+
+config VIDEO_SAA7146_VV
+        tristate
+	select VIDEO_BUF
+	select VIDEO_VIDEOBUF
+	select VIDEO_SAA7146
+
 config VIDEO_VIDEOBUF
-	def_tristate VIDEO_SAA7134 || VIDEO_BT848 || VIDEO_SAA7146
-        depends on VIDEO_DEV
+        tristate
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/common/Makefile linux-2.6.0-test6-cvs/drivers/media/common/Makefile
--- linux-2.6.0-test6/drivers/media/common/Makefile	2003-10-01 12:20:38.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/common/Makefile	2003-09-29 14:08:58.000000000 +0200
@@ -1,5 +1,6 @@
 saa7146-objs    := saa7146_i2c.o saa7146_core.o 
 saa7146_vv-objs := saa7146_vv_ksyms.o saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o  
 
-obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o saa7146_vv.o
+obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o
+obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o
 
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/Kconfig linux-2.6.0-test6-cvs/drivers/media/dvb/Kconfig
--- linux-2.6.0-test6/drivers/media/dvb/Kconfig	2003-10-01 12:20:38.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/Kconfig	2003-09-30 19:43:56.000000000 +0200
@@ -3,16 +3,16 @@
 #
 
 menu "Digital Video Broadcasting Devices"
-	depends on NET && INET 
 
 config DVB
 	bool "DVB For Linux"
+	depends on NET && INET
 	---help---
 	  Support Digital Video Broadcasting hardware.  Enable this if you 
 	  own a DVB adapter and want to use it or if you compile Linux for 
 	  a digital SetTopBox.
 
-	  API specs and user tools and are available for example from 
+	  API specs and user tools are available from
 	  <http://www.linuxtv.org/>. 
 
 	  Please report problems regarding this driver to the LinuxDVB 
@@ -33,18 +33,16 @@
 source "drivers/media/dvb/frontends/Kconfig"
 
 comment "Supported SAA7146 based PCI Adapters"
-	depends on DVB && PCI
-
+	depends on DVB_CORE && PCI
 source "drivers/media/dvb/ttpci/Kconfig"
 
 comment "Supported USB Adapters"
-	depends on DVB && USB
-
+	depends on DVB_CORE && USB
 source "drivers/media/dvb/ttusb-budget/Kconfig"
 source "drivers/media/dvb/ttusb-dec/Kconfig"
 
 comment "Supported FlexCopII (B2C2) Adapters"
-	depends on DVB && PCI
+	depends on DVB_CORE && PCI
 source "drivers/media/dvb/b2c2/Kconfig"
 
 endmenu
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/dvb-core/Kconfig linux-2.6.0-test6-cvs/drivers/media/dvb/dvb-core/Kconfig
--- linux-2.6.0-test6/drivers/media/dvb/dvb-core/Kconfig	2003-10-01 12:20:38.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/dvb-core/Kconfig	2003-09-29 15:50:51.000000000 +0200
@@ -4,5 +4,8 @@
 	select CRC32
 	help
 	  DVB core utility functions for device handling, software fallbacks etc.
+	  Say Y when you have a DVB card and want to use it. Say Y if your want
+	  to build your drivers outside the kernel, but need the DVB core. All 
+	  in-kernel drivers will select this automatically if needed.
+	  If unsure say N.
 
-	  Say Y when you have a DVB card and want to use it. If unsure say N.
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/dvb-core/Makefile.lib linux-2.6.0-test6-cvs/drivers/media/dvb/dvb-core/Makefile.lib
--- linux-2.6.0-test6/drivers/media/dvb/dvb-core/Makefile.lib	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/dvb-core/Makefile.lib	2002-11-08 18:13:22.000000000 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_DVB_CORE)		+= crc32.o
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/ttpci/Kconfig linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/Kconfig
--- linux-2.6.0-test6/drivers/media/dvb/ttpci/Kconfig	2003-10-01 12:20:38.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/ttpci/Kconfig	2003-09-29 14:28:39.000000000 +0200
@@ -1,6 +1,8 @@
 config DVB_AV7110
 	tristate "AV7110 cards"
-	depends on VIDEO_DEV && DVB_CORE
+	depends on DVB_CORE
+	select VIDEO_DEV
+	select VIDEO_SAA7146_VV
 	help
 	  Support for SAA7146 and AV7110 based DVB cards as produced 
 	  by Fujitsu-Siemens, Technotrend, Hauppauge and others.
@@ -26,6 +28,7 @@
 config DVB_BUDGET
 	tristate "Budget cards"
 	depends on DVB_CORE
+	select VIDEO_SAA7146
 	help
 	  Support for simple SAA7146 based DVB cards
 	  (so called Budget- or Nova-PCI cards) without onboard
@@ -38,7 +41,8 @@
 
 config DVB_BUDGET_CI
 	tristate "Budget cards with onboard CI connector"
-	depends on VIDEO_DEV && DVB_CORE && DVB_BUDGET
+	depends on DVB_CORE
+	select VIDEO_SAA7146
 	help
 	  Support for simple SAA7146 based DVB cards
 	  (so called Budget- or Nova-PCI cards) without onboard
@@ -51,7 +55,9 @@
 
 config DVB_BUDGET_AV
 	tristate "Budget cards with analog video inputs"
-	depends on VIDEO_DEV && DVB_CORE && DVB_BUDGET
+	depends on DVB_CORE
+	select VIDEO_DEV
+	select VIDEO_SAA7146_VV
 	help
 	  Support for simple SAA7146 based DVB cards
 	  (so called Budget- or Nova-PCI cards) without onboard
@@ -64,7 +70,9 @@
 
 config DVB_BUDGET_PATCH
 	tristate "AV7110 cards with Budget Patch"
-	depends on DVB_CORE && DVB_BUDGET
+	depends on DVB_BUDGET
+	select VIDEO_DEV
+	select VIDEO_SAA7146_VV
 	help
 	  Support for Budget Patch (full TS) modification on 
 	  SAA7146+AV7110 based cards (DVB-S cards). This
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/ttusb-budget/Kconfig linux-2.6.0-test6-cvs/drivers/media/dvb/ttusb-budget/Kconfig
--- linux-2.6.0-test6/drivers/media/dvb/ttusb-budget/Kconfig	2003-10-01 12:20:38.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/ttusb-budget/Kconfig	2003-09-30 19:45:20.000000000 +0200
@@ -1,6 +1,6 @@
 config DVB_TTUSB_BUDGET
 	tristate "Technotrend/Hauppauge Nova-USB devices"
-	depends on DVB_CORE && USB
+	depends on DVB_CORE
 	help
 	  Support for external USB adapters designed by Technotrend and
 	  produced by Hauppauge, shipped under the brand name 'Nova-USB'.
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/dvb/frontends/Kconfig linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/Kconfig
--- linux-2.6.0-test6/drivers/media/dvb/frontends/Kconfig	2003-10-01 13:36:35.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/dvb/frontends/Kconfig	2003-10-01 13:04:16.000000000 +0200
@@ -26,6 +26,16 @@
 	  DVB adapter simply enable all supported frontends, the 
 	  right one will get autodetected.
 
+config DVB_SP887X
+ 	tristate "Frontends with sp887x demodulators, e.g. Microtune DTF7072"
+ 	depends on DVB_CORE
+ 	help
+ 	  A DVB-T demodulator driver. Say Y when you want to support the sp887x.
+ 
+ 	  If you don't know what tuner module is soldered on your
+ 	  DVB adapter simply enable all supported frontends, the
+ 	  right one will get autodetected.
+
 config DVB_ALPS_TDLB7
 	tristate "Alps TDLB7 (OFDM)"
 	depends on DVB_CORE
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/video/Kconfig linux-2.6.0-test6-cvs/drivers/media/video/Kconfig
--- linux-2.6.0-test6/drivers/media/video/Kconfig	2003-10-01 13:36:35.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/video/Kconfig	2003-09-30 19:40:39.000000000 +0200
@@ -3,7 +3,7 @@
 #
 
 menu "Video For Linux"
-	depends on VIDEO_DEV!=n
+	depends on VIDEO_DEV
 
 comment "Video Adapters"
 
@@ -228,7 +228,8 @@
 
 config VIDEO_MXB
 	tristate "Siemens-Nixdorf 'Multimedia eXtension Board'"
-	depends on VIDEO_DEV && PCI && I2C
+	depends on VIDEO_DEV && PCI
+	select VIDEO_SAA7146_VV
 	---help---
 	  This is a video4linux driver for the 'Multimedia eXtension Board'
 	  TV card by Siemens-Nixdorf.
@@ -238,7 +239,8 @@
 
 config VIDEO_DPC
 	tristate "Philips-Semiconductors 'dpc7146 demonstration board'"
-	depends on VIDEO_DEV && PCI && I2C
+	depends on VIDEO_DEV && PCI
+	select VIDEO_SAA7146_VV
 	---help---
 	  This is a video4linux driver for the 'dpc7146 demonstration
 	  board' by Philips-Semiconductors. It's the reference design
@@ -251,7 +253,8 @@
 
 config VIDEO_HEXIUM_ORION
 	tristate "Hexium HV-PCI6 and Orion frame grabber"
-	depends on VIDEO_DEV && PCI && I2C
+	depends on VIDEO_DEV && PCI
+	select VIDEO_SAA7146_VV
 	---help---
 	  This is a video4linux driver for the Hexium HV-PCI6 and
 	  Orion frame grabber cards by Hexium.
@@ -261,7 +264,8 @@
 
 config VIDEO_HEXIUM_GEMINI
 	tristate "Hexium Gemini frame grabber"
-	depends on VIDEO_DEV && PCI && I2C
+	depends on VIDEO_DEV && PCI
+	select VIDEO_SAA7146_VV
 	---help---
 	  This is a video4linux driver for the Hexium Gemini frame
 	  grabber card by Hexium. Please note that the Gemini Dual


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 14/14] firmware blob for new DVB-T frontend driver
  2003-10-08 13:29                       ` [PATCH 13/14] fix v4l1 backward compatibility in saa7146 driver Michael Hunold
@ 2003-10-08 13:29                         ` Michael Hunold
  0 siblings, 0 replies; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:29 UTC (permalink / raw)
  To: linux-kernel

... send to Linus only.


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 13/14] fix v4l1 backward compatibility in saa7146 driver
  2003-10-08 13:28                     ` [PATCH 12/14] some more av7110 dvb-driver updates Michael Hunold
@ 2003-10-08 13:29                       ` Michael Hunold
  2003-10-08 13:29                         ` [PATCH 14/14] firmware blob for new DVB-T frontend driver Michael Hunold
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 13:29 UTC (permalink / raw)
  To: linux-kernel

- [DVB] fix VIDIOC_S_FBUF for v4l1 backward compatility with xfree86 / v4l_drv
diff -uNrwB --new-file -uraN linux-2.6.0-test6/drivers/media/common/saa7146_video.c linux-2.6.0-test6-cvs/drivers/media/common/saa7146_video.c
--- linux-2.6.0-test6/drivers/media/common/saa7146_video.c	2003-10-01 12:25:26.000000000 +0200
+++ linux-2.6.0-test6-cvs/drivers/media/common/saa7146_video.c	2003-09-30 19:15:11.000000000 +0200
@@ -904,6 +904,8 @@
 	{
 		struct v4l2_framebuffer *fb = arg;
 		struct saa7146_format *fmt;
+		struct saa7146_fh *ov_fh = NULL;
+		int restart_overlay = 0;
 
 		DEB_EE(("VIDIOC_S_FBUF\n"));
 
@@ -913,10 +915,6 @@
 			return -EPERM;
 		}
 */
-		if( 0 != vv->ov_data ) {
-			DEB_D(("VIDIOC_S_FBUF: overlay is active.\n"));
-			return -EPERM;
-		}
 
 		/* check args */
 		fmt = format_by_fourcc(dev,fb->fmt.pixelformat);
@@ -924,12 +922,27 @@
 			return -EINVAL;
 		}
 		
+		down(&dev->lock);
+
+		if( vv->ov_data != NULL ) {
+			ov_fh = vv->ov_data->fh;
+			saa7146_stop_preview(ov_fh);
+			restart_overlay = 1;
+		}
+
 		/* ok, accept it */
 		vv->ov_fb = *fb;
 		vv->ov_fmt = fmt;
 		if (0 == vv->ov_fb.fmt.bytesperline)
 			vv->ov_fb.fmt.bytesperline =
 				vv->ov_fb.fmt.width*fmt->depth/8;
+
+		if( 0 != restart_overlay ) {
+			saa7146_start_preview(ov_fh);
+		}
+
+		up(&dev->lock);
+
 		return 0;
 	}
 	case VIDIOC_ENUM_FMT:


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 2/14] firmware update for av7110 dvb driver
  2003-10-08 13:28 ` [PATCH 2/14] firmware update for av7110 dvb driver Michael Hunold
  2003-10-08 13:28   ` [PATCH 3/14] add new DVB-T frontend driver Michael Hunold
@ 2003-10-08 14:45   ` Marcel Holtmann
  2003-10-08 15:36     ` Michael Hunold
  2003-10-11 11:59     ` Jochen Friedrich
  1 sibling, 2 replies; 28+ messages in thread
From: Marcel Holtmann @ 2003-10-08 14:45 UTC (permalink / raw)
  To: Michael Hunold; +Cc: Linux Kernel Mailing List

Hi Michael,

> ... send to Linus only. (You don't want a 150kB bzip2 compressed firmware blob, don't you? In case you do, drop me a line.)

the request_firmware() framework is part of Linux 2.4 and 2.6 and so for
most drivers the firmware file can be loaded from userspace through proc
or sysfs. Please take a look at it.

Regards

Marcel



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 2/14] firmware update for av7110 dvb driver
  2003-10-08 14:45   ` [PATCH 2/14] firmware update for av7110 dvb driver Marcel Holtmann
@ 2003-10-08 15:36     ` Michael Hunold
  2003-10-08 15:54       ` Michael Hunold
  2003-10-11 11:59     ` Jochen Friedrich
  1 sibling, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 15:36 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Linux Kernel Mailing List

Hello Marcel,

>>... send to Linus only. (You don't want a 150kB bzip2 compressed firmware blob, don't you? In case you do, drop me a line.)

> the request_firmware() framework is part of Linux 2.4 and 2.6 and so for
> most drivers the firmware file can be loaded from userspace through proc
> or sysfs. Please take a look at it.

Yes, we know. When I looked at it the last time, there were some 
problems that kept us from actually finishing the work.

(If you did not use a hotplug agent, then the system was frozen, because 
the firmware foo did not use it's own workqueue)

I gave some feedback, but I don't know if the fixes made it into the 
kernel yet.

I have once patched our drivers to use request_firmware() and I have 
these patches still lying around, so I'll try and see if they work when 
I have some spare time.

> Regards
> Marcel

CU
Michael.


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 2/14] firmware update for av7110 dvb driver
  2003-10-08 15:36     ` Michael Hunold
@ 2003-10-08 15:54       ` Michael Hunold
  2003-10-12 21:42         ` Manuel Estrada Sainz
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-08 15:54 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: ranty, Marcel Holtmann

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

Hello Marcel,
>>> ... send to Linus only. (You don't want a 150kB bzip2 compressed 
>>> firmware blob, don't you? In case you do, drop me a line.)
> 
> 
>> the request_firmware() framework is part of Linux 2.4 and 2.6 and so for
>> most drivers the firmware file can be loaded from userspace through proc
>> or sysfs. Please take a look at it.

> Yes, we know. When I looked at it the last time, there were some 
> problems that kept us from actually finishing the work.
> 
> (If you did not use a hotplug agent, then the system was frozen, because 
> the firmware foo did not use it's own workqueue)

As a follow-up to my post: I just checked what already got in and what's 
still missing. I attached the stuff from request_firmwar() that didn't 
make it into the kernel yet.

Please note that I did not check if the problem has been solved 
otherwise. Perhaps Manuel Estrada Sainz <ranty@debian.org> can tell us 
what the current state is?

CU
Michael.

[-- Attachment #2: xx-01-FC-request_firmware_own-workqueue.diff --]
[-- Type: text/plain, Size: 1103 bytes --]

diff -u -r1.3 firmware_class.c
--- linux/drivers/base/firmware_class.c	4 Jul 2003 02:21:18 -0000	1.3
+++ linux/drivers/base/firmware_class.c	26 Jul 2003 08:38:07 -0000
@@ -22,6 +22,8 @@
 MODULE_LICENSE("GPL");
 
 static int loading_timeout = 10;	/* In seconds */
+static struct workqueue_struct *firmware_wq;
+
 
 struct firmware_priv {
 	char fw_id[FIRMWARE_NAME_MAX];
@@ -467,7 +469,7 @@
 	};
 	INIT_WORK(&fw_work->work, request_firmware_work_func, fw_work);
 
-	schedule_work(&fw_work->work);
+	queue_work(firmware_wq, &fw_work->work);
 	return 0;
 }
 
@@ -485,12 +487,20 @@
 		       __FUNCTION__);
 		class_unregister(&firmware_class);
 	}
+	firmware_wq = create_workqueue("firmware");
+	if (!firmware_wq) {
+		printk(KERN_ERR "%s: create_workqueue failed\n", __FUNCTION__);
+		class_remove_file(&firmware_class, &class_attr_timeout);
+		class_unregister(&firmware_class);
+		error = -EIO;
+	}
 	return error;
 
 }
 static void __exit
 firmware_class_exit(void)
 {
+	destroy_workqueue(firmware_wq);
 	class_remove_file(&firmware_class, &class_attr_timeout);
 	class_unregister(&firmware_class);
 }

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-08 13:28 [PATCH 1/14] LinuxTV.org DVB driver update Michael Hunold
  2003-10-08 13:28 ` [PATCH 2/14] firmware update for av7110 dvb driver Michael Hunold
@ 2003-10-10 20:15 ` Stephen Hemminger
  2003-10-11  8:41   ` Michael Hunold
  1 sibling, 1 reply; 28+ messages in thread
From: Stephen Hemminger @ 2003-10-10 20:15 UTC (permalink / raw)
  To: Michael Hunold, David S. Miller; +Cc: linux-kernel

This update broke the dvb network device changes to make it work with the
new rules about dynamic allocation for 2.6.  It reverts the code to getting
the network device out of an array, so it will break if:
	rmmod dvb_net </sys/class/net/dvb0_0/mtu

See:
	Documentation/net/netdevices.txt

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-10 20:15 ` [PATCH 1/14] LinuxTV.org DVB driver update Stephen Hemminger
@ 2003-10-11  8:41   ` Michael Hunold
  2003-10-11 17:53     ` David S. Miller
  0 siblings, 1 reply; 28+ messages in thread
From: Michael Hunold @ 2003-10-11  8:41 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-dvb, David S. Miller, linux-kernel

Hello Stephen,

> This update broke the dvb network device changes to make it work with the
> new rules about dynamic allocation for 2.6.  It reverts the code to getting
> the network device out of an array, so it will break if:
> 	rmmod dvb_net </sys/class/net/dvb0_0/mtu
> See:
> 	Documentation/net/netdevices.txt

Thanks for spotting this, although I don't know what has gone wrong here 
yet. (I don't know the DVB net code very well).

I'll review this, have a talk with the original author and then send an 
update patch.

Unfortunately, I don't notice every patch that goes directly into 2.6 
without getting postet on the linux-dvb mailinglist. Now if someone 
changes stuff in our CVS in the same file, it can happen that the stuff 
from the kernel is wiped out.

CU
Michael.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 2/14] firmware update for av7110 dvb driver
  2003-10-08 14:45   ` [PATCH 2/14] firmware update for av7110 dvb driver Marcel Holtmann
  2003-10-08 15:36     ` Michael Hunold
@ 2003-10-11 11:59     ` Jochen Friedrich
  1 sibling, 0 replies; 28+ messages in thread
From: Jochen Friedrich @ 2003-10-11 11:59 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Linux Kernel Mailing List

Hi Marcel,

> the request_firmware() framework is part of Linux 2.4 and 2.6 and so for
> most drivers the firmware file can be loaded from userspace through proc
> or sysfs. Please take a look at it.

Is there a way to use this for ISA devices? I'd like to convert my
tms380tr request_firmware() as i want to get rid of hardcoded, binary
only firmware. However, there is no struct device for ISA devices (and
in particular, no bus id) and unlike the old style PCI DMA mapping, which
accepts NULL as pci_dev and assumes ISA in this case, request_firmware()
absolutely needs the parameter...

--jochen

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-11  8:41   ` Michael Hunold
@ 2003-10-11 17:53     ` David S. Miller
  2003-10-12  9:16       ` Geert Uytterhoeven
  0 siblings, 1 reply; 28+ messages in thread
From: David S. Miller @ 2003-10-11 17:53 UTC (permalink / raw)
  To: Michael Hunold; +Cc: shemminger, linux-dvb, linux-kernel

On Sat, 11 Oct 2003 10:41:43 +0200
Michael Hunold <hunold@convergence.de> wrote:

> Unfortunately, I don't notice every patch that goes directly into 2.6 
> without getting postet on the linux-dvb mailinglist. Now if someone 
> changes stuff in our CVS in the same file, it can happen that the stuff 
> from the kernel is wiped out.

It is your responsibility to resolve such things though.  It is
inevitable and unavoidable that others outside of your development
group will make many changes to your files, as we fix bugs that
are tree-wide.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-11 17:53     ` David S. Miller
@ 2003-10-12  9:16       ` Geert Uytterhoeven
  2003-10-12 11:08         ` Sam Ravnborg
  2003-10-12 20:10         ` Michael Hunold
  0 siblings, 2 replies; 28+ messages in thread
From: Geert Uytterhoeven @ 2003-10-12  9:16 UTC (permalink / raw)
  To: David S. Miller
  Cc: Michael Hunold, shemminger, linux-dvb, Linux Kernel Development

On Sat, 11 Oct 2003, David S. Miller wrote:
> On Sat, 11 Oct 2003 10:41:43 +0200
> Michael Hunold <hunold@convergence.de> wrote:
> 
> > Unfortunately, I don't notice every patch that goes directly into 2.6 
> > without getting postet on the linux-dvb mailinglist. Now if someone 
> > changes stuff in our CVS in the same file, it can happen that the stuff 
> > from the kernel is wiped out.
> 
> It is your responsibility to resolve such things though.  It is
> inevitable and unavoidable that others outside of your development
> group will make many changes to your files, as we fix bugs that
> are tree-wide.

So you best subscribe to bk-commits-head and monitor every patch that affects
drivers/media/dvb/.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-12  9:16       ` Geert Uytterhoeven
@ 2003-10-12 11:08         ` Sam Ravnborg
  2003-10-12 20:14           ` Michael Hunold
  2003-10-13 16:01           ` Stephen Hemminger
  2003-10-12 20:10         ` Michael Hunold
  1 sibling, 2 replies; 28+ messages in thread
From: Sam Ravnborg @ 2003-10-12 11:08 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: David S. Miller, Michael Hunold, shemminger, linux-dvb,
	Linux Kernel Development

On Sun, Oct 12, 2003 at 11:16:03AM +0200, Geert Uytterhoeven wrote:
> On Sat, 11 Oct 2003, David S. Miller wrote:
> > On Sat, 11 Oct 2003 10:41:43 +0200
> > Michael Hunold <hunold@convergence.de> wrote:
> > 
> > > Unfortunately, I don't notice every patch that goes directly into 2.6 
> > > without getting postet on the linux-dvb mailinglist. Now if someone 
> > > changes stuff in our CVS in the same file, it can happen that the stuff 
> > > from the kernel is wiped out.
> > 
> > It is your responsibility to resolve such things though.  It is
> > inevitable and unavoidable that others outside of your development
> > group will make many changes to your files, as we fix bugs that
> > are tree-wide.
> 
> So you best subscribe to bk-commits-head and monitor every patch that affects
> drivers/media/dvb/.

Or more simple - keep a copy of the kernel where your patches got applied,
and make a diff between that kernel and latest.
Apply that diff to your local tree, and you are up-to-date.

This gives a good opportunity to review what has been applied without
passing the maintainer.

And finally it also resolve potential conflicts.

And as always - the more frequent you get patches applied, the less burden
it is to update to latest kernel.

	Sam

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-12  9:16       ` Geert Uytterhoeven
  2003-10-12 11:08         ` Sam Ravnborg
@ 2003-10-12 20:10         ` Michael Hunold
  1 sibling, 0 replies; 28+ messages in thread
From: Michael Hunold @ 2003-10-12 20:10 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Linux Kernel Development

Hello Geert,

> So you best subscribe to bk-commits-head and monitor every patch that affects
> drivers/media/dvb/.

Thanks for that hint -- I should have thought about that before. 8-)
I just subscribed to that list.

> Gr{oetje,eeting}s,
> 						Geert

CU
Michael.


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-12 11:08         ` Sam Ravnborg
@ 2003-10-12 20:14           ` Michael Hunold
  2003-10-13 16:01           ` Stephen Hemminger
  1 sibling, 0 replies; 28+ messages in thread
From: Michael Hunold @ 2003-10-12 20:14 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Linux Kernel Development

Hello Sam,

>>>It is your responsibility to resolve such things though.  It is
>>>inevitable and unavoidable that others outside of your development
>>>group will make many changes to your files, as we fix bugs that
>>>are tree-wide.
>>
>>So you best subscribe to bk-commits-head and monitor every patch that affects
>>drivers/media/dvb/.
> 
> 
> Or more simple - keep a copy of the kernel where your patches got applied,
> and make a diff between that kernel and latest.
> Apply that diff to your local tree, and you are up-to-date.
> 
> This gives a good opportunity to review what has been applied without
> passing the maintainer.

Yes, another good hint. Thanks!

> 	Sam

CU
Michael.


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 2/14] firmware update for av7110 dvb driver
  2003-10-08 15:54       ` Michael Hunold
@ 2003-10-12 21:42         ` Manuel Estrada Sainz
  0 siblings, 0 replies; 28+ messages in thread
From: Manuel Estrada Sainz @ 2003-10-12 21:42 UTC (permalink / raw)
  To: Michael Hunold; +Cc: Linux Kernel Mailing List, Marcel Holtmann, Andrew Morton

On Wed, Oct 08, 2003 at 05:54:18PM +0200, Michael Hunold wrote:
> Hello Marcel,
> >>>... send to Linus only. (You don't want a 150kB bzip2 compressed 
> >>>firmware blob, don't you? In case you do, drop me a line.)
> >
> >
> >>the request_firmware() framework is part of Linux 2.4 and 2.6 and so for
> >>most drivers the firmware file can be loaded from userspace through proc
> >>or sysfs. Please take a look at it.
> 
> >Yes, we know. When I looked at it the last time, there were some 
> >problems that kept us from actually finishing the work.
> >
> >(If you did not use a hotplug agent, then the system was frozen, because 
> >the firmware foo did not use it's own workqueue)
> 
> As a follow-up to my post: I just checked what already got in and what's 
> still missing. I attached the stuff from request_firmwar() that didn't 
> make it into the kernel yet.
> 
> Please note that I did not check if the problem has been solved 
> otherwise. Perhaps Manuel Estrada Sainz <ranty@debian.org> can tell us 
> what the current state is?

 The patch should work but Andrew Morton didn't like the fact that in
 practice the kernel end's up having some threads around full time for
 the sole purpose of loading firmware once in a while.

 I should make a new patch to spawn a thread for each firmware load and
 have them die when the job is done. And stop using workqueues at all.

 	- Performance should not be an issue since firmware should
	  seldom be needed.
	- Code complexity shouldn't change much either.

 Comments are welcomed.

 If the issue seams urgent, the current "private workqueue" patch could
 be applied and replaced later with a cleaner solution.
 
 Just for the record I should get the job done within a couple of weeks.
 A proposal patch would of course help :)

 Have a nice day

 	Manuel

-- 
--- Manuel Estrada Sainz <ranty@debian.org>
                         <ranty@bigfoot.com>
			 <ranty@users.sourceforge.net>
------------------------ <manuel.estrada@hispalinux.es> -------------------
Let us have the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-12 11:08         ` Sam Ravnborg
  2003-10-12 20:14           ` Michael Hunold
@ 2003-10-13 16:01           ` Stephen Hemminger
  2003-10-14  9:59             ` Michael Hunold
  1 sibling, 1 reply; 28+ messages in thread
From: Stephen Hemminger @ 2003-10-13 16:01 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Geert Uytterhoeven, David S. Miller, Michael Hunold, linux-dvb,
	Linux Kernel Development

I think root cause of the problem is that dvb was only just been added
to the MAINTAINERS file so the patch got lost when I sent to closet
match was the video lists. It was kind of orphan thing since it crossed
both networking and DVB.

Do you need any help in reinserting it?

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 1/14] LinuxTV.org DVB driver update
  2003-10-13 16:01           ` Stephen Hemminger
@ 2003-10-14  9:59             ` Michael Hunold
  0 siblings, 0 replies; 28+ messages in thread
From: Michael Hunold @ 2003-10-14  9:59 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Linux Kernel Development

Hello Stephen,

> I think root cause of the problem is that dvb was only just been added
> to the MAINTAINERS file so the patch got lost when I sent to closet
> match was the video lists. It was kind of orphan thing since it crossed
> both networking and DVB.

I just browsed thorugh the changelogs at
http://linus.bkbits.net:8080/linux-2.5/src/drivers/media/dvb?nav=index.html|src/.|src/drivers|src/drivers/media
and back-feeded the changes that did not make it into our local CVS yet.

> Do you need any help in reinserting it?

Thanks for your offer. But I have just cut out your patch, "reversed 
it", compile tested it and sent it to lkml.

CU
Michael.


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2003-10-14  9:59 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-08 13:28 [PATCH 1/14] LinuxTV.org DVB driver update Michael Hunold
2003-10-08 13:28 ` [PATCH 2/14] firmware update for av7110 dvb driver Michael Hunold
2003-10-08 13:28   ` [PATCH 3/14] add new DVB-T frontend driver Michael Hunold
2003-10-08 13:28     ` [PATCH 4/14] video capture updates for saa7146 core Michael Hunold
2003-10-08 13:28       ` [PATCH 5/14] multiple device *read* opens support Michael Hunold
2003-10-08 13:28         ` [PATCH 6/14] update copyright and licensing Michael Hunold
2003-10-08 13:28           ` [PATCH 7/14] usual c99 initializer fixes Michael Hunold
2003-10-08 13:28             ` [PATCH 8/14] various patches for non-av7110 dvb-drivers Michael Hunold
2003-10-08 13:28               ` [PATCH 9/14] various av7110 dvb-driver updates Michael Hunold
2003-10-08 13:28                 ` [PATCH 10/14] update dvb frontend drivers Michael Hunold
2003-10-08 13:28                   ` [PATCH 11/14] Kconfig and Makefile updates, inspired by Adrian Bunk and Roman Zippel Michael Hunold
2003-10-08 13:28                     ` [PATCH 12/14] some more av7110 dvb-driver updates Michael Hunold
2003-10-08 13:29                       ` [PATCH 13/14] fix v4l1 backward compatibility in saa7146 driver Michael Hunold
2003-10-08 13:29                         ` [PATCH 14/14] firmware blob for new DVB-T frontend driver Michael Hunold
2003-10-08 14:45   ` [PATCH 2/14] firmware update for av7110 dvb driver Marcel Holtmann
2003-10-08 15:36     ` Michael Hunold
2003-10-08 15:54       ` Michael Hunold
2003-10-12 21:42         ` Manuel Estrada Sainz
2003-10-11 11:59     ` Jochen Friedrich
2003-10-10 20:15 ` [PATCH 1/14] LinuxTV.org DVB driver update Stephen Hemminger
2003-10-11  8:41   ` Michael Hunold
2003-10-11 17:53     ` David S. Miller
2003-10-12  9:16       ` Geert Uytterhoeven
2003-10-12 11:08         ` Sam Ravnborg
2003-10-12 20:14           ` Michael Hunold
2003-10-13 16:01           ` Stephen Hemminger
2003-10-14  9:59             ` Michael Hunold
2003-10-12 20:10         ` Michael Hunold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).