В сообщении от 9 November 2007 19:10:11 Igor M. Liplianin написал(а): > Glad to inform, that I start working on Acorp DS110 PCI DVB-S driver. > The card contains DM1105 chip to receive DVB Transport Stream with PCI > interface. For those, who interested - early and buggy dm1105 driver. Needs manual loading for proper work. But works! http://liplianin.at.tut.by -- Igor M. Liplianin
diff -crN v4l-dvb-08122007/linux/drivers/media/dvb/Kconfig v4l-dvb-dm1105/linux/drivers/media/dvb/Kconfig *** v4l-dvb-08122007/linux/drivers/media/dvb/Kconfig 2007-12-08 22:14:08.000000000 +0200 --- v4l-dvb-dm1105/linux/drivers/media/dvb/Kconfig 2007-12-08 22:22:33.000000000 +0200 *************** *** 36,41 **** --- 36,45 ---- depends on DVB_CORE && PCI && I2C source "drivers/media/dvb/pluto2/Kconfig" + comment "Supported DM1105 Adapters" + depends on DVB_CORE && PCI && I2C + source "drivers/media/dvb/dm1105/Kconfig" + comment "Supported DVB Frontends" depends on DVB_CORE source "drivers/media/dvb/frontends/Kconfig" diff -crN v4l-dvb-08122007/linux/drivers/media/dvb/Makefile v4l-dvb-dm1105/linux/drivers/media/dvb/Makefile *** v4l-dvb-08122007/linux/drivers/media/dvb/Makefile 2007-12-08 22:14:08.000000000 +0200 --- v4l-dvb-dm1105/linux/drivers/media/dvb/Makefile 2007-12-08 22:23:05.000000000 +0200 *************** *** 2,5 **** # Makefile for the kernel multimedia device drivers. # ! obj-y := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ cinergyT2/ dvb-usb/ pluto2/ --- 2,5 ---- # Makefile for the kernel multimedia device drivers. # ! obj-y := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ cinergyT2/ dvb-usb/ pluto2/ dm1105/ diff -crN v4l-dvb-08122007/linux/drivers/media/dvb/dm1105/Kconfig v4l-dvb-dm1105/linux/drivers/media/dvb/dm1105/Kconfig *** v4l-dvb-08122007/linux/drivers/media/dvb/dm1105/Kconfig 1970-01-01 03:00:00.000000000 +0300 --- v4l-dvb-dm1105/linux/drivers/media/dvb/dm1105/Kconfig 2007-12-08 17:50:38.000000000 +0200 *************** *** 0 **** --- 1,15 ---- + config DVB_DM1105 + tristate "DM1105 based cards" + depends on DVB_CORE && PCI && I2C + select DVB_PLL if !DVB_FE_CUSTOMISE + select DVB_STV0299 if !DVB_FE_CUSTOMISE + help + Support for PCI cards based on the DM1105 like the Acorp + DS110. + + Since these cards have no MPEG decoder onboard, they transmit + only compressed MPEG data over the PCI bus, so you need + an external software decoder to watch TV on your computer. + + Say Y or M if you own such a device and want to use it. + diff -crN v4l-dvb-08122007/linux/drivers/media/dvb/dm1105/Makefile v4l-dvb-dm1105/linux/drivers/media/dvb/dm1105/Makefile *** v4l-dvb-08122007/linux/drivers/media/dvb/dm1105/Makefile 1970-01-01 03:00:00.000000000 +0300 --- v4l-dvb-dm1105/linux/drivers/media/dvb/dm1105/Makefile 2007-11-23 21:23:56.000000000 +0200 *************** *** 0 **** --- 1,3 ---- + obj-$(CONFIG_DVB_DM1105) += dm1105.o + + EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends diff -crN v4l-dvb-08122007/linux/drivers/media/dvb/dm1105/dm1105.c v4l-dvb-dm1105/linux/drivers/media/dvb/dm1105/dm1105.c *** v4l-dvb-08122007/linux/drivers/media/dvb/dm1105/dm1105.c 1970-01-01 03:00:00.000000000 +0300 --- v4l-dvb-dm1105/linux/drivers/media/dvb/dm1105/dm1105.c 2007-12-08 23:10:48.000000000 +0200 *************** *** 0 **** --- 1,681 ---- + /* + * dm1105.c - DVBWorld PCI2002 [DVB-S] + * + * Copyright (C) 2007 Igor M. Liplianin <liplianin@xxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + + #include <linux/i2c.h> + //#include <linux/i2c-algo-bit.h> + #include <linux/init.h> + #include <linux/kernel.h> + #include <linux/module.h> + #include <linux/pci.h> + #include <linux/dma-mapping.h> + + #include "demux.h" + #include "dmxdev.h" + #include "dvb_demux.h" + #include "dvb_frontend.h" + #include "dvb_net.h" + #include "dvbdev.h" + #include "dvb-pll.h" + + #include "stv0299.h" + #include "bsru6.h" + + /* sdmc dm1105 registers */ + /* ----------------------------------------------- */ + /* + * PCI ID's + */ + #ifndef PCI_DEVICE_ID_TRIGEM_DM1105 + # define PCI_DEVICE_ID_TRIGEM_DM1105 0x036f + #endif + /* ----------------------------------------------- */ + + /* TS Control */ + #define DM1105_TSCTR 0x00 + #define DM1105_DTALENTH 0x04 + + /* GPIO Interface */ + #define DM1105_GPIOVAL 0x08 + #define DM1105_POWER 0x08 + #define GPIO89DATA 0x09 + #define DM1105_GPIOCTR 0x0c + #define GPIO89DIR 0x0D + + /* PID serial number */ + #define DM1105_PIDN 0x10 + + /* Odd-even secret key select */ + #define DM1105_CWSEL 0x14 + + /* Host Command Interface */ + #define DM1105_HOST_CTR 0x18 + #define DM1105_HOST_AD 0x1c + + /* PCI Interface */ + #define DM1105_CR 0x30 + #define DM1105_RST 0x34 + #define DM1105_STADR 0x38 + #define DM1105_RLEN 0x3c + #define DM1105_WRP 0x40 + #define DM1105_INTCNT 0x44 + #define DM1105_INTMAK 0x48 + #define DM1105_INTSTS 0x4c + + /* CW Value */ + #define DM1105_ODD 0x50 + #define DM1105_EVEN 0x58 + + /* PID Value */ + #define DM1105_PID 0x60 + + /* IR Control */ + #define DM1105_IRCTR 0x64 + #define DM1105_IRMODE 0x68 + #define DM1105_SYSTEMCODE 0x6c + #define DM1105_IRCODE 0x70 + + /* I2C Interface */ + #define DM1105_I2CCTR 0x80 + #define DM1105_I2CSTS 0x81 + #define DM1105_I2CDAT 0x82 + #define DM1105_I2C_RA 0x83 + + /* Masks */ + #define INTMAK_ALLMASK 0x01 + + /* EEPROM addr */ + #define IIC_24C01_addr 0xa0 + /* Max board count */ + #define DM1105_MAX 0x04 + /* ----------------------------------------------- */ + + #define DRIVER_NAME "dm1105" + + #define DM1105_DMA_PACKETS (47) + #define DM1105_DMA_BYTES (128 * 4 * DM1105_DMA_PACKETS) + + #ifndef PCI_VENDOR_ID_TRIGEM + #define PCI_VENDOR_ID_TRIGEM 0x109f + #endif + #ifndef PCI_DEVICE_ID_DM1105 + #define PCI_DEVICE_ID_DM1105 0x036f + #endif + + struct dm1105dvb { + /* pci */ + struct pci_dev *pdev; + u8 __iomem *io_mem; + + /* dvb */ + struct dmx_frontend hw_frontend; + struct dmx_frontend mem_frontend; + struct dmxdev dmxdev; + struct dvb_adapter dvb_adapter; + struct dvb_demux demux; + struct dvb_frontend *fe; + struct dvb_net dvbnet; + unsigned int full_ts_users; + unsigned int users; + + /* i2c */ + struct i2c_adapter i2c_adap; + + /* irq */ + struct tasklet_struct vpe_tasklet; + + /* dma */ + dma_addr_t dma_addr; + unsigned char *ts_buf; + /*u8 dma_buf[10*DM1105_DMA_BYTES];*/ + u32 wrp; + u32 buffer_size; + unsigned int PacketErrorCount; + unsigned char dmarst; + spinlock_t lock; + + }; + unsigned char DMARSTFLAG = 0; + static int dm1105_i2c_xfer(struct i2c_adapter *i2c_adap, + struct i2c_msg *msgs, int num) + { + struct dm1105dvb *dm1105dvb ; + + int addr,rc,i,j,byte,data; + void *ioaddr; + u8 status; + + dm1105dvb = i2c_adap->algo_data; + ioaddr = dm1105dvb->io_mem; + for (i = 0; i < num; i++) { + outb(0x00, (unsigned long)(&dm1105dvb->io_mem[DM1105_I2CCTR])); + if (msgs[i].flags & I2C_M_RD) { + /* read bytes */ + addr = msgs[i].addr << 1; + addr |= 1; + outb(addr, (unsigned long)(&dm1105dvb->io_mem[DM1105_I2CDAT])); + for (byte = 0; byte < msgs[i].len; byte++) { + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_I2CDAT+byte+1])); + } + outb(0x81 + msgs[i].len, (unsigned long)(&dm1105dvb->io_mem[DM1105_I2CCTR])); + for (j = 0; j < 55; i++){ + mdelay (10); // 10ms + status = inb((unsigned long)&dm1105dvb->io_mem[DM1105_I2CSTS]); + if ((status & 0xc0) == 0x40) + break; + } + if (j >= 55){ + return -1; + } + for (byte = 0; byte < msgs[i].len; byte++) { + + rc = inb((unsigned long)(&dm1105dvb->io_mem[DM1105_I2CDAT+byte+1])); + if (rc < 0) + goto err; + msgs[i].buf[byte] = rc; + + } + } else { + /* write bytes */ + outb(msgs[i].addr<<1, (unsigned long)(&dm1105dvb->io_mem[DM1105_I2CDAT])); + for (byte = 0; byte < msgs[i].len; byte++) { + data = msgs[i].buf[byte]; + outb(data, (unsigned long)(&dm1105dvb->io_mem[DM1105_I2CDAT+byte+1])); + } + outb(0x81 + msgs[i].len, (unsigned long)(&dm1105dvb->io_mem[DM1105_I2CCTR])); + for (j = 0; j < 25; i++){ + mdelay (10); // 10ms + status = inb((unsigned long)(&dm1105dvb->io_mem[DM1105_I2CSTS])); + if ((status & 0xc0) == 0x40) + break; + } + + if (j >= 25){ + return -1; + } + } + } + return num; + err: + return rc; + } + + static u32 functionality(struct i2c_adapter *adap) + { + return I2C_FUNC_I2C; + } + + static struct i2c_algorithm dm1105_algo = { + .master_xfer = dm1105_i2c_xfer, + .functionality = functionality, + }; + + static inline struct dm1105dvb *feed_to_dm1105dvb(struct dvb_demux_feed *feed) + { + return container_of(feed->demux, struct dm1105dvb, demux); + } + + static inline struct dm1105dvb *frontend_to_dm1105dvb(struct dvb_frontend *fe) + { + return container_of(fe->dvb, struct dm1105dvb, dvb_adapter); + } + + static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) + { + struct dm1105dvb *dm1105dvb = frontend_to_dm1105dvb(fe); + + if (voltage == SEC_VOLTAGE_18) { + outl(0xfffcffff, (unsigned long)(&dm1105dvb->io_mem[DM1105_GPIOCTR])); + outl(0x0ffff, (unsigned long)(&dm1105dvb->io_mem[DM1105_POWER])); + }else { + /*LNB ON-13V by default!*/ + outl(0xfffcffff, (unsigned long)(&dm1105dvb->io_mem[DM1105_GPIOCTR])); + outl(0x1ffff, (unsigned long)(&dm1105dvb->io_mem[DM1105_POWER])); + } + + return 0; + } + + static void dm1105dvb_set_dma_addr(struct dm1105dvb *dm1105dvb) + { + outl(cpu_to_le32(dm1105dvb->dma_addr), (unsigned long)(&dm1105dvb->io_mem[DM1105_STADR])); + } + + static int __devinit dm1105dvb_dma_map(struct dm1105dvb *dm1105dvb) + { + dm1105dvb->ts_buf = pci_alloc_consistent(dm1105dvb->pdev, 11*DM1105_DMA_BYTES, &dm1105dvb->dma_addr); + /* dm1105dvb->dma_addr = pci_map_single(dm1105dvb->pdev, dm1105dvb->dma_buf, + 5*DM1105_DMA_BYTES, PCI_DMA_FROMDEVICE);*/ + + return pci_dma_mapping_error(dm1105dvb->dma_addr); + } + /* liplianin */ + static void dm1105dvb_dma_unmap(struct dm1105dvb *dm1105dvb) + { + pci_free_consistent(dm1105dvb->pdev, 11*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr); + /*pci_unmap_single(dm1105dvb->pdev, dm1105dvb->dma_addr, + 5*DM1105_DMA_BYTES, PCI_DMA_FROMDEVICE);*/ + } + + static int dm1105dvb_start_feed(struct dvb_demux_feed *f) + { + struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f); + + if (dm1105dvb->full_ts_users++ == 0){ + outb(1 ,(unsigned long)(&dm1105dvb->io_mem[DM1105_CR])); + outb(1 ,(unsigned long)(&dm1105dvb->io_mem[DM1105_INTMAK])); + } + return 0; + } + + static int dm1105dvb_stop_feed(struct dvb_demux_feed *f) + { + struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f); + + if (--dm1105dvb->full_ts_users == 0){ + outb(0 ,(unsigned long)(&dm1105dvb->io_mem[DM1105_CR])); + outb( 0 ,(unsigned long)(&dm1105dvb->io_mem[DM1105_INTMAK])); + } + return 0; + } + + static void vpeirq(unsigned long data) + { + struct dm1105dvb *dm1105dvb = (struct dm1105dvb *) data; + unsigned int nbpackets, piece; + u32 nextwrp = inl((unsigned long)(&dm1105dvb->io_mem[DM1105_WRP])) - + inl((unsigned long)(&dm1105dvb->io_mem[DM1105_STADR])) ; + u32 oldwrp = dm1105dvb->wrp; + + spin_lock(&dm1105dvb->lock); + if (nextwrp==oldwrp){ + spin_unlock(&dm1105dvb->lock); + return; + } + + if (!((dm1105dvb->ts_buf[oldwrp] == 0x47 ) && (dm1105dvb->ts_buf[oldwrp + 188]== 0x47 ) + && (dm1105dvb->ts_buf[oldwrp + 188*2] == 0x47))) { + dm1105dvb->PacketErrorCount++; + /*printk("Bad Packet Found! NIC Device Reset ! ----%06x ----%06x\n",oldwrp,nextwrp);*/ + if((dm1105dvb->PacketErrorCount >= 2)&&(dm1105dvb->dmarst == 0)){ + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_INTMAK])); + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_CR])); + outb(1, (unsigned long)(&dm1105dvb->io_mem[DM1105_RST])); + outb(1, (unsigned long)(&dm1105dvb->io_mem[DM1105_CR])); + outb(0x0f, (unsigned long)(&dm1105dvb->io_mem[DM1105_INTSTS])); + outb(INTMAK_ALLMASK, (unsigned long)(&dm1105dvb->io_mem[DM1105_INTMAK])); + dm1105dvb->wrp = 0; + dm1105dvb->PacketErrorCount=0; + dm1105dvb->dmarst = 0; + spin_unlock(&dm1105dvb->lock); + return; + } + } + if (nextwrp > oldwrp){ + nbpackets = (nextwrp - oldwrp)/188; + } + if (nextwrp<oldwrp){ + piece = dm1105dvb->buffer_size - oldwrp; + memcpy(dm1105dvb->ts_buf + dm1105dvb->buffer_size, dm1105dvb->ts_buf, nextwrp); + nbpackets = (piece + nextwrp)/188; + } + dvb_dmx_swfilter_packets(&dm1105dvb->demux, &dm1105dvb->ts_buf[oldwrp], nbpackets); + dm1105dvb->wrp = nextwrp; + spin_unlock(&dm1105dvb->lock); + } + + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + static irqreturn_t dm1105dvb_irq(int irq, void *dev_id, struct pt_regs *regs) + #else + static irqreturn_t dm1105dvb_irq(int irq, void *dev_id) + #endif + { + struct dm1105dvb *dm1105dvb = dev_id; + + if (dm1105dvb->pdev->irq==irq) + //tasklet_schedule(&dm1105dvb->vpe_tasklet); + vpeirq(dev_id); + return IRQ_HANDLED; + } + + static void __devinit dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb) + { + outb(1, (unsigned long)(&dm1105dvb->io_mem[DM1105_INTMAK])); + outb(1, (unsigned long)(&dm1105dvb->io_mem[DM1105_CR])); + } + + static void dm1105dvb_disable_irqs(struct dm1105dvb *dm1105dvb) + { + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_INTMAK])); + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_CR])); + } + + static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb) + { + disable_irq(dm1105dvb->pdev->irq); + dm1105dvb_disable_irqs(dm1105dvb); + + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_INTSTS])); + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_IRCTR])); + outb(0, (unsigned long)(&dm1105dvb->io_mem[DM1105_HOST_CTR])); + + /*DATALEN 188,*/ + outb(188, (unsigned long)(&dm1105dvb->io_mem[DM1105_DTALENTH])); + /*TS_STRT TS_VALP MSBFIRST TS_MODE ALPAS TSPES*/ + outw(0xc12a, (unsigned long)(&dm1105dvb->io_mem[DM1105_TSCTR])); + + /*LNB ON-13V by default!*/ + //outl(0xfffcffff, (unsigned long)(&dm1105dvb->io_mem[DM1105_GPIOCTR])); + //outl(0x1ffff, (unsigned long)(&dm1105dvb->io_mem[DM1105_POWER])); + + + /* map DMA and set address */ + dm1105dvb_dma_map(dm1105dvb); + dm1105dvb_set_dma_addr(dm1105dvb); + /* big buffer */ + outl(10*DM1105_DMA_BYTES, (unsigned long)(&dm1105dvb->io_mem[DM1105_RLEN])); + outb(47, (unsigned long)(&dm1105dvb->io_mem[DM1105_INTCNT])); + + outb(1, (unsigned long)(&dm1105dvb->io_mem[DM1105_RST])); + + /* enable interrupts */ + dm1105dvb_enable_irqs(dm1105dvb); + enable_irq(dm1105dvb->pdev->irq); + + return 0; + } + + static void dm1105dvb_hw_exit(struct dm1105dvb *dm1105dvb) + { + dm1105dvb_disable_irqs(dm1105dvb); + tasklet_kill(&dm1105dvb->vpe_tasklet); + dm1105dvb_dma_unmap(dm1105dvb); + } + + static int __devinit frontend_init(struct dm1105dvb *dm1105dvb) + { + int ret; + + dm1105dvb->fe = dvb_attach( + stv0299_attach, &alps_bsru6_config, + &dm1105dvb->i2c_adap); + + if (!dm1105dvb->fe) { + dev_err(&dm1105dvb->pdev->dev, "could not attach frontend\n"); + return -ENODEV; + } + dm1105dvb->fe->ops.set_voltage = dm1105dvb_set_voltage; + + dvb_attach( + dvb_pll_attach, dm1105dvb->fe, 0x60, + &dm1105dvb->i2c_adap, DVB_PLL_OPERA1); + + + ret = dvb_register_frontend(&dm1105dvb->dvb_adapter, dm1105dvb->fe); + if (ret < 0) { + if (dm1105dvb->fe->ops.release) + dm1105dvb->fe->ops.release(dm1105dvb->fe); + return ret; + } + + return 0; + } + + /*static void __devinit dm1105dvb_read_rev(struct dm1105dvb *dm1105dvb) + { + + } + */ + static void __devinit dm1105dvb_read_mac(struct dm1105dvb *dm1105dvb, u8 *mac) + { + static u8 command[1]={0x28}; + + struct i2c_msg msg[] = { + {.addr = IIC_24C01_addr>>1, .flags = 0, .buf = command, .len = 1}, + {.addr = IIC_24C01_addr>>1, .flags = I2C_M_RD, .buf = mac, .len = 6}, + }; + + dm1105_i2c_xfer(&dm1105dvb->i2c_adap, msg , 2); + dev_info(&dm1105dvb->pdev->dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + } + /* + static int __devinit dm1105dvb_read_serial(struct dm1105dvb *dm1105dvb) + { + + }*/ + + static int __devinit dm1105_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) + { + struct dm1105dvb *dm1105dvb; + struct dvb_adapter *dvb_adapter; + struct dvb_demux *dvbdemux; + struct dmx_demux *dmx; + int ret = -ENOMEM; + + dm1105dvb = kzalloc(sizeof(struct dm1105dvb), GFP_KERNEL); + if (!dm1105dvb) + goto out; + + dm1105dvb->pdev = pdev; + dm1105dvb->buffer_size = 10*DM1105_DMA_BYTES; + dm1105dvb->PacketErrorCount = 0; + dm1105dvb->dmarst = 0; + + ret = pci_enable_device(pdev); + if (ret < 0) + goto err_kfree; + + ret = pci_set_dma_mask(pdev, DMA_32BIT_MASK); + if (ret < 0) + goto err_pci_disable_device; + + pci_set_master(pdev); + + ret = pci_request_regions(pdev, DRIVER_NAME); + if (ret < 0) + goto err_pci_disable_device; + + dm1105dvb->io_mem = pci_iomap(pdev, 0, pci_resource_len (pdev, 0)); + if (!dm1105dvb->io_mem) { + ret = -EIO; + goto err_pci_release_regions; + } + + outb(1, (unsigned long)&dm1105dvb->io_mem[DM1105_RST]); + mdelay(1); + spin_lock_init (&dm1105dvb->lock); + pci_set_drvdata(pdev, dm1105dvb); + + ret = request_irq(pdev->irq, dm1105dvb_irq, IRQF_SHARED, DRIVER_NAME, dm1105dvb); + if (ret < 0) + goto err_pci_iounmap; + + ret = dm1105dvb_hw_init(dm1105dvb); + if (ret < 0) + goto err_free_irq; + + /* i2c */ + i2c_set_adapdata(&dm1105dvb->i2c_adap, dm1105dvb); + strcpy(dm1105dvb->i2c_adap.name, DRIVER_NAME); + dm1105dvb->i2c_adap.owner = THIS_MODULE; + dm1105dvb->i2c_adap.class = I2C_CLASS_TV_DIGITAL; + dm1105dvb->i2c_adap.dev.parent = &pdev->dev; + dm1105dvb->i2c_adap.algo = &dm1105_algo; + dm1105dvb->i2c_adap.algo_data = dm1105dvb; + ret = i2c_add_adapter(&dm1105dvb->i2c_adap); + + if (ret < 0) + goto err_dm1105dvb_hw_exit; + + /* dvb */ + ret = dvb_register_adapter(&dm1105dvb->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev); + if (ret < 0) + goto err_i2c_del_adapter; + + dvb_adapter = &dm1105dvb->dvb_adapter; + + /*dm1105dvb_read_rev(dm1105dvb); + dm1105dvb_read_serial(dm1105dvb);*/ + dm1105dvb_read_mac(dm1105dvb, dvb_adapter->proposed_mac); + tasklet_init(&dm1105dvb->vpe_tasklet, vpeirq, (unsigned long) dm1105dvb); + + dvbdemux = &dm1105dvb->demux; + dvbdemux->filternum = 256; + dvbdemux->feednum = 256; + dvbdemux->start_feed = dm1105dvb_start_feed; + dvbdemux->stop_feed = dm1105dvb_stop_feed; + dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | + DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING); + ret = dvb_dmx_init(dvbdemux); + if (ret < 0) + goto err_dvb_unregister_adapter; + + dmx = &dvbdemux->dmx; + dm1105dvb->dmxdev.filternum = 256; + dm1105dvb->dmxdev.demux = dmx; + dm1105dvb->dmxdev.capabilities = 0; + + ret = dvb_dmxdev_init(&dm1105dvb->dmxdev, dvb_adapter); + if (ret < 0) + goto err_dvb_dmx_release; + + dm1105dvb->hw_frontend.source = DMX_FRONTEND_0; + + ret = dmx->add_frontend(dmx, &dm1105dvb->hw_frontend); + if (ret < 0) + goto err_dvb_dmxdev_release; + + dm1105dvb->mem_frontend.source = DMX_MEMORY_FE; + + ret = dmx->add_frontend(dmx, &dm1105dvb->mem_frontend); + if (ret < 0) + goto err_remove_hw_frontend; + + ret = dmx->connect_frontend(dmx, &dm1105dvb->hw_frontend); + if (ret < 0) + goto err_remove_mem_frontend; + + ret = frontend_init(dm1105dvb); + if (ret < 0) + goto err_disconnect_frontend; + + dvb_net_init(dvb_adapter, &dm1105dvb->dvbnet, dmx); + out: + return ret; + + err_disconnect_frontend: + dmx->disconnect_frontend(dmx); + err_remove_mem_frontend: + dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend); + err_remove_hw_frontend: + dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend); + err_dvb_dmxdev_release: + dvb_dmxdev_release(&dm1105dvb->dmxdev); + err_dvb_dmx_release: + dvb_dmx_release(dvbdemux); + err_dvb_unregister_adapter: + dvb_unregister_adapter(dvb_adapter); + err_i2c_del_adapter: + i2c_del_adapter(&dm1105dvb->i2c_adap); + err_dm1105dvb_hw_exit: + dm1105dvb_hw_exit(dm1105dvb); + err_free_irq: + free_irq(pdev->irq, dm1105dvb); + err_pci_iounmap: + pci_iounmap(pdev, dm1105dvb->io_mem); + err_pci_release_regions: + pci_release_regions(pdev); + err_pci_disable_device: + pci_disable_device(pdev); + err_kfree: + pci_set_drvdata(pdev, NULL); + kfree(dm1105dvb); + goto out; + } + + static void __devexit dm1105_remove(struct pci_dev *pdev) + { + struct dm1105dvb *dm1105dvb = pci_get_drvdata(pdev); + struct dvb_adapter *dvb_adapter = &dm1105dvb->dvb_adapter; + struct dvb_demux *dvbdemux = &dm1105dvb->demux; + struct dmx_demux *dmx = &dvbdemux->dmx; + + dmx->close(dmx); + dvb_net_release(&dm1105dvb->dvbnet); + if (dm1105dvb->fe) + dvb_unregister_frontend(dm1105dvb->fe); + + dmx->disconnect_frontend(dmx); + dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend); + dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend); + dvb_dmxdev_release(&dm1105dvb->dmxdev); + dvb_dmx_release(dvbdemux); + dvb_unregister_adapter(dvb_adapter); + if (&dm1105dvb->i2c_adap) + i2c_del_adapter(&dm1105dvb->i2c_adap); + + dm1105dvb_hw_exit(dm1105dvb); + synchronize_irq (pdev->irq); + free_irq(pdev->irq, dm1105dvb); + pci_iounmap(pdev, dm1105dvb->io_mem); + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + kfree(dm1105dvb); + } + + static struct pci_device_id dm1105_id_table[] __devinitdata = { + { + .vendor = PCI_VENDOR_ID_TRIGEM, + .device = PCI_DEVICE_ID_DM1105, + .subvendor = 0x0001, + .subdevice = 0x2002, + }, { + /* empty */ + }, + }; + + MODULE_DEVICE_TABLE(pci, dm1105_id_table); + + static struct pci_driver dm1105_driver = { + .name = DRIVER_NAME, + .id_table = dm1105_id_table, + .probe = dm1105_probe, + .remove = __devexit_p(dm1105_remove), + }; + + static int __init dm1105_init(void) + { + return pci_register_driver(&dm1105_driver); + } + + static void __exit dm1105_exit(void) + { + pci_unregister_driver(&dm1105_driver); + } + + module_init(dm1105_init); + module_exit(dm1105_exit); + + MODULE_AUTHOR("Igor M. Liplianin <liplianin@xxxxx>"); + MODULE_DESCRIPTION("DM1105 driver"); + MODULE_LICENSE("GPL");
_______________________________________________ linux-dvb mailing list linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb