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_DEVICE_ID_DM1105
55 #define PCI_DEVICE_ID_DM1105 0x036f
57 #ifndef PCI_DEVICE_ID_DW2002
58 #define PCI_DEVICE_ID_DW2002 0x2002
60 #ifndef PCI_DEVICE_ID_DW2004
61 #define PCI_DEVICE_ID_DW2004 0x2004
63 /* ----------------------------------------------- */
64 /* sdmc dm1105 registers */
67 #define DM1105_TSCTR 0x00
68 #define DM1105_DTALENTH 0x04
71 #define DM1105_GPIOVAL 0x08
72 #define DM1105_GPIOCTR 0x0c
74 /* PID serial number */
75 #define DM1105_PIDN 0x10
77 /* Odd-even secret key select */
78 #define DM1105_CWSEL 0x14
80 /* Host Command Interface */
81 #define DM1105_HOST_CTR 0x18
82 #define DM1105_HOST_AD 0x1c
85 #define DM1105_CR 0x30
86 #define DM1105_RST 0x34
87 #define DM1105_STADR 0x38
88 #define DM1105_RLEN 0x3c
89 #define DM1105_WRP 0x40
90 #define DM1105_INTCNT 0x44
91 #define DM1105_INTMAK 0x48
92 #define DM1105_INTSTS 0x4c
95 #define DM1105_ODD 0x50
96 #define DM1105_EVEN 0x58
99 #define DM1105_PID 0x60
102 #define DM1105_IRCTR 0x64
103 #define DM1105_IRMODE 0x68
104 #define DM1105_SYSTEMCODE 0x6c
105 #define DM1105_IRCODE 0x70
108 #define DM1105_ENCRYPT 0x74
109 #define DM1105_VER 0x7c
112 #define DM1105_I2CCTR 0x80
113 #define DM1105_I2CSTS 0x81
114 #define DM1105_I2CDAT 0x82
115 #define DM1105_I2C_RA 0x83
116 /* ----------------------------------------------- */
117 /* Interrupt Mask Bits */
119 #define INTMAK_TSIRQM 0x01
120 #define INTMAK_HIRQM 0x04
121 #define INTMAK_IRM 0x08
122 #define INTMAK_ALLMASK (INTMAK_TSIRQM | \
125 #define INTMAK_NONEMASK 0x00
127 /* Interrupt Status Bits */
128 #define INTSTS_TSIRQ 0x01
129 #define INTSTS_HIRQ 0x04
130 #define INTSTS_IR 0x08
132 /* IR Control Bits */
133 #define DM1105_IR_EN 0x01
134 #define DM1105_SYS_CHK 0x02
135 #define DM1105_REP_FLG 0x08
138 #define IIC_24C01_addr 0xa0
139 /* Max board count */
140 #define DM1105_MAX 0x04
142 #define DRIVER_NAME "dm1105"
144 #define DM1105_DMA_PACKETS 47
145 #define DM1105_DMA_PACKET_LENGTH (128*4)
146 #define DM1105_DMA_BYTES (128 * 4 * DM1105_DMA_PACKETS)
148 /* GPIO's for LNB power control */
149 #define DM1105_LNB_MASK 0x00000000
150 #define DM1105_LNB_13V 0x00010100
151 #define DM1105_LNB_18V 0x00000100
154 module_param(ir_debug, int, 0644);
155 MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding");
157 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
159 /* infrared remote control */
161 struct input_dev *input_dev;
162 struct ir_input_state ir;
164 struct work_struct work;
170 struct pci_dev *pdev;
177 struct dmx_frontend hw_frontend;
178 struct dmx_frontend mem_frontend;
179 struct dmxdev dmxdev;
180 struct dvb_adapter dvb_adapter;
181 struct dvb_demux demux;
182 struct dvb_frontend *fe;
183 struct dvb_net dvbnet;
184 unsigned int full_ts_users;
187 struct i2c_adapter i2c_adap;
190 struct work_struct work;
194 unsigned char *ts_buf;
198 unsigned int PacketErrorCount;
204 #define dm_io_mem(reg) ((unsigned long)(&dm1105dvb->io_mem[reg]))
206 static int dm1105_i2c_xfer(struct i2c_adapter *i2c_adap,
207 struct i2c_msg *msgs, int num)
209 struct dm1105dvb *dm1105dvb ;
211 int addr, rc, i, j, k, len, byte, data;
214 dm1105dvb = i2c_adap->algo_data;
215 for (i = 0; i < num; i++) {
216 outb(0x00, dm_io_mem(DM1105_I2CCTR));
217 if (msgs[i].flags & I2C_M_RD) {
219 addr = msgs[i].addr << 1;
221 outb(addr, dm_io_mem(DM1105_I2CDAT));
222 for (byte = 0; byte < msgs[i].len; byte++)
223 outb(0, dm_io_mem(DM1105_I2CDAT + byte + 1));
225 outb(0x81 + msgs[i].len, dm_io_mem(DM1105_I2CCTR));
226 for (j = 0; j < 55; j++) {
228 status = inb(dm_io_mem(DM1105_I2CSTS));
229 if ((status & 0xc0) == 0x40)
235 for (byte = 0; byte < msgs[i].len; byte++) {
236 rc = inb(dm_io_mem(DM1105_I2CDAT + byte + 1));
239 msgs[i].buf[byte] = rc;
242 if ((msgs[i].buf[0] == 0xf7) && (msgs[i].addr == 0x55)) {
243 /* prepaired for cx24116 firmware */
244 /* Write in small blocks */
245 len = msgs[i].len - 1;
248 outb(msgs[i].addr << 1, dm_io_mem(DM1105_I2CDAT));
249 outb(0xf7, dm_io_mem(DM1105_I2CDAT + 1));
250 for (byte = 0; byte < (len > 48 ? 48 : len); byte++) {
251 data = msgs[i].buf[k+byte];
252 outb(data, dm_io_mem(DM1105_I2CDAT + byte + 2));
254 outb(0x82 + (len > 48 ? 48 : len), dm_io_mem(DM1105_I2CCTR));
255 for (j = 0; j < 25; j++) {
257 status = inb(dm_io_mem(DM1105_I2CSTS));
258 if ((status & 0xc0) == 0x40)
270 outb(msgs[i].addr<<1, dm_io_mem(DM1105_I2CDAT));
271 for (byte = 0; byte < msgs[i].len; byte++) {
272 data = msgs[i].buf[byte];
273 outb(data, dm_io_mem(DM1105_I2CDAT + byte + 1));
275 outb(0x81 + msgs[i].len, dm_io_mem(DM1105_I2CCTR));
276 for (j = 0; j < 25; j++) {
278 status = inb(dm_io_mem(DM1105_I2CSTS));
279 if ((status & 0xc0) == 0x40)
293 static u32 functionality(struct i2c_adapter *adap)
298 static struct i2c_algorithm dm1105_algo = {
299 .master_xfer = dm1105_i2c_xfer,
300 .functionality = functionality,
303 static inline struct dm1105dvb *feed_to_dm1105dvb(struct dvb_demux_feed *feed)
305 return container_of(feed->demux, struct dm1105dvb, demux);
308 static inline struct dm1105dvb *frontend_to_dm1105dvb(struct dvb_frontend *fe)
310 return container_of(fe->dvb, struct dm1105dvb, dvb_adapter);
313 static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
315 struct dm1105dvb *dm1105dvb = frontend_to_dm1105dvb(fe);
317 if (voltage == SEC_VOLTAGE_18) {
318 outl(DM1105_LNB_MASK, dm_io_mem(DM1105_GPIOCTR));
319 outl(DM1105_LNB_18V, dm_io_mem(DM1105_GPIOVAL));
321 /*LNB ON-13V by default!*/
322 outl(DM1105_LNB_MASK, dm_io_mem(DM1105_GPIOCTR));
323 outl(DM1105_LNB_13V, dm_io_mem(DM1105_GPIOVAL));
329 static void dm1105dvb_set_dma_addr(struct dm1105dvb *dm1105dvb)
331 outl(cpu_to_le32(dm1105dvb->dma_addr), dm_io_mem(DM1105_STADR));
334 static int __devinit dm1105dvb_dma_map(struct dm1105dvb *dm1105dvb)
336 dm1105dvb->ts_buf = pci_alloc_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, &dm1105dvb->dma_addr);
338 return !dm1105dvb->ts_buf;
341 static void dm1105dvb_dma_unmap(struct dm1105dvb *dm1105dvb)
343 pci_free_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr);
346 static void dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb)
348 outb(INTMAK_ALLMASK, dm_io_mem(DM1105_INTMAK));
349 outb(1, dm_io_mem(DM1105_CR));
352 static void dm1105dvb_disable_irqs(struct dm1105dvb *dm1105dvb)
354 outb(INTMAK_IRM, dm_io_mem(DM1105_INTMAK));
355 outb(0, dm_io_mem(DM1105_CR));
358 static int dm1105dvb_start_feed(struct dvb_demux_feed *f)
360 struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f);
362 if (dm1105dvb->full_ts_users++ == 0)
363 dm1105dvb_enable_irqs(dm1105dvb);
368 static int dm1105dvb_stop_feed(struct dvb_demux_feed *f)
370 struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f);
372 if (--dm1105dvb->full_ts_users == 0)
373 dm1105dvb_disable_irqs(dm1105dvb);
378 /* ir work handler */
379 static void dm1105_emit_key(struct work_struct *work)
381 struct infrared *ir = container_of(work, struct infrared, work);
382 u32 ircom = ir->ir_command;
386 printk(KERN_INFO "%s: received byte 0x%04x\n", __func__, ircom);
388 data = (ircom >> 8) & 0x7f;
390 ir_input_keydown(ir->input_dev, &ir->ir, data, data);
391 ir_input_nokey(ir->input_dev, &ir->ir);
395 static void dm1105_dmx_buffer(struct work_struct *work)
397 struct dm1105dvb *dm1105dvb =
398 container_of(work, struct dm1105dvb, work);
399 unsigned int nbpackets;
400 u32 oldwrp = dm1105dvb->wrp;
401 u32 nextwrp = dm1105dvb->nextwrp;
403 if (!((dm1105dvb->ts_buf[oldwrp] == 0x47) &&
404 (dm1105dvb->ts_buf[oldwrp + 188] == 0x47) &&
405 (dm1105dvb->ts_buf[oldwrp + 188 * 2] == 0x47))) {
406 dm1105dvb->PacketErrorCount++;
407 /* bad packet found */
408 if ((dm1105dvb->PacketErrorCount >= 2) &&
409 (dm1105dvb->dmarst == 0)) {
410 outb(1, dm_io_mem(DM1105_RST));
412 dm1105dvb->PacketErrorCount = 0;
413 dm1105dvb->dmarst = 0;
418 if (nextwrp < oldwrp) {
419 memcpy(dm1105dvb->ts_buf + dm1105dvb->buffer_size,
420 dm1105dvb->ts_buf, nextwrp);
421 nbpackets = ((dm1105dvb->buffer_size - oldwrp) + nextwrp) / 188;
423 nbpackets = (nextwrp - oldwrp) / 188;
425 dm1105dvb->wrp = nextwrp;
426 dvb_dmx_swfilter_packets(&dm1105dvb->demux,
427 &dm1105dvb->ts_buf[oldwrp], nbpackets);
430 static irqreturn_t dm1105dvb_irq(int irq, void *dev_id)
432 struct dm1105dvb *dm1105dvb = dev_id;
434 /* Read-Write INSTS Ack's Interrupt for DM1105 chip 16.03.2008 */
435 unsigned int intsts = inb(dm_io_mem(DM1105_INTSTS));
436 outb(intsts, dm_io_mem(DM1105_INTSTS));
440 case (INTSTS_TSIRQ | INTSTS_IR):
441 dm1105dvb->nextwrp = inl(dm_io_mem(DM1105_WRP)) -
442 inl(dm_io_mem(DM1105_STADR));
443 schedule_work(&dm1105dvb->work);
446 dm1105dvb->ir.ir_command = inl(dm_io_mem(DM1105_IRCODE));
447 schedule_work(&dm1105dvb->ir.work);
454 int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
456 struct input_dev *input_dev;
457 IR_KEYTAB_TYPE *ir_codes = ir_codes_dm1105_nec;
458 int ir_type = IR_TYPE_OTHER;
461 input_dev = input_allocate_device();
465 dm1105->ir.input_dev = input_dev;
466 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
467 "pci-%s/ir0", pci_name(dm1105->pdev));
469 ir_input_init(input_dev, &dm1105->ir.ir, ir_type, ir_codes);
470 input_dev->name = "DVB on-card IR receiver";
471 input_dev->phys = dm1105->ir.input_phys;
472 input_dev->id.bustype = BUS_PCI;
473 input_dev->id.version = 1;
474 if (dm1105->pdev->subsystem_vendor) {
475 input_dev->id.vendor = dm1105->pdev->subsystem_vendor;
476 input_dev->id.product = dm1105->pdev->subsystem_device;
478 input_dev->id.vendor = dm1105->pdev->vendor;
479 input_dev->id.product = dm1105->pdev->device;
482 input_dev->dev.parent = &dm1105->pdev->dev;
484 INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
486 err = input_register_device(input_dev);
488 input_free_device(input_dev);
495 void __devexit dm1105_ir_exit(struct dm1105dvb *dm1105)
497 input_unregister_device(dm1105->ir.input_dev);
501 static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb)
503 dm1105dvb_disable_irqs(dm1105dvb);
505 outb(0, dm_io_mem(DM1105_HOST_CTR));
508 outb(188, dm_io_mem(DM1105_DTALENTH));
509 /*TS_STRT TS_VALP MSBFIRST TS_MODE ALPAS TSPES*/
510 outw(0xc10a, dm_io_mem(DM1105_TSCTR));
512 /* map DMA and set address */
513 dm1105dvb_dma_map(dm1105dvb);
514 dm1105dvb_set_dma_addr(dm1105dvb);
516 outl(5*DM1105_DMA_BYTES, dm_io_mem(DM1105_RLEN));
517 outb(47, dm_io_mem(DM1105_INTCNT));
519 /* IR NEC mode enable */
520 outb((DM1105_IR_EN | DM1105_SYS_CHK), dm_io_mem(DM1105_IRCTR));
521 outb(0, dm_io_mem(DM1105_IRMODE));
522 outw(0, dm_io_mem(DM1105_SYSTEMCODE));
527 static void dm1105dvb_hw_exit(struct dm1105dvb *dm1105dvb)
529 dm1105dvb_disable_irqs(dm1105dvb);
532 outb(0, dm_io_mem(DM1105_IRCTR));
533 outb(INTMAK_NONEMASK, dm_io_mem(DM1105_INTMAK));
535 dm1105dvb_dma_unmap(dm1105dvb);
538 static struct stv0299_config sharp_z0194a_config = {
539 .demod_address = 0x68,
540 .inittab = sharp_z0194a_inittab,
544 .lock_output = STV0299_LOCKOUTPUT_1,
545 .volt13_op0_op1 = STV0299_VOLT13_OP1,
547 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
550 static struct stv0288_config earda_config = {
551 .demod_address = 0x68,
555 static struct si21xx_config serit_config = {
556 .demod_address = 0x68,
561 static struct cx24116_config serit_sp2633_config = {
562 .demod_address = 0x55,
565 static int __devinit frontend_init(struct dm1105dvb *dm1105dvb)
569 switch (dm1105dvb->pdev->subsystem_device) {
570 case PCI_DEVICE_ID_DW2002:
571 dm1105dvb->fe = dvb_attach(
572 stv0299_attach, &sharp_z0194a_config,
573 &dm1105dvb->i2c_adap);
576 dm1105dvb->fe->ops.set_voltage =
577 dm1105dvb_set_voltage;
578 dvb_attach(dvb_pll_attach, dm1105dvb->fe, 0x60,
579 &dm1105dvb->i2c_adap, DVB_PLL_OPERA1);
582 if (!dm1105dvb->fe) {
583 dm1105dvb->fe = dvb_attach(
584 stv0288_attach, &earda_config,
585 &dm1105dvb->i2c_adap);
587 dm1105dvb->fe->ops.set_voltage =
588 dm1105dvb_set_voltage;
589 dvb_attach(stb6000_attach, dm1105dvb->fe, 0x61,
590 &dm1105dvb->i2c_adap);
594 if (!dm1105dvb->fe) {
595 dm1105dvb->fe = dvb_attach(
596 si21xx_attach, &serit_config,
597 &dm1105dvb->i2c_adap);
599 dm1105dvb->fe->ops.set_voltage =
600 dm1105dvb_set_voltage;
603 case PCI_DEVICE_ID_DW2004:
604 dm1105dvb->fe = dvb_attach(
605 cx24116_attach, &serit_sp2633_config,
606 &dm1105dvb->i2c_adap);
608 dm1105dvb->fe->ops.set_voltage = dm1105dvb_set_voltage;
612 if (!dm1105dvb->fe) {
613 dev_err(&dm1105dvb->pdev->dev, "could not attach frontend\n");
617 ret = dvb_register_frontend(&dm1105dvb->dvb_adapter, dm1105dvb->fe);
619 if (dm1105dvb->fe->ops.release)
620 dm1105dvb->fe->ops.release(dm1105dvb->fe);
621 dm1105dvb->fe = NULL;
628 static void __devinit dm1105dvb_read_mac(struct dm1105dvb *dm1105dvb, u8 *mac)
630 static u8 command[1] = { 0x28 };
632 struct i2c_msg msg[] = {
633 { .addr = IIC_24C01_addr >> 1, .flags = 0,
634 .buf = command, .len = 1 },
635 { .addr = IIC_24C01_addr >> 1, .flags = I2C_M_RD,
636 .buf = mac, .len = 6 },
639 dm1105_i2c_xfer(&dm1105dvb->i2c_adap, msg , 2);
640 dev_info(&dm1105dvb->pdev->dev, "MAC %pM\n", mac);
643 static int __devinit dm1105_probe(struct pci_dev *pdev,
644 const struct pci_device_id *ent)
646 struct dm1105dvb *dm1105dvb;
647 struct dvb_adapter *dvb_adapter;
648 struct dvb_demux *dvbdemux;
649 struct dmx_demux *dmx;
652 dm1105dvb = kzalloc(sizeof(struct dm1105dvb), GFP_KERNEL);
656 dm1105dvb->pdev = pdev;
657 dm1105dvb->buffer_size = 5 * DM1105_DMA_BYTES;
658 dm1105dvb->PacketErrorCount = 0;
659 dm1105dvb->dmarst = 0;
661 ret = pci_enable_device(pdev);
665 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
667 goto err_pci_disable_device;
669 pci_set_master(pdev);
671 ret = pci_request_regions(pdev, DRIVER_NAME);
673 goto err_pci_disable_device;
675 dm1105dvb->io_mem = pci_iomap(pdev, 0, pci_resource_len(pdev, 0));
676 if (!dm1105dvb->io_mem) {
678 goto err_pci_release_regions;
681 spin_lock_init(&dm1105dvb->lock);
682 pci_set_drvdata(pdev, dm1105dvb);
684 ret = dm1105dvb_hw_init(dm1105dvb);
686 goto err_pci_iounmap;
689 i2c_set_adapdata(&dm1105dvb->i2c_adap, dm1105dvb);
690 strcpy(dm1105dvb->i2c_adap.name, DRIVER_NAME);
691 dm1105dvb->i2c_adap.owner = THIS_MODULE;
692 dm1105dvb->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
693 dm1105dvb->i2c_adap.dev.parent = &pdev->dev;
694 dm1105dvb->i2c_adap.algo = &dm1105_algo;
695 dm1105dvb->i2c_adap.algo_data = dm1105dvb;
696 ret = i2c_add_adapter(&dm1105dvb->i2c_adap);
699 goto err_dm1105dvb_hw_exit;
702 ret = dvb_register_adapter(&dm1105dvb->dvb_adapter, DRIVER_NAME,
703 THIS_MODULE, &pdev->dev, adapter_nr);
705 goto err_i2c_del_adapter;
707 dvb_adapter = &dm1105dvb->dvb_adapter;
709 dm1105dvb_read_mac(dm1105dvb, dvb_adapter->proposed_mac);
711 dvbdemux = &dm1105dvb->demux;
712 dvbdemux->filternum = 256;
713 dvbdemux->feednum = 256;
714 dvbdemux->start_feed = dm1105dvb_start_feed;
715 dvbdemux->stop_feed = dm1105dvb_stop_feed;
716 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
717 DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
718 ret = dvb_dmx_init(dvbdemux);
720 goto err_dvb_unregister_adapter;
722 dmx = &dvbdemux->dmx;
723 dm1105dvb->dmxdev.filternum = 256;
724 dm1105dvb->dmxdev.demux = dmx;
725 dm1105dvb->dmxdev.capabilities = 0;
727 ret = dvb_dmxdev_init(&dm1105dvb->dmxdev, dvb_adapter);
729 goto err_dvb_dmx_release;
731 dm1105dvb->hw_frontend.source = DMX_FRONTEND_0;
733 ret = dmx->add_frontend(dmx, &dm1105dvb->hw_frontend);
735 goto err_dvb_dmxdev_release;
737 dm1105dvb->mem_frontend.source = DMX_MEMORY_FE;
739 ret = dmx->add_frontend(dmx, &dm1105dvb->mem_frontend);
741 goto err_remove_hw_frontend;
743 ret = dmx->connect_frontend(dmx, &dm1105dvb->hw_frontend);
745 goto err_remove_mem_frontend;
747 ret = frontend_init(dm1105dvb);
749 goto err_disconnect_frontend;
751 dvb_net_init(dvb_adapter, &dm1105dvb->dvbnet, dmx);
752 dm1105_ir_init(dm1105dvb);
754 INIT_WORK(&dm1105dvb->work, dm1105_dmx_buffer);
756 ret = request_irq(pdev->irq, dm1105dvb_irq, IRQF_SHARED,
757 DRIVER_NAME, dm1105dvb);
763 err_disconnect_frontend:
764 dmx->disconnect_frontend(dmx);
765 err_remove_mem_frontend:
766 dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend);
767 err_remove_hw_frontend:
768 dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend);
769 err_dvb_dmxdev_release:
770 dvb_dmxdev_release(&dm1105dvb->dmxdev);
772 dvb_dmx_release(dvbdemux);
773 err_dvb_unregister_adapter:
774 dvb_unregister_adapter(dvb_adapter);
776 i2c_del_adapter(&dm1105dvb->i2c_adap);
777 err_dm1105dvb_hw_exit:
778 dm1105dvb_hw_exit(dm1105dvb);
780 free_irq(pdev->irq, dm1105dvb);
782 pci_iounmap(pdev, dm1105dvb->io_mem);
783 err_pci_release_regions:
784 pci_release_regions(pdev);
785 err_pci_disable_device:
786 pci_disable_device(pdev);
788 pci_set_drvdata(pdev, NULL);
793 static void __devexit dm1105_remove(struct pci_dev *pdev)
795 struct dm1105dvb *dm1105dvb = pci_get_drvdata(pdev);
796 struct dvb_adapter *dvb_adapter = &dm1105dvb->dvb_adapter;
797 struct dvb_demux *dvbdemux = &dm1105dvb->demux;
798 struct dmx_demux *dmx = &dvbdemux->dmx;
800 dm1105_ir_exit(dm1105dvb);
802 dvb_net_release(&dm1105dvb->dvbnet);
804 dvb_unregister_frontend(dm1105dvb->fe);
806 dmx->disconnect_frontend(dmx);
807 dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend);
808 dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend);
809 dvb_dmxdev_release(&dm1105dvb->dmxdev);
810 dvb_dmx_release(dvbdemux);
811 dvb_unregister_adapter(dvb_adapter);
812 if (&dm1105dvb->i2c_adap)
813 i2c_del_adapter(&dm1105dvb->i2c_adap);
815 dm1105dvb_hw_exit(dm1105dvb);
816 synchronize_irq(pdev->irq);
817 free_irq(pdev->irq, dm1105dvb);
818 pci_iounmap(pdev, dm1105dvb->io_mem);
819 pci_release_regions(pdev);
820 pci_disable_device(pdev);
821 pci_set_drvdata(pdev, NULL);
825 static struct pci_device_id dm1105_id_table[] __devinitdata = {
827 .vendor = PCI_VENDOR_ID_TRIGEM,
828 .device = PCI_DEVICE_ID_DM1105,
829 .subvendor = PCI_ANY_ID,
830 .subdevice = PCI_DEVICE_ID_DW2002,
832 .vendor = PCI_VENDOR_ID_TRIGEM,
833 .device = PCI_DEVICE_ID_DM1105,
834 .subvendor = PCI_ANY_ID,
835 .subdevice = PCI_DEVICE_ID_DW2004,
841 MODULE_DEVICE_TABLE(pci, dm1105_id_table);
843 static struct pci_driver dm1105_driver = {
845 .id_table = dm1105_id_table,
846 .probe = dm1105_probe,
847 .remove = __devexit_p(dm1105_remove),
850 static int __init dm1105_init(void)
852 return pci_register_driver(&dm1105_driver);
855 static void __exit dm1105_exit(void)
857 pci_unregister_driver(&dm1105_driver);
860 module_init(dm1105_init);
861 module_exit(dm1105_exit);
863 MODULE_AUTHOR("Igor M. Liplianin <liplianin@me.by>");
864 MODULE_DESCRIPTION("SDMC DM1105 DVB driver");
865 MODULE_LICENSE("GPL");