2 * dm1105.c - driver for DVB cards based on SDMC DM1105 PCI chip
4 * Copyright (C) 2008 Igor M. Liplianin <liplianin@me.by>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/i2c.h>
23 #include <linux/init.h>
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/proc_fs.h>
27 #include <linux/pci.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/input.h>
30 #include <media/ir-common.h>
34 #include "dvb_demux.h"
35 #include "dvb_frontend.h"
47 /* ----------------------------------------------- */
51 #ifndef PCI_VENDOR_ID_TRIGEM
52 #define PCI_VENDOR_ID_TRIGEM 0x109f
54 #ifndef PCI_VENDOR_ID_AXESS
55 #define PCI_VENDOR_ID_AXESS 0x195d
57 #ifndef PCI_DEVICE_ID_DM1105
58 #define PCI_DEVICE_ID_DM1105 0x036f
60 #ifndef PCI_DEVICE_ID_DW2002
61 #define PCI_DEVICE_ID_DW2002 0x2002
63 #ifndef PCI_DEVICE_ID_DW2004
64 #define PCI_DEVICE_ID_DW2004 0x2004
66 #ifndef PCI_DEVICE_ID_DM05
67 #define PCI_DEVICE_ID_DM05 0x1105
69 /* ----------------------------------------------- */
70 /* sdmc dm1105 registers */
73 #define DM1105_TSCTR 0x00
74 #define DM1105_DTALENTH 0x04
77 #define DM1105_GPIOVAL 0x08
78 #define DM1105_GPIOCTR 0x0c
80 /* PID serial number */
81 #define DM1105_PIDN 0x10
83 /* Odd-even secret key select */
84 #define DM1105_CWSEL 0x14
86 /* Host Command Interface */
87 #define DM1105_HOST_CTR 0x18
88 #define DM1105_HOST_AD 0x1c
91 #define DM1105_CR 0x30
92 #define DM1105_RST 0x34
93 #define DM1105_STADR 0x38
94 #define DM1105_RLEN 0x3c
95 #define DM1105_WRP 0x40
96 #define DM1105_INTCNT 0x44
97 #define DM1105_INTMAK 0x48
98 #define DM1105_INTSTS 0x4c
101 #define DM1105_ODD 0x50
102 #define DM1105_EVEN 0x58
105 #define DM1105_PID 0x60
108 #define DM1105_IRCTR 0x64
109 #define DM1105_IRMODE 0x68
110 #define DM1105_SYSTEMCODE 0x6c
111 #define DM1105_IRCODE 0x70
114 #define DM1105_ENCRYPT 0x74
115 #define DM1105_VER 0x7c
118 #define DM1105_I2CCTR 0x80
119 #define DM1105_I2CSTS 0x81
120 #define DM1105_I2CDAT 0x82
121 #define DM1105_I2C_RA 0x83
122 /* ----------------------------------------------- */
123 /* Interrupt Mask Bits */
125 #define INTMAK_TSIRQM 0x01
126 #define INTMAK_HIRQM 0x04
127 #define INTMAK_IRM 0x08
128 #define INTMAK_ALLMASK (INTMAK_TSIRQM | \
131 #define INTMAK_NONEMASK 0x00
133 /* Interrupt Status Bits */
134 #define INTSTS_TSIRQ 0x01
135 #define INTSTS_HIRQ 0x04
136 #define INTSTS_IR 0x08
138 /* IR Control Bits */
139 #define DM1105_IR_EN 0x01
140 #define DM1105_SYS_CHK 0x02
141 #define DM1105_REP_FLG 0x08
144 #define IIC_24C01_addr 0xa0
145 /* Max board count */
146 #define DM1105_MAX 0x04
148 #define DRIVER_NAME "dm1105"
150 #define DM1105_DMA_PACKETS 47
151 #define DM1105_DMA_PACKET_LENGTH (128*4)
152 #define DM1105_DMA_BYTES (128 * 4 * DM1105_DMA_PACKETS)
154 /* GPIO's for LNB power control */
155 #define DM1105_LNB_MASK 0x00000000
156 #define DM1105_LNB_13V 0x00010100
157 #define DM1105_LNB_18V 0x00000100
159 /* GPIO's for LNB power control for Axess DM05 */
160 #define DM05_LNB_MASK 0x00000000
161 #define DM05_LNB_13V 0x00020000
162 #define DM05_LNB_18V 0x00030000
165 module_param(ir_debug, int, 0644);
166 MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding");
168 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
170 /* infrared remote control */
172 struct input_dev *input_dev;
173 struct ir_input_state ir;
175 struct work_struct work;
181 struct pci_dev *pdev;
188 struct dmx_frontend hw_frontend;
189 struct dmx_frontend mem_frontend;
190 struct dmxdev dmxdev;
191 struct dvb_adapter dvb_adapter;
192 struct dvb_demux demux;
193 struct dvb_frontend *fe;
194 struct dvb_net dvbnet;
195 unsigned int full_ts_users;
198 struct i2c_adapter i2c_adap;
201 struct work_struct work;
202 struct workqueue_struct *wq;
207 unsigned char *ts_buf;
211 unsigned int PacketErrorCount;
217 #define dm_io_mem(reg) ((unsigned long)(&dm1105dvb->io_mem[reg]))
219 static int dm1105_i2c_xfer(struct i2c_adapter *i2c_adap,
220 struct i2c_msg *msgs, int num)
222 struct dm1105dvb *dm1105dvb ;
224 int addr, rc, i, j, k, len, byte, data;
227 dm1105dvb = i2c_adap->algo_data;
228 for (i = 0; i < num; i++) {
229 outb(0x00, dm_io_mem(DM1105_I2CCTR));
230 if (msgs[i].flags & I2C_M_RD) {
232 addr = msgs[i].addr << 1;
234 outb(addr, dm_io_mem(DM1105_I2CDAT));
235 for (byte = 0; byte < msgs[i].len; byte++)
236 outb(0, dm_io_mem(DM1105_I2CDAT + byte + 1));
238 outb(0x81 + msgs[i].len, dm_io_mem(DM1105_I2CCTR));
239 for (j = 0; j < 55; j++) {
241 status = inb(dm_io_mem(DM1105_I2CSTS));
242 if ((status & 0xc0) == 0x40)
248 for (byte = 0; byte < msgs[i].len; byte++) {
249 rc = inb(dm_io_mem(DM1105_I2CDAT + byte + 1));
252 msgs[i].buf[byte] = rc;
255 if ((msgs[i].buf[0] == 0xf7) && (msgs[i].addr == 0x55)) {
256 /* prepaired for cx24116 firmware */
257 /* Write in small blocks */
258 len = msgs[i].len - 1;
261 outb(msgs[i].addr << 1, dm_io_mem(DM1105_I2CDAT));
262 outb(0xf7, dm_io_mem(DM1105_I2CDAT + 1));
263 for (byte = 0; byte < (len > 48 ? 48 : len); byte++) {
264 data = msgs[i].buf[k+byte];
265 outb(data, dm_io_mem(DM1105_I2CDAT + byte + 2));
267 outb(0x82 + (len > 48 ? 48 : len), dm_io_mem(DM1105_I2CCTR));
268 for (j = 0; j < 25; j++) {
270 status = inb(dm_io_mem(DM1105_I2CSTS));
271 if ((status & 0xc0) == 0x40)
283 outb(msgs[i].addr<<1, dm_io_mem(DM1105_I2CDAT));
284 for (byte = 0; byte < msgs[i].len; byte++) {
285 data = msgs[i].buf[byte];
286 outb(data, dm_io_mem(DM1105_I2CDAT + byte + 1));
288 outb(0x81 + msgs[i].len, dm_io_mem(DM1105_I2CCTR));
289 for (j = 0; j < 25; j++) {
291 status = inb(dm_io_mem(DM1105_I2CSTS));
292 if ((status & 0xc0) == 0x40)
306 static u32 functionality(struct i2c_adapter *adap)
311 static struct i2c_algorithm dm1105_algo = {
312 .master_xfer = dm1105_i2c_xfer,
313 .functionality = functionality,
316 static inline struct dm1105dvb *feed_to_dm1105dvb(struct dvb_demux_feed *feed)
318 return container_of(feed->demux, struct dm1105dvb, demux);
321 static inline struct dm1105dvb *frontend_to_dm1105dvb(struct dvb_frontend *fe)
323 return container_of(fe->dvb, struct dm1105dvb, dvb_adapter);
326 static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
328 struct dm1105dvb *dm1105dvb = frontend_to_dm1105dvb(fe);
329 u32 lnb_mask, lnb_13v, lnb_18v;
331 switch (dm1105dvb->pdev->subsystem_device) {
332 case PCI_DEVICE_ID_DM05:
333 lnb_mask = DM05_LNB_MASK;
334 lnb_13v = DM05_LNB_13V;
335 lnb_18v = DM05_LNB_18V;
338 lnb_mask = DM1105_LNB_MASK;
339 lnb_13v = DM1105_LNB_13V;
340 lnb_18v = DM1105_LNB_18V;
343 outl(lnb_mask, dm_io_mem(DM1105_GPIOCTR));
344 if (voltage == SEC_VOLTAGE_18)
345 outl(lnb_18v , dm_io_mem(DM1105_GPIOVAL));
347 outl(lnb_13v, dm_io_mem(DM1105_GPIOVAL));
352 static void dm1105dvb_set_dma_addr(struct dm1105dvb *dm1105dvb)
354 outl(cpu_to_le32(dm1105dvb->dma_addr), dm_io_mem(DM1105_STADR));
357 static int __devinit dm1105dvb_dma_map(struct dm1105dvb *dm1105dvb)
359 dm1105dvb->ts_buf = pci_alloc_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, &dm1105dvb->dma_addr);
361 return !dm1105dvb->ts_buf;
364 static void dm1105dvb_dma_unmap(struct dm1105dvb *dm1105dvb)
366 pci_free_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr);
369 static void dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb)
371 outb(INTMAK_ALLMASK, dm_io_mem(DM1105_INTMAK));
372 outb(1, dm_io_mem(DM1105_CR));
375 static void dm1105dvb_disable_irqs(struct dm1105dvb *dm1105dvb)
377 outb(INTMAK_IRM, dm_io_mem(DM1105_INTMAK));
378 outb(0, dm_io_mem(DM1105_CR));
381 static int dm1105dvb_start_feed(struct dvb_demux_feed *f)
383 struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f);
385 if (dm1105dvb->full_ts_users++ == 0)
386 dm1105dvb_enable_irqs(dm1105dvb);
391 static int dm1105dvb_stop_feed(struct dvb_demux_feed *f)
393 struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f);
395 if (--dm1105dvb->full_ts_users == 0)
396 dm1105dvb_disable_irqs(dm1105dvb);
401 /* ir work handler */
402 static void dm1105_emit_key(struct work_struct *work)
404 struct infrared *ir = container_of(work, struct infrared, work);
405 u32 ircom = ir->ir_command;
409 printk(KERN_INFO "%s: received byte 0x%04x\n", __func__, ircom);
411 data = (ircom >> 8) & 0x7f;
413 ir_input_keydown(ir->input_dev, &ir->ir, data, data);
414 ir_input_nokey(ir->input_dev, &ir->ir);
418 static void dm1105_dmx_buffer(struct work_struct *work)
420 struct dm1105dvb *dm1105dvb =
421 container_of(work, struct dm1105dvb, work);
422 unsigned int nbpackets;
423 u32 oldwrp = dm1105dvb->wrp;
424 u32 nextwrp = dm1105dvb->nextwrp;
426 if (!((dm1105dvb->ts_buf[oldwrp] == 0x47) &&
427 (dm1105dvb->ts_buf[oldwrp + 188] == 0x47) &&
428 (dm1105dvb->ts_buf[oldwrp + 188 * 2] == 0x47))) {
429 dm1105dvb->PacketErrorCount++;
430 /* bad packet found */
431 if ((dm1105dvb->PacketErrorCount >= 2) &&
432 (dm1105dvb->dmarst == 0)) {
433 outb(1, dm_io_mem(DM1105_RST));
435 dm1105dvb->PacketErrorCount = 0;
436 dm1105dvb->dmarst = 0;
441 if (nextwrp < oldwrp) {
442 memcpy(dm1105dvb->ts_buf + dm1105dvb->buffer_size,
443 dm1105dvb->ts_buf, nextwrp);
444 nbpackets = ((dm1105dvb->buffer_size - oldwrp) + nextwrp) / 188;
446 nbpackets = (nextwrp - oldwrp) / 188;
448 dm1105dvb->wrp = nextwrp;
449 dvb_dmx_swfilter_packets(&dm1105dvb->demux,
450 &dm1105dvb->ts_buf[oldwrp], nbpackets);
453 static irqreturn_t dm1105dvb_irq(int irq, void *dev_id)
455 struct dm1105dvb *dm1105dvb = dev_id;
457 /* Read-Write INSTS Ack's Interrupt for DM1105 chip 16.03.2008 */
458 unsigned int intsts = inb(dm_io_mem(DM1105_INTSTS));
459 outb(intsts, dm_io_mem(DM1105_INTSTS));
463 case (INTSTS_TSIRQ | INTSTS_IR):
464 dm1105dvb->nextwrp = inl(dm_io_mem(DM1105_WRP)) -
465 inl(dm_io_mem(DM1105_STADR));
466 queue_work(dm1105dvb->wq, &dm1105dvb->work);
469 dm1105dvb->ir.ir_command = inl(dm_io_mem(DM1105_IRCODE));
470 schedule_work(&dm1105dvb->ir.work);
477 int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
479 struct input_dev *input_dev;
480 IR_KEYTAB_TYPE *ir_codes = ir_codes_dm1105_nec;
481 int ir_type = IR_TYPE_OTHER;
484 input_dev = input_allocate_device();
488 dm1105->ir.input_dev = input_dev;
489 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
490 "pci-%s/ir0", pci_name(dm1105->pdev));
492 ir_input_init(input_dev, &dm1105->ir.ir, ir_type, ir_codes);
493 input_dev->name = "DVB on-card IR receiver";
494 input_dev->phys = dm1105->ir.input_phys;
495 input_dev->id.bustype = BUS_PCI;
496 input_dev->id.version = 1;
497 if (dm1105->pdev->subsystem_vendor) {
498 input_dev->id.vendor = dm1105->pdev->subsystem_vendor;
499 input_dev->id.product = dm1105->pdev->subsystem_device;
501 input_dev->id.vendor = dm1105->pdev->vendor;
502 input_dev->id.product = dm1105->pdev->device;
505 input_dev->dev.parent = &dm1105->pdev->dev;
507 INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
509 err = input_register_device(input_dev);
511 input_free_device(input_dev);
518 void __devexit dm1105_ir_exit(struct dm1105dvb *dm1105)
520 input_unregister_device(dm1105->ir.input_dev);
524 static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb)
526 dm1105dvb_disable_irqs(dm1105dvb);
528 outb(0, dm_io_mem(DM1105_HOST_CTR));
531 outb(188, dm_io_mem(DM1105_DTALENTH));
532 /*TS_STRT TS_VALP MSBFIRST TS_MODE ALPAS TSPES*/
533 outw(0xc10a, dm_io_mem(DM1105_TSCTR));
535 /* map DMA and set address */
536 dm1105dvb_dma_map(dm1105dvb);
537 dm1105dvb_set_dma_addr(dm1105dvb);
539 outl(5*DM1105_DMA_BYTES, dm_io_mem(DM1105_RLEN));
540 outb(47, dm_io_mem(DM1105_INTCNT));
542 /* IR NEC mode enable */
543 outb((DM1105_IR_EN | DM1105_SYS_CHK), dm_io_mem(DM1105_IRCTR));
544 outb(0, dm_io_mem(DM1105_IRMODE));
545 outw(0, dm_io_mem(DM1105_SYSTEMCODE));
550 static void dm1105dvb_hw_exit(struct dm1105dvb *dm1105dvb)
552 dm1105dvb_disable_irqs(dm1105dvb);
555 outb(0, dm_io_mem(DM1105_IRCTR));
556 outb(INTMAK_NONEMASK, dm_io_mem(DM1105_INTMAK));
558 dm1105dvb_dma_unmap(dm1105dvb);
561 static struct stv0299_config sharp_z0194a_config = {
562 .demod_address = 0x68,
563 .inittab = sharp_z0194a_inittab,
567 .lock_output = STV0299_LOCKOUTPUT_1,
568 .volt13_op0_op1 = STV0299_VOLT13_OP1,
570 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
573 static struct stv0288_config earda_config = {
574 .demod_address = 0x68,
578 static struct si21xx_config serit_config = {
579 .demod_address = 0x68,
584 static struct cx24116_config serit_sp2633_config = {
585 .demod_address = 0x55,
588 static int __devinit frontend_init(struct dm1105dvb *dm1105dvb)
592 switch (dm1105dvb->pdev->subsystem_device) {
593 case PCI_DEVICE_ID_DW2004:
594 dm1105dvb->fe = dvb_attach(
595 cx24116_attach, &serit_sp2633_config,
596 &dm1105dvb->i2c_adap);
598 dm1105dvb->fe->ops.set_voltage = dm1105dvb_set_voltage;
602 dm1105dvb->fe = dvb_attach(
603 stv0299_attach, &sharp_z0194a_config,
604 &dm1105dvb->i2c_adap);
606 dm1105dvb->fe->ops.set_voltage =
607 dm1105dvb_set_voltage;
608 dvb_attach(dvb_pll_attach, dm1105dvb->fe, 0x60,
609 &dm1105dvb->i2c_adap, DVB_PLL_OPERA1);
613 dm1105dvb->fe = dvb_attach(
614 stv0288_attach, &earda_config,
615 &dm1105dvb->i2c_adap);
617 dm1105dvb->fe->ops.set_voltage =
618 dm1105dvb_set_voltage;
619 dvb_attach(stb6000_attach, dm1105dvb->fe, 0x61,
620 &dm1105dvb->i2c_adap);
624 dm1105dvb->fe = dvb_attach(
625 si21xx_attach, &serit_config,
626 &dm1105dvb->i2c_adap);
628 dm1105dvb->fe->ops.set_voltage =
629 dm1105dvb_set_voltage;
633 if (!dm1105dvb->fe) {
634 dev_err(&dm1105dvb->pdev->dev, "could not attach frontend\n");
638 ret = dvb_register_frontend(&dm1105dvb->dvb_adapter, dm1105dvb->fe);
640 if (dm1105dvb->fe->ops.release)
641 dm1105dvb->fe->ops.release(dm1105dvb->fe);
642 dm1105dvb->fe = NULL;
649 static void __devinit dm1105dvb_read_mac(struct dm1105dvb *dm1105dvb, u8 *mac)
651 static u8 command[1] = { 0x28 };
653 struct i2c_msg msg[] = {
655 .addr = IIC_24C01_addr >> 1,
660 .addr = IIC_24C01_addr >> 1,
667 dm1105_i2c_xfer(&dm1105dvb->i2c_adap, msg , 2);
668 dev_info(&dm1105dvb->pdev->dev, "MAC %pM\n", mac);
671 static int __devinit dm1105_probe(struct pci_dev *pdev,
672 const struct pci_device_id *ent)
674 struct dm1105dvb *dm1105dvb;
675 struct dvb_adapter *dvb_adapter;
676 struct dvb_demux *dvbdemux;
677 struct dmx_demux *dmx;
680 dm1105dvb = kzalloc(sizeof(struct dm1105dvb), GFP_KERNEL);
684 dm1105dvb->pdev = pdev;
685 dm1105dvb->buffer_size = 5 * DM1105_DMA_BYTES;
686 dm1105dvb->PacketErrorCount = 0;
687 dm1105dvb->dmarst = 0;
689 ret = pci_enable_device(pdev);
693 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
695 goto err_pci_disable_device;
697 pci_set_master(pdev);
699 ret = pci_request_regions(pdev, DRIVER_NAME);
701 goto err_pci_disable_device;
703 dm1105dvb->io_mem = pci_iomap(pdev, 0, pci_resource_len(pdev, 0));
704 if (!dm1105dvb->io_mem) {
706 goto err_pci_release_regions;
709 spin_lock_init(&dm1105dvb->lock);
710 pci_set_drvdata(pdev, dm1105dvb);
712 ret = dm1105dvb_hw_init(dm1105dvb);
714 goto err_pci_iounmap;
717 i2c_set_adapdata(&dm1105dvb->i2c_adap, dm1105dvb);
718 strcpy(dm1105dvb->i2c_adap.name, DRIVER_NAME);
719 dm1105dvb->i2c_adap.owner = THIS_MODULE;
720 dm1105dvb->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
721 dm1105dvb->i2c_adap.dev.parent = &pdev->dev;
722 dm1105dvb->i2c_adap.algo = &dm1105_algo;
723 dm1105dvb->i2c_adap.algo_data = dm1105dvb;
724 ret = i2c_add_adapter(&dm1105dvb->i2c_adap);
727 goto err_dm1105dvb_hw_exit;
730 ret = dvb_register_adapter(&dm1105dvb->dvb_adapter, DRIVER_NAME,
731 THIS_MODULE, &pdev->dev, adapter_nr);
733 goto err_i2c_del_adapter;
735 dvb_adapter = &dm1105dvb->dvb_adapter;
737 dm1105dvb_read_mac(dm1105dvb, dvb_adapter->proposed_mac);
739 dvbdemux = &dm1105dvb->demux;
740 dvbdemux->filternum = 256;
741 dvbdemux->feednum = 256;
742 dvbdemux->start_feed = dm1105dvb_start_feed;
743 dvbdemux->stop_feed = dm1105dvb_stop_feed;
744 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
745 DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
746 ret = dvb_dmx_init(dvbdemux);
748 goto err_dvb_unregister_adapter;
750 dmx = &dvbdemux->dmx;
751 dm1105dvb->dmxdev.filternum = 256;
752 dm1105dvb->dmxdev.demux = dmx;
753 dm1105dvb->dmxdev.capabilities = 0;
755 ret = dvb_dmxdev_init(&dm1105dvb->dmxdev, dvb_adapter);
757 goto err_dvb_dmx_release;
759 dm1105dvb->hw_frontend.source = DMX_FRONTEND_0;
761 ret = dmx->add_frontend(dmx, &dm1105dvb->hw_frontend);
763 goto err_dvb_dmxdev_release;
765 dm1105dvb->mem_frontend.source = DMX_MEMORY_FE;
767 ret = dmx->add_frontend(dmx, &dm1105dvb->mem_frontend);
769 goto err_remove_hw_frontend;
771 ret = dmx->connect_frontend(dmx, &dm1105dvb->hw_frontend);
773 goto err_remove_mem_frontend;
775 ret = frontend_init(dm1105dvb);
777 goto err_disconnect_frontend;
779 dvb_net_init(dvb_adapter, &dm1105dvb->dvbnet, dmx);
780 dm1105_ir_init(dm1105dvb);
782 INIT_WORK(&dm1105dvb->work, dm1105_dmx_buffer);
783 sprintf(dm1105dvb->wqn, "%s/%d", dvb_adapter->name, dvb_adapter->num);
784 dm1105dvb->wq = create_singlethread_workqueue(dm1105dvb->wqn);
788 ret = request_irq(pdev->irq, dm1105dvb_irq, IRQF_SHARED,
789 DRIVER_NAME, dm1105dvb);
796 destroy_workqueue(dm1105dvb->wq);
798 dvb_net_release(&dm1105dvb->dvbnet);
799 err_disconnect_frontend:
800 dmx->disconnect_frontend(dmx);
801 err_remove_mem_frontend:
802 dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend);
803 err_remove_hw_frontend:
804 dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend);
805 err_dvb_dmxdev_release:
806 dvb_dmxdev_release(&dm1105dvb->dmxdev);
808 dvb_dmx_release(dvbdemux);
809 err_dvb_unregister_adapter:
810 dvb_unregister_adapter(dvb_adapter);
812 i2c_del_adapter(&dm1105dvb->i2c_adap);
813 err_dm1105dvb_hw_exit:
814 dm1105dvb_hw_exit(dm1105dvb);
816 pci_iounmap(pdev, dm1105dvb->io_mem);
817 err_pci_release_regions:
818 pci_release_regions(pdev);
819 err_pci_disable_device:
820 pci_disable_device(pdev);
822 pci_set_drvdata(pdev, NULL);
827 static void __devexit dm1105_remove(struct pci_dev *pdev)
829 struct dm1105dvb *dm1105dvb = pci_get_drvdata(pdev);
830 struct dvb_adapter *dvb_adapter = &dm1105dvb->dvb_adapter;
831 struct dvb_demux *dvbdemux = &dm1105dvb->demux;
832 struct dmx_demux *dmx = &dvbdemux->dmx;
834 dm1105_ir_exit(dm1105dvb);
836 dvb_net_release(&dm1105dvb->dvbnet);
838 dvb_unregister_frontend(dm1105dvb->fe);
840 dmx->disconnect_frontend(dmx);
841 dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend);
842 dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend);
843 dvb_dmxdev_release(&dm1105dvb->dmxdev);
844 dvb_dmx_release(dvbdemux);
845 dvb_unregister_adapter(dvb_adapter);
846 if (&dm1105dvb->i2c_adap)
847 i2c_del_adapter(&dm1105dvb->i2c_adap);
849 dm1105dvb_hw_exit(dm1105dvb);
850 synchronize_irq(pdev->irq);
851 free_irq(pdev->irq, dm1105dvb);
852 pci_iounmap(pdev, dm1105dvb->io_mem);
853 pci_release_regions(pdev);
854 pci_disable_device(pdev);
855 pci_set_drvdata(pdev, NULL);
859 static struct pci_device_id dm1105_id_table[] __devinitdata = {
861 .vendor = PCI_VENDOR_ID_TRIGEM,
862 .device = PCI_DEVICE_ID_DM1105,
863 .subvendor = PCI_ANY_ID,
864 .subdevice = PCI_DEVICE_ID_DW2002,
866 .vendor = PCI_VENDOR_ID_TRIGEM,
867 .device = PCI_DEVICE_ID_DM1105,
868 .subvendor = PCI_ANY_ID,
869 .subdevice = PCI_DEVICE_ID_DW2004,
871 .vendor = PCI_VENDOR_ID_AXESS,
872 .device = PCI_DEVICE_ID_DM05,
873 .subvendor = PCI_VENDOR_ID_AXESS,
874 .subdevice = PCI_DEVICE_ID_DM05,
880 MODULE_DEVICE_TABLE(pci, dm1105_id_table);
882 static struct pci_driver dm1105_driver = {
884 .id_table = dm1105_id_table,
885 .probe = dm1105_probe,
886 .remove = __devexit_p(dm1105_remove),
889 static int __init dm1105_init(void)
891 return pci_register_driver(&dm1105_driver);
894 static void __exit dm1105_exit(void)
896 pci_unregister_driver(&dm1105_driver);
899 module_init(dm1105_init);
900 module_exit(dm1105_exit);
902 MODULE_AUTHOR("Igor M. Liplianin <liplianin@me.by>");
903 MODULE_DESCRIPTION("SDMC DM1105 DVB driver");
904 MODULE_LICENSE("GPL");