diff -r 359d95e1d541 -r f22da8d6a83c linux/drivers/media/dvb/dm1105/dm1105.c
--- a/linux/drivers/media/dvb/dm1105/dm1105.cÂ Â Â Wed Feb 18 09:49:37 2009 -0300
+++ b/linux/drivers/media/dvb/dm1105/dm1105.cÂ Â Â Thu Feb 19 04:38:32 2009 +0200
@@ -220,10 +220,14 @@
Â Â Â Â Â Â Â Â /* i2c */
Â Â Â Â Â Â Â Â struct i2c_adapter i2c_adap;
Â 
+Â Â Â Â Â Â Â /* irq */
+Â Â Â Â Â Â Â struct work_struct work;
+
Â Â Â Â Â Â Â Â /* dma */
Â Â Â Â Â Â Â Â dma_addr_t dma_addr;
Â Â Â Â Â Â Â Â unsigned char *ts_buf;
Â Â Â Â Â Â Â Â u32 wrp;
+Â Â Â Â Â Â Â u32 nextwrp;
Â Â Â Â Â Â Â Â u32 buffer_size;
Â Â Â Â Â Â Â Â unsigned intÂ Â Â Â PacketErrorCount;
Â Â Â Â Â Â Â Â unsigned int dmarst;
@@ -418,6 +422,9 @@
Â Â Â Â Â Â Â Â u8 data;
Â Â Â Â Â Â Â Â u16 keycode;
Â 
+Â Â Â Â Â Â Â if (ir_debug)
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk(KERN_INFO "%s: received byte 0x%04x\n", __func__, ircom);
+
Â Â Â Â Â Â Â Â data = (ircom >> 8) & 0x7f;
Â 
Â Â Â Â Â Â Â Â input_event(ir->input_dev, EV_MSC, MSC_RAW, (0x0000f8 << 16) | data);
@@ -434,6 +441,50 @@
Â 
Â }
Â 
+/* work handler */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void dm1105_dmx_buffer(void *_dm1105dvb)
+#else
+static void dm1105_dmx_buffer(struct work_struct *work)
+#endif
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+Â Â Â Â Â Â Â struct dm1105dvb *dm1105dvb = _dm1105dvb;
+#else
+Â Â Â Â Â Â Â struct dm1105dvb *dm1105dvb =
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â container_of(work, struct dm1105dvb, work);
+#endif
+Â Â Â Â Â Â Â unsigned int nbpackets;
+Â Â Â Â Â Â Â u32 oldwrp = dm1105dvb->wrp;
+Â Â Â Â Â Â Â u32 nextwrp = dm1105dvb->nextwrp;
+
+Â Â Â Â Â Â Â if (!((dm1105dvb->ts_buf[oldwrp] == 0x47) &&
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (dm1105dvb->ts_buf[oldwrp + 188] == 0x47) &&
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (dm1105dvb->ts_buf[oldwrp + 188 * 2] == 0x47))) {
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->PacketErrorCount++;
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* bad packet found */
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if ((dm1105dvb->PacketErrorCount >= 2) &&
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (dm1105dvb->dmarst == 0)) {
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â outb(1, dm_io_mem(DM1105_RST));
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->wrp = 0;
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->PacketErrorCount = 0;
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->dmarst = 0;
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return;
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
+Â Â Â Â Â Â Â }
+
+Â Â Â Â Â Â Â if (nextwrp < oldwrp) {
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â memcpy(dm1105dvb->ts_buf + dm1105dvb->buffer_size,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->ts_buf, nextwrp);
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nbpackets = ((dm1105dvb->buffer_size - oldwrp) + nextwrp) / 188;
+Â Â Â Â Â Â Â } else
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nbpackets = (nextwrp - oldwrp) / 188;
+
+Â Â Â Â Â Â Â dm1105dvb->wrp = nextwrp;
+Â Â Â Â Â Â Â dvb_dmx_swfilter_packets(&dm1105dvb->demux,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &dm1105dvb->ts_buf[oldwrp], nbpackets);
+}
+
Â #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
Â static irqreturn_t dm1105dvb_irq(int irq, void *dev_id, struct pt_regs *regs)
Â #else
@@ -441,11 +492,6 @@
Â #endif
Â {
Â Â Â Â Â Â Â Â struct dm1105dvb *dm1105dvb = dev_id;
-Â Â Â Â Â Â Â unsigned int piece;
-Â Â Â Â Â Â Â unsigned int nbpackets;
-Â Â Â Â Â Â Â u32 command;
-Â Â Â Â Â Â Â u32 nextwrp;
-Â Â Â Â Â Â Â u32 oldwrp;
Â 
Â Â Â Â Â Â Â Â /* Read-Write INSTS Ack's Interrupt for DM1105 chip 16.03.2008 */
Â Â Â Â Â Â Â Â unsigned int intsts = inb(dm_io_mem(DM1105_INTSTS));
@@ -454,48 +500,17 @@
Â Â Â Â Â Â Â Â switch (intsts) {
Â Â Â Â Â Â Â Â case INTSTS_TSIRQ:
Â Â Â Â Â Â Â Â case (INTSTS_TSIRQ | INTSTS_IR):
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nextwrp = inl(dm_io_mem(DM1105_WRP)) -
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â inl(dm_io_mem(DM1105_STADR)) ;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oldwrp = dm1105dvb->wrp;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â spin_lock(&dm1105dvb->lock);
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (!((dm1105dvb->ts_buf[oldwrp] == 0x47) &&
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (dm1105dvb->ts_buf[oldwrp + 188] == 0x47) &&
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (dm1105dvb->ts_buf[oldwrp + 188 * 2] == 0x47))) {
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->PacketErrorCount++;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* bad packet found */
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if ((dm1105dvb->PacketErrorCount >= 2) &&
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (dm1105dvb->dmarst == 0)) {
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â outb(1, dm_io_mem(DM1105_RST));
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->wrp = 0;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->PacketErrorCount = 0;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->dmarst = 0;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â spin_unlock(&dm1105dvb->lock);
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return IRQ_HANDLED;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (nextwrp < oldwrp) {
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â piece = dm1105dvb->buffer_size - oldwrp;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â memcpy(dm1105dvb->ts_buf + dm1105dvb->buffer_size, dm1105dvb->ts_buf, 
nextwrp);
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nbpackets = (piece + nextwrp)/188;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } elseÂ Â {
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nbpackets = (nextwrp - oldwrp)/188;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dvb_dmx_swfilter_packets(&dm1105dvb->demux, &dm1105dvb->ts_buf[oldwrp], 
nbpackets);
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->wrp = nextwrp;
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â spin_unlock(&dm1105dvb->lock);
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->nextwrp = inl(dm_io_mem(DM1105_WRP)) -
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â inl(dm_io_mem(DM1105_STADR));
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â schedule_work(&dm1105dvb->work);
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
Â Â Â Â Â Â Â Â case INTSTS_IR:
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â command = inl(dm_io_mem(DM1105_IRCODE));
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (ir_debug)
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("dm1105: received byte 0x%04x\n", command);
-
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->ir.ir_command = command;
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dm1105dvb->ir.ir_command = inl(dm_io_mem(DM1105_IRCODE));
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tasklet_schedule(&dm1105dvb->ir.ir_tasklet);
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
Â Â Â Â Â Â Â Â }
+
Â Â Â Â Â Â Â Â return IRQ_HANDLED;
-
-
Â }
