aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dm1105/dm1105.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dm1105/dm1105.c')
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c505
1 files changed, 265 insertions, 240 deletions
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index f0f483ac8b89..383cca378b8c 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -43,6 +43,7 @@
43#include "si21xx.h" 43#include "si21xx.h"
44#include "cx24116.h" 44#include "cx24116.h"
45#include "z0194a.h" 45#include "z0194a.h"
46#include "ds3000.h"
46 47
47#define UNSET (-1U) 48#define UNSET (-1U)
48 49
@@ -269,7 +270,7 @@ struct infrared {
269 u32 ir_command; 270 u32 ir_command;
270}; 271};
271 272
272struct dm1105dvb { 273struct dm1105_dev {
273 /* pci */ 274 /* pci */
274 struct pci_dev *pdev; 275 struct pci_dev *pdev;
275 u8 __iomem *io_mem; 276 u8 __iomem *io_mem;
@@ -308,31 +309,47 @@ struct dm1105dvb {
308 spinlock_t lock; 309 spinlock_t lock;
309}; 310};
310 311
311#define dm_io_mem(reg) ((unsigned long)(&dm1105dvb->io_mem[reg])) 312#define dm_io_mem(reg) ((unsigned long)(&dev->io_mem[reg]))
313
314#define dm_readb(reg) inb(dm_io_mem(reg))
315#define dm_writeb(reg, value) outb((value), (dm_io_mem(reg)))
316
317#define dm_readw(reg) inw(dm_io_mem(reg))
318#define dm_writew(reg, value) outw((value), (dm_io_mem(reg)))
319
320#define dm_readl(reg) inl(dm_io_mem(reg))
321#define dm_writel(reg, value) outl((value), (dm_io_mem(reg)))
322
323#define dm_andorl(reg, mask, value) \
324 outl((inl(dm_io_mem(reg)) & ~(mask)) |\
325 ((value) & (mask)), (dm_io_mem(reg)))
326
327#define dm_setl(reg, bit) dm_andorl((reg), (bit), (bit))
328#define dm_clearl(reg, bit) dm_andorl((reg), (bit), 0)
312 329
313static int dm1105_i2c_xfer(struct i2c_adapter *i2c_adap, 330static int dm1105_i2c_xfer(struct i2c_adapter *i2c_adap,
314 struct i2c_msg *msgs, int num) 331 struct i2c_msg *msgs, int num)
315{ 332{
316 struct dm1105dvb *dm1105dvb ; 333 struct dm1105_dev *dev ;
317 334
318 int addr, rc, i, j, k, len, byte, data; 335 int addr, rc, i, j, k, len, byte, data;
319 u8 status; 336 u8 status;
320 337
321 dm1105dvb = i2c_adap->algo_data; 338 dev = i2c_adap->algo_data;
322 for (i = 0; i < num; i++) { 339 for (i = 0; i < num; i++) {
323 outb(0x00, dm_io_mem(DM1105_I2CCTR)); 340 dm_writeb(DM1105_I2CCTR, 0x00);
324 if (msgs[i].flags & I2C_M_RD) { 341 if (msgs[i].flags & I2C_M_RD) {
325 /* read bytes */ 342 /* read bytes */
326 addr = msgs[i].addr << 1; 343 addr = msgs[i].addr << 1;
327 addr |= 1; 344 addr |= 1;
328 outb(addr, dm_io_mem(DM1105_I2CDAT)); 345 dm_writeb(DM1105_I2CDAT, addr);
329 for (byte = 0; byte < msgs[i].len; byte++) 346 for (byte = 0; byte < msgs[i].len; byte++)
330 outb(0, dm_io_mem(DM1105_I2CDAT + byte + 1)); 347 dm_writeb(DM1105_I2CDAT + byte + 1, 0);
331 348
332 outb(0x81 + msgs[i].len, dm_io_mem(DM1105_I2CCTR)); 349 dm_writeb(DM1105_I2CCTR, 0x81 + msgs[i].len);
333 for (j = 0; j < 55; j++) { 350 for (j = 0; j < 55; j++) {
334 mdelay(10); 351 mdelay(10);
335 status = inb(dm_io_mem(DM1105_I2CSTS)); 352 status = dm_readb(DM1105_I2CSTS);
336 if ((status & 0xc0) == 0x40) 353 if ((status & 0xc0) == 0x40)
337 break; 354 break;
338 } 355 }
@@ -340,56 +357,54 @@ static int dm1105_i2c_xfer(struct i2c_adapter *i2c_adap,
340 return -1; 357 return -1;
341 358
342 for (byte = 0; byte < msgs[i].len; byte++) { 359 for (byte = 0; byte < msgs[i].len; byte++) {
343 rc = inb(dm_io_mem(DM1105_I2CDAT + byte + 1)); 360 rc = dm_readb(DM1105_I2CDAT + byte + 1);
344 if (rc < 0) 361 if (rc < 0)
345 goto err; 362 goto err;
346 msgs[i].buf[byte] = rc; 363 msgs[i].buf[byte] = rc;
347 } 364 }
348 } else { 365 } else if ((msgs[i].buf[0] == 0xf7) && (msgs[i].addr == 0x55)) {
349 if ((msgs[i].buf[0] == 0xf7) && (msgs[i].addr == 0x55)) { 366 /* prepaired for cx24116 firmware */
350 /* prepaired for cx24116 firmware */ 367 /* Write in small blocks */
351 /* Write in small blocks */ 368 len = msgs[i].len - 1;
352 len = msgs[i].len - 1; 369 k = 1;
353 k = 1; 370 do {
354 do { 371 dm_writeb(DM1105_I2CDAT, msgs[i].addr << 1);
355 outb(msgs[i].addr << 1, dm_io_mem(DM1105_I2CDAT)); 372 dm_writeb(DM1105_I2CDAT + 1, 0xf7);
356 outb(0xf7, dm_io_mem(DM1105_I2CDAT + 1)); 373 for (byte = 0; byte < (len > 48 ? 48 : len); byte++) {
357 for (byte = 0; byte < (len > 48 ? 48 : len); byte++) { 374 data = msgs[i].buf[k + byte];
358 data = msgs[i].buf[k+byte]; 375 dm_writeb(DM1105_I2CDAT + byte + 2, data);
359 outb(data, dm_io_mem(DM1105_I2CDAT + byte + 2));
360 }
361 outb(0x82 + (len > 48 ? 48 : len), dm_io_mem(DM1105_I2CCTR));
362 for (j = 0; j < 25; j++) {
363 mdelay(10);
364 status = inb(dm_io_mem(DM1105_I2CSTS));
365 if ((status & 0xc0) == 0x40)
366 break;
367 }
368
369 if (j >= 25)
370 return -1;
371
372 k += 48;
373 len -= 48;
374 } while (len > 0);
375 } else {
376 /* write bytes */
377 outb(msgs[i].addr<<1, dm_io_mem(DM1105_I2CDAT));
378 for (byte = 0; byte < msgs[i].len; byte++) {
379 data = msgs[i].buf[byte];
380 outb(data, dm_io_mem(DM1105_I2CDAT + byte + 1));
381 } 376 }
382 outb(0x81 + msgs[i].len, dm_io_mem(DM1105_I2CCTR)); 377 dm_writeb(DM1105_I2CCTR, 0x82 + (len > 48 ? 48 : len));
383 for (j = 0; j < 25; j++) { 378 for (j = 0; j < 25; j++) {
384 mdelay(10); 379 mdelay(10);
385 status = inb(dm_io_mem(DM1105_I2CSTS)); 380 status = dm_readb(DM1105_I2CSTS);
386 if ((status & 0xc0) == 0x40) 381 if ((status & 0xc0) == 0x40)
387 break; 382 break;
388 } 383 }
389 384
390 if (j >= 25) 385 if (j >= 25)
391 return -1; 386 return -1;
387
388 k += 48;
389 len -= 48;
390 } while (len > 0);
391 } else {
392 /* write bytes */
393 dm_writeb(DM1105_I2CDAT, msgs[i].addr << 1);
394 for (byte = 0; byte < msgs[i].len; byte++) {
395 data = msgs[i].buf[byte];
396 dm_writeb(DM1105_I2CDAT + byte + 1, data);
392 } 397 }
398 dm_writeb(DM1105_I2CCTR, 0x81 + msgs[i].len);
399 for (j = 0; j < 25; j++) {
400 mdelay(10);
401 status = dm_readb(DM1105_I2CSTS);
402 if ((status & 0xc0) == 0x40)
403 break;
404 }
405
406 if (j >= 25)
407 return -1;
393 } 408 }
394 } 409 }
395 return num; 410 return num;
@@ -407,22 +422,22 @@ static struct i2c_algorithm dm1105_algo = {
407 .functionality = functionality, 422 .functionality = functionality,
408}; 423};
409 424
410static inline struct dm1105dvb *feed_to_dm1105dvb(struct dvb_demux_feed *feed) 425static inline struct dm1105_dev *feed_to_dm1105_dev(struct dvb_demux_feed *feed)
411{ 426{
412 return container_of(feed->demux, struct dm1105dvb, demux); 427 return container_of(feed->demux, struct dm1105_dev, demux);
413} 428}
414 429
415static inline struct dm1105dvb *frontend_to_dm1105dvb(struct dvb_frontend *fe) 430static inline struct dm1105_dev *frontend_to_dm1105_dev(struct dvb_frontend *fe)
416{ 431{
417 return container_of(fe->dvb, struct dm1105dvb, dvb_adapter); 432 return container_of(fe->dvb, struct dm1105_dev, dvb_adapter);
418} 433}
419 434
420static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 435static int dm1105_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
421{ 436{
422 struct dm1105dvb *dm1105dvb = frontend_to_dm1105dvb(fe); 437 struct dm1105_dev *dev = frontend_to_dm1105_dev(fe);
423 u32 lnb_mask, lnb_13v, lnb_18v, lnb_off; 438 u32 lnb_mask, lnb_13v, lnb_18v, lnb_off;
424 439
425 switch (dm1105dvb->boardnr) { 440 switch (dev->boardnr) {
426 case DM1105_BOARD_AXESS_DM05: 441 case DM1105_BOARD_AXESS_DM05:
427 lnb_mask = DM05_LNB_MASK; 442 lnb_mask = DM05_LNB_MASK;
428 lnb_off = DM05_LNB_OFF; 443 lnb_off = DM05_LNB_OFF;
@@ -438,62 +453,67 @@ static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t volta
438 lnb_18v = DM1105_LNB_18V; 453 lnb_18v = DM1105_LNB_18V;
439 } 454 }
440 455
441 outl(lnb_mask, dm_io_mem(DM1105_GPIOCTR)); 456 dm_writel(DM1105_GPIOCTR, lnb_mask);
442 if (voltage == SEC_VOLTAGE_18) 457 if (voltage == SEC_VOLTAGE_18)
443 outl(lnb_18v , dm_io_mem(DM1105_GPIOVAL)); 458 dm_writel(DM1105_GPIOVAL, lnb_18v);
444 else if (voltage == SEC_VOLTAGE_13) 459 else if (voltage == SEC_VOLTAGE_13)
445 outl(lnb_13v, dm_io_mem(DM1105_GPIOVAL)); 460 dm_writel(DM1105_GPIOVAL, lnb_13v);
446 else 461 else
447 outl(lnb_off, dm_io_mem(DM1105_GPIOVAL)); 462 dm_writel(DM1105_GPIOVAL, lnb_off);
448 463
449 return 0; 464 return 0;
450} 465}
451 466
452static void dm1105dvb_set_dma_addr(struct dm1105dvb *dm1105dvb) 467static void dm1105_set_dma_addr(struct dm1105_dev *dev)
453{ 468{
454 outl(cpu_to_le32(dm1105dvb->dma_addr), dm_io_mem(DM1105_STADR)); 469 dm_writel(DM1105_STADR, cpu_to_le32(dev->dma_addr));
455} 470}
456 471
457static int __devinit dm1105dvb_dma_map(struct dm1105dvb *dm1105dvb) 472static int __devinit dm1105_dma_map(struct dm1105_dev *dev)
458{ 473{
459 dm1105dvb->ts_buf = pci_alloc_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, &dm1105dvb->dma_addr); 474 dev->ts_buf = pci_alloc_consistent(dev->pdev,
475 6 * DM1105_DMA_BYTES,
476 &dev->dma_addr);
460 477
461 return !dm1105dvb->ts_buf; 478 return !dev->ts_buf;
462} 479}
463 480
464static void dm1105dvb_dma_unmap(struct dm1105dvb *dm1105dvb) 481static void dm1105_dma_unmap(struct dm1105_dev *dev)
465{ 482{
466 pci_free_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr); 483 pci_free_consistent(dev->pdev,
484 6 * DM1105_DMA_BYTES,
485 dev->ts_buf,
486 dev->dma_addr);
467} 487}
468 488
469static void dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb) 489static void dm1105_enable_irqs(struct dm1105_dev *dev)
470{ 490{
471 outb(INTMAK_ALLMASK, dm_io_mem(DM1105_INTMAK)); 491 dm_writeb(DM1105_INTMAK, INTMAK_ALLMASK);
472 outb(1, dm_io_mem(DM1105_CR)); 492 dm_writeb(DM1105_CR, 1);
473} 493}
474 494
475static void dm1105dvb_disable_irqs(struct dm1105dvb *dm1105dvb) 495static void dm1105_disable_irqs(struct dm1105_dev *dev)
476{ 496{
477 outb(INTMAK_IRM, dm_io_mem(DM1105_INTMAK)); 497 dm_writeb(DM1105_INTMAK, INTMAK_IRM);
478 outb(0, dm_io_mem(DM1105_CR)); 498 dm_writeb(DM1105_CR, 0);
479} 499}
480 500
481static int dm1105dvb_start_feed(struct dvb_demux_feed *f) 501static int dm1105_start_feed(struct dvb_demux_feed *f)
482{ 502{
483 struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f); 503 struct dm1105_dev *dev = feed_to_dm1105_dev(f);
484 504
485 if (dm1105dvb->full_ts_users++ == 0) 505 if (dev->full_ts_users++ == 0)
486 dm1105dvb_enable_irqs(dm1105dvb); 506 dm1105_enable_irqs(dev);
487 507
488 return 0; 508 return 0;
489} 509}
490 510
491static int dm1105dvb_stop_feed(struct dvb_demux_feed *f) 511static int dm1105_stop_feed(struct dvb_demux_feed *f)
492{ 512{
493 struct dm1105dvb *dm1105dvb = feed_to_dm1105dvb(f); 513 struct dm1105_dev *dev = feed_to_dm1105_dev(f);
494 514
495 if (--dm1105dvb->full_ts_users == 0) 515 if (--dev->full_ts_users == 0)
496 dm1105dvb_disable_irqs(dm1105dvb); 516 dm1105_disable_irqs(dev);
497 517
498 return 0; 518 return 0;
499} 519}
@@ -517,68 +537,64 @@ static void dm1105_emit_key(struct work_struct *work)
517/* work handler */ 537/* work handler */
518static void dm1105_dmx_buffer(struct work_struct *work) 538static void dm1105_dmx_buffer(struct work_struct *work)
519{ 539{
520 struct dm1105dvb *dm1105dvb = 540 struct dm1105_dev *dev = container_of(work, struct dm1105_dev, work);
521 container_of(work, struct dm1105dvb, work);
522 unsigned int nbpackets; 541 unsigned int nbpackets;
523 u32 oldwrp = dm1105dvb->wrp; 542 u32 oldwrp = dev->wrp;
524 u32 nextwrp = dm1105dvb->nextwrp; 543 u32 nextwrp = dev->nextwrp;
525 544
526 if (!((dm1105dvb->ts_buf[oldwrp] == 0x47) && 545 if (!((dev->ts_buf[oldwrp] == 0x47) &&
527 (dm1105dvb->ts_buf[oldwrp + 188] == 0x47) && 546 (dev->ts_buf[oldwrp + 188] == 0x47) &&
528 (dm1105dvb->ts_buf[oldwrp + 188 * 2] == 0x47))) { 547 (dev->ts_buf[oldwrp + 188 * 2] == 0x47))) {
529 dm1105dvb->PacketErrorCount++; 548 dev->PacketErrorCount++;
530 /* bad packet found */ 549 /* bad packet found */
531 if ((dm1105dvb->PacketErrorCount >= 2) && 550 if ((dev->PacketErrorCount >= 2) &&
532 (dm1105dvb->dmarst == 0)) { 551 (dev->dmarst == 0)) {
533 outb(1, dm_io_mem(DM1105_RST)); 552 dm_writeb(DM1105_RST, 1);
534 dm1105dvb->wrp = 0; 553 dev->wrp = 0;
535 dm1105dvb->PacketErrorCount = 0; 554 dev->PacketErrorCount = 0;
536 dm1105dvb->dmarst = 0; 555 dev->dmarst = 0;
537 return; 556 return;
538 } 557 }
539 } 558 }
540 559
541 if (nextwrp < oldwrp) { 560 if (nextwrp < oldwrp) {
542 memcpy(dm1105dvb->ts_buf + dm1105dvb->buffer_size, 561 memcpy(dev->ts_buf + dev->buffer_size, dev->ts_buf, nextwrp);
543 dm1105dvb->ts_buf, nextwrp); 562 nbpackets = ((dev->buffer_size - oldwrp) + nextwrp) / 188;
544 nbpackets = ((dm1105dvb->buffer_size - oldwrp) + nextwrp) / 188;
545 } else 563 } else
546 nbpackets = (nextwrp - oldwrp) / 188; 564 nbpackets = (nextwrp - oldwrp) / 188;
547 565
548 dm1105dvb->wrp = nextwrp; 566 dev->wrp = nextwrp;
549 dvb_dmx_swfilter_packets(&dm1105dvb->demux, 567 dvb_dmx_swfilter_packets(&dev->demux, &dev->ts_buf[oldwrp], nbpackets);
550 &dm1105dvb->ts_buf[oldwrp], nbpackets);
551} 568}
552 569
553static irqreturn_t dm1105dvb_irq(int irq, void *dev_id) 570static irqreturn_t dm1105_irq(int irq, void *dev_id)
554{ 571{
555 struct dm1105dvb *dm1105dvb = dev_id; 572 struct dm1105_dev *dev = dev_id;
556 573
557 /* Read-Write INSTS Ack's Interrupt for DM1105 chip 16.03.2008 */ 574 /* Read-Write INSTS Ack's Interrupt for DM1105 chip 16.03.2008 */
558 unsigned int intsts = inb(dm_io_mem(DM1105_INTSTS)); 575 unsigned int intsts = dm_readb(DM1105_INTSTS);
559 outb(intsts, dm_io_mem(DM1105_INTSTS)); 576 dm_writeb(DM1105_INTSTS, intsts);
560 577
561 switch (intsts) { 578 switch (intsts) {
562 case INTSTS_TSIRQ: 579 case INTSTS_TSIRQ:
563 case (INTSTS_TSIRQ | INTSTS_IR): 580 case (INTSTS_TSIRQ | INTSTS_IR):
564 dm1105dvb->nextwrp = inl(dm_io_mem(DM1105_WRP)) - 581 dev->nextwrp = dm_readl(DM1105_WRP) - dm_readl(DM1105_STADR);
565 inl(dm_io_mem(DM1105_STADR)); 582 queue_work(dev->wq, &dev->work);
566 queue_work(dm1105dvb->wq, &dm1105dvb->work);
567 break; 583 break;
568 case INTSTS_IR: 584 case INTSTS_IR:
569 dm1105dvb->ir.ir_command = inl(dm_io_mem(DM1105_IRCODE)); 585 dev->ir.ir_command = dm_readl(DM1105_IRCODE);
570 schedule_work(&dm1105dvb->ir.work); 586 schedule_work(&dev->ir.work);
571 break; 587 break;
572 } 588 }
573 589
574 return IRQ_HANDLED; 590 return IRQ_HANDLED;
575} 591}
576 592
577int __devinit dm1105_ir_init(struct dm1105dvb *dm1105) 593int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
578{ 594{
579 struct input_dev *input_dev; 595 struct input_dev *input_dev;
580 struct ir_scancode_table *ir_codes = &ir_codes_dm1105_nec_table; 596 struct ir_scancode_table *ir_codes = &ir_codes_dm1105_nec_table;
581 int ir_type = IR_TYPE_OTHER; 597 u64 ir_type = IR_TYPE_OTHER;
582 int err = -ENOMEM; 598 int err = -ENOMEM;
583 599
584 input_dev = input_allocate_device(); 600 input_dev = input_allocate_device();
@@ -611,51 +627,51 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
611 627
612 INIT_WORK(&dm1105->ir.work, dm1105_emit_key); 628 INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
613 629
614 err = ir_input_register(input_dev, ir_codes); 630 err = ir_input_register(input_dev, ir_codes, NULL);
615 631
616 return err; 632 return err;
617} 633}
618 634
619void __devexit dm1105_ir_exit(struct dm1105dvb *dm1105) 635void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105)
620{ 636{
621 ir_input_unregister(dm1105->ir.input_dev); 637 ir_input_unregister(dm1105->ir.input_dev);
622} 638}
623 639
624static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb) 640static int __devinit dm1105_hw_init(struct dm1105_dev *dev)
625{ 641{
626 dm1105dvb_disable_irqs(dm1105dvb); 642 dm1105_disable_irqs(dev);
627 643
628 outb(0, dm_io_mem(DM1105_HOST_CTR)); 644 dm_writeb(DM1105_HOST_CTR, 0);
629 645
630 /*DATALEN 188,*/ 646 /*DATALEN 188,*/
631 outb(188, dm_io_mem(DM1105_DTALENTH)); 647 dm_writeb(DM1105_DTALENTH, 188);
632 /*TS_STRT TS_VALP MSBFIRST TS_MODE ALPAS TSPES*/ 648 /*TS_STRT TS_VALP MSBFIRST TS_MODE ALPAS TSPES*/
633 outw(0xc10a, dm_io_mem(DM1105_TSCTR)); 649 dm_writew(DM1105_TSCTR, 0xc10a);
634 650
635 /* map DMA and set address */ 651 /* map DMA and set address */
636 dm1105dvb_dma_map(dm1105dvb); 652 dm1105_dma_map(dev);
637 dm1105dvb_set_dma_addr(dm1105dvb); 653 dm1105_set_dma_addr(dev);
638 /* big buffer */ 654 /* big buffer */
639 outl(5*DM1105_DMA_BYTES, dm_io_mem(DM1105_RLEN)); 655 dm_writel(DM1105_RLEN, 5 * DM1105_DMA_BYTES);
640 outb(47, dm_io_mem(DM1105_INTCNT)); 656 dm_writeb(DM1105_INTCNT, 47);
641 657
642 /* IR NEC mode enable */ 658 /* IR NEC mode enable */
643 outb((DM1105_IR_EN | DM1105_SYS_CHK), dm_io_mem(DM1105_IRCTR)); 659 dm_writeb(DM1105_IRCTR, (DM1105_IR_EN | DM1105_SYS_CHK));
644 outb(0, dm_io_mem(DM1105_IRMODE)); 660 dm_writeb(DM1105_IRMODE, 0);
645 outw(0, dm_io_mem(DM1105_SYSTEMCODE)); 661 dm_writew(DM1105_SYSTEMCODE, 0);
646 662
647 return 0; 663 return 0;
648} 664}
649 665
650static void dm1105dvb_hw_exit(struct dm1105dvb *dm1105dvb) 666static void dm1105_hw_exit(struct dm1105_dev *dev)
651{ 667{
652 dm1105dvb_disable_irqs(dm1105dvb); 668 dm1105_disable_irqs(dev);
653 669
654 /* IR disable */ 670 /* IR disable */
655 outb(0, dm_io_mem(DM1105_IRCTR)); 671 dm_writeb(DM1105_IRCTR, 0);
656 outb(INTMAK_NONEMASK, dm_io_mem(DM1105_INTMAK)); 672 dm_writeb(DM1105_INTMAK, INTMAK_NONEMASK);
657 673
658 dm1105dvb_dma_unmap(dm1105dvb); 674 dm1105_dma_unmap(dev);
659} 675}
660 676
661static struct stv0299_config sharp_z0194a_config = { 677static struct stv0299_config sharp_z0194a_config = {
@@ -685,70 +701,79 @@ static struct cx24116_config serit_sp2633_config = {
685 .demod_address = 0x55, 701 .demod_address = 0x55,
686}; 702};
687 703
688static int __devinit frontend_init(struct dm1105dvb *dm1105dvb) 704static struct ds3000_config dvbworld_ds3000_config = {
705 .demod_address = 0x68,
706};
707
708static int __devinit frontend_init(struct dm1105_dev *dev)
689{ 709{
690 int ret; 710 int ret;
691 711
692 switch (dm1105dvb->boardnr) { 712 switch (dev->boardnr) {
693 case DM1105_BOARD_DVBWORLD_2004: 713 case DM1105_BOARD_DVBWORLD_2004:
694 dm1105dvb->fe = dvb_attach( 714 dev->fe = dvb_attach(
695 cx24116_attach, &serit_sp2633_config, 715 cx24116_attach, &serit_sp2633_config,
696 &dm1105dvb->i2c_adap); 716 &dev->i2c_adap);
697 if (dm1105dvb->fe) 717 if (dev->fe) {
698 dm1105dvb->fe->ops.set_voltage = dm1105dvb_set_voltage; 718 dev->fe->ops.set_voltage = dm1105_set_voltage;
719 break;
720 }
721
722 dev->fe = dvb_attach(
723 ds3000_attach, &dvbworld_ds3000_config,
724 &dev->i2c_adap);
725 if (dev->fe)
726 dev->fe->ops.set_voltage = dm1105_set_voltage;
699 727
700 break; 728 break;
701 case DM1105_BOARD_DVBWORLD_2002: 729 case DM1105_BOARD_DVBWORLD_2002:
702 case DM1105_BOARD_AXESS_DM05: 730 case DM1105_BOARD_AXESS_DM05:
703 default: 731 default:
704 dm1105dvb->fe = dvb_attach( 732 dev->fe = dvb_attach(
705 stv0299_attach, &sharp_z0194a_config, 733 stv0299_attach, &sharp_z0194a_config,
706 &dm1105dvb->i2c_adap); 734 &dev->i2c_adap);
707 if (dm1105dvb->fe) { 735 if (dev->fe) {
708 dm1105dvb->fe->ops.set_voltage = 736 dev->fe->ops.set_voltage = dm1105_set_voltage;
709 dm1105dvb_set_voltage; 737 dvb_attach(dvb_pll_attach, dev->fe, 0x60,
710 dvb_attach(dvb_pll_attach, dm1105dvb->fe, 0x60, 738 &dev->i2c_adap, DVB_PLL_OPERA1);
711 &dm1105dvb->i2c_adap, DVB_PLL_OPERA1);
712 break; 739 break;
713 } 740 }
714 741
715 dm1105dvb->fe = dvb_attach( 742 dev->fe = dvb_attach(
716 stv0288_attach, &earda_config, 743 stv0288_attach, &earda_config,
717 &dm1105dvb->i2c_adap); 744 &dev->i2c_adap);
718 if (dm1105dvb->fe) { 745 if (dev->fe) {
719 dm1105dvb->fe->ops.set_voltage = 746 dev->fe->ops.set_voltage = dm1105_set_voltage;
720 dm1105dvb_set_voltage; 747 dvb_attach(stb6000_attach, dev->fe, 0x61,
721 dvb_attach(stb6000_attach, dm1105dvb->fe, 0x61, 748 &dev->i2c_adap);
722 &dm1105dvb->i2c_adap);
723 break; 749 break;
724 } 750 }
725 751
726 dm1105dvb->fe = dvb_attach( 752 dev->fe = dvb_attach(
727 si21xx_attach, &serit_config, 753 si21xx_attach, &serit_config,
728 &dm1105dvb->i2c_adap); 754 &dev->i2c_adap);
729 if (dm1105dvb->fe) 755 if (dev->fe)
730 dm1105dvb->fe->ops.set_voltage = 756 dev->fe->ops.set_voltage = dm1105_set_voltage;
731 dm1105dvb_set_voltage;
732 757
733 } 758 }
734 759
735 if (!dm1105dvb->fe) { 760 if (!dev->fe) {
736 dev_err(&dm1105dvb->pdev->dev, "could not attach frontend\n"); 761 dev_err(&dev->pdev->dev, "could not attach frontend\n");
737 return -ENODEV; 762 return -ENODEV;
738 } 763 }
739 764
740 ret = dvb_register_frontend(&dm1105dvb->dvb_adapter, dm1105dvb->fe); 765 ret = dvb_register_frontend(&dev->dvb_adapter, dev->fe);
741 if (ret < 0) { 766 if (ret < 0) {
742 if (dm1105dvb->fe->ops.release) 767 if (dev->fe->ops.release)
743 dm1105dvb->fe->ops.release(dm1105dvb->fe); 768 dev->fe->ops.release(dev->fe);
744 dm1105dvb->fe = NULL; 769 dev->fe = NULL;
745 return ret; 770 return ret;
746 } 771 }
747 772
748 return 0; 773 return 0;
749} 774}
750 775
751static void __devinit dm1105dvb_read_mac(struct dm1105dvb *dm1105dvb, u8 *mac) 776static void __devinit dm1105_read_mac(struct dm1105_dev *dev, u8 *mac)
752{ 777{
753 static u8 command[1] = { 0x28 }; 778 static u8 command[1] = { 0x28 };
754 779
@@ -766,47 +791,47 @@ static void __devinit dm1105dvb_read_mac(struct dm1105dvb *dm1105dvb, u8 *mac)
766 }, 791 },
767 }; 792 };
768 793
769 dm1105_i2c_xfer(&dm1105dvb->i2c_adap, msg , 2); 794 dm1105_i2c_xfer(&dev->i2c_adap, msg , 2);
770 dev_info(&dm1105dvb->pdev->dev, "MAC %pM\n", mac); 795 dev_info(&dev->pdev->dev, "MAC %pM\n", mac);
771} 796}
772 797
773static int __devinit dm1105_probe(struct pci_dev *pdev, 798static int __devinit dm1105_probe(struct pci_dev *pdev,
774 const struct pci_device_id *ent) 799 const struct pci_device_id *ent)
775{ 800{
776 struct dm1105dvb *dm1105dvb; 801 struct dm1105_dev *dev;
777 struct dvb_adapter *dvb_adapter; 802 struct dvb_adapter *dvb_adapter;
778 struct dvb_demux *dvbdemux; 803 struct dvb_demux *dvbdemux;
779 struct dmx_demux *dmx; 804 struct dmx_demux *dmx;
780 int ret = -ENOMEM; 805 int ret = -ENOMEM;
781 int i; 806 int i;
782 807
783 dm1105dvb = kzalloc(sizeof(struct dm1105dvb), GFP_KERNEL); 808 dev = kzalloc(sizeof(struct dm1105_dev), GFP_KERNEL);
784 if (!dm1105dvb) 809 if (!dev)
785 return -ENOMEM; 810 return -ENOMEM;
786 811
787 /* board config */ 812 /* board config */
788 dm1105dvb->nr = dm1105_devcount; 813 dev->nr = dm1105_devcount;
789 dm1105dvb->boardnr = UNSET; 814 dev->boardnr = UNSET;
790 if (card[dm1105dvb->nr] < ARRAY_SIZE(dm1105_boards)) 815 if (card[dev->nr] < ARRAY_SIZE(dm1105_boards))
791 dm1105dvb->boardnr = card[dm1105dvb->nr]; 816 dev->boardnr = card[dev->nr];
792 for (i = 0; UNSET == dm1105dvb->boardnr && 817 for (i = 0; UNSET == dev->boardnr &&
793 i < ARRAY_SIZE(dm1105_subids); i++) 818 i < ARRAY_SIZE(dm1105_subids); i++)
794 if (pdev->subsystem_vendor == 819 if (pdev->subsystem_vendor ==
795 dm1105_subids[i].subvendor && 820 dm1105_subids[i].subvendor &&
796 pdev->subsystem_device == 821 pdev->subsystem_device ==
797 dm1105_subids[i].subdevice) 822 dm1105_subids[i].subdevice)
798 dm1105dvb->boardnr = dm1105_subids[i].card; 823 dev->boardnr = dm1105_subids[i].card;
799 824
800 if (UNSET == dm1105dvb->boardnr) { 825 if (UNSET == dev->boardnr) {
801 dm1105dvb->boardnr = DM1105_BOARD_UNKNOWN; 826 dev->boardnr = DM1105_BOARD_UNKNOWN;
802 dm1105_card_list(pdev); 827 dm1105_card_list(pdev);
803 } 828 }
804 829
805 dm1105_devcount++; 830 dm1105_devcount++;
806 dm1105dvb->pdev = pdev; 831 dev->pdev = pdev;
807 dm1105dvb->buffer_size = 5 * DM1105_DMA_BYTES; 832 dev->buffer_size = 5 * DM1105_DMA_BYTES;
808 dm1105dvb->PacketErrorCount = 0; 833 dev->PacketErrorCount = 0;
809 dm1105dvb->dmarst = 0; 834 dev->dmarst = 0;
810 835
811 ret = pci_enable_device(pdev); 836 ret = pci_enable_device(pdev);
812 if (ret < 0) 837 if (ret < 0)
@@ -822,47 +847,47 @@ static int __devinit dm1105_probe(struct pci_dev *pdev,
822 if (ret < 0) 847 if (ret < 0)
823 goto err_pci_disable_device; 848 goto err_pci_disable_device;
824 849
825 dm1105dvb->io_mem = pci_iomap(pdev, 0, pci_resource_len(pdev, 0)); 850 dev->io_mem = pci_iomap(pdev, 0, pci_resource_len(pdev, 0));
826 if (!dm1105dvb->io_mem) { 851 if (!dev->io_mem) {
827 ret = -EIO; 852 ret = -EIO;
828 goto err_pci_release_regions; 853 goto err_pci_release_regions;
829 } 854 }
830 855
831 spin_lock_init(&dm1105dvb->lock); 856 spin_lock_init(&dev->lock);
832 pci_set_drvdata(pdev, dm1105dvb); 857 pci_set_drvdata(pdev, dev);
833 858
834 ret = dm1105dvb_hw_init(dm1105dvb); 859 ret = dm1105_hw_init(dev);
835 if (ret < 0) 860 if (ret < 0)
836 goto err_pci_iounmap; 861 goto err_pci_iounmap;
837 862
838 /* i2c */ 863 /* i2c */
839 i2c_set_adapdata(&dm1105dvb->i2c_adap, dm1105dvb); 864 i2c_set_adapdata(&dev->i2c_adap, dev);
840 strcpy(dm1105dvb->i2c_adap.name, DRIVER_NAME); 865 strcpy(dev->i2c_adap.name, DRIVER_NAME);
841 dm1105dvb->i2c_adap.owner = THIS_MODULE; 866 dev->i2c_adap.owner = THIS_MODULE;
842 dm1105dvb->i2c_adap.class = I2C_CLASS_TV_DIGITAL; 867 dev->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
843 dm1105dvb->i2c_adap.dev.parent = &pdev->dev; 868 dev->i2c_adap.dev.parent = &pdev->dev;
844 dm1105dvb->i2c_adap.algo = &dm1105_algo; 869 dev->i2c_adap.algo = &dm1105_algo;
845 dm1105dvb->i2c_adap.algo_data = dm1105dvb; 870 dev->i2c_adap.algo_data = dev;
846 ret = i2c_add_adapter(&dm1105dvb->i2c_adap); 871 ret = i2c_add_adapter(&dev->i2c_adap);
847 872
848 if (ret < 0) 873 if (ret < 0)
849 goto err_dm1105dvb_hw_exit; 874 goto err_dm1105_hw_exit;
850 875
851 /* dvb */ 876 /* dvb */
852 ret = dvb_register_adapter(&dm1105dvb->dvb_adapter, DRIVER_NAME, 877 ret = dvb_register_adapter(&dev->dvb_adapter, DRIVER_NAME,
853 THIS_MODULE, &pdev->dev, adapter_nr); 878 THIS_MODULE, &pdev->dev, adapter_nr);
854 if (ret < 0) 879 if (ret < 0)
855 goto err_i2c_del_adapter; 880 goto err_i2c_del_adapter;
856 881
857 dvb_adapter = &dm1105dvb->dvb_adapter; 882 dvb_adapter = &dev->dvb_adapter;
858 883
859 dm1105dvb_read_mac(dm1105dvb, dvb_adapter->proposed_mac); 884 dm1105_read_mac(dev, dvb_adapter->proposed_mac);
860 885
861 dvbdemux = &dm1105dvb->demux; 886 dvbdemux = &dev->demux;
862 dvbdemux->filternum = 256; 887 dvbdemux->filternum = 256;
863 dvbdemux->feednum = 256; 888 dvbdemux->feednum = 256;
864 dvbdemux->start_feed = dm1105dvb_start_feed; 889 dvbdemux->start_feed = dm1105_start_feed;
865 dvbdemux->stop_feed = dm1105dvb_stop_feed; 890 dvbdemux->stop_feed = dm1105_stop_feed;
866 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | 891 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
867 DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING); 892 DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
868 ret = dvb_dmx_init(dvbdemux); 893 ret = dvb_dmx_init(dvbdemux);
@@ -870,113 +895,113 @@ static int __devinit dm1105_probe(struct pci_dev *pdev,
870 goto err_dvb_unregister_adapter; 895 goto err_dvb_unregister_adapter;
871 896
872 dmx = &dvbdemux->dmx; 897 dmx = &dvbdemux->dmx;
873 dm1105dvb->dmxdev.filternum = 256; 898 dev->dmxdev.filternum = 256;
874 dm1105dvb->dmxdev.demux = dmx; 899 dev->dmxdev.demux = dmx;
875 dm1105dvb->dmxdev.capabilities = 0; 900 dev->dmxdev.capabilities = 0;
876 901
877 ret = dvb_dmxdev_init(&dm1105dvb->dmxdev, dvb_adapter); 902 ret = dvb_dmxdev_init(&dev->dmxdev, dvb_adapter);
878 if (ret < 0) 903 if (ret < 0)
879 goto err_dvb_dmx_release; 904 goto err_dvb_dmx_release;
880 905
881 dm1105dvb->hw_frontend.source = DMX_FRONTEND_0; 906 dev->hw_frontend.source = DMX_FRONTEND_0;
882 907
883 ret = dmx->add_frontend(dmx, &dm1105dvb->hw_frontend); 908 ret = dmx->add_frontend(dmx, &dev->hw_frontend);
884 if (ret < 0) 909 if (ret < 0)
885 goto err_dvb_dmxdev_release; 910 goto err_dvb_dmxdev_release;
886 911
887 dm1105dvb->mem_frontend.source = DMX_MEMORY_FE; 912 dev->mem_frontend.source = DMX_MEMORY_FE;
888 913
889 ret = dmx->add_frontend(dmx, &dm1105dvb->mem_frontend); 914 ret = dmx->add_frontend(dmx, &dev->mem_frontend);
890 if (ret < 0) 915 if (ret < 0)
891 goto err_remove_hw_frontend; 916 goto err_remove_hw_frontend;
892 917
893 ret = dmx->connect_frontend(dmx, &dm1105dvb->hw_frontend); 918 ret = dmx->connect_frontend(dmx, &dev->hw_frontend);
894 if (ret < 0) 919 if (ret < 0)
895 goto err_remove_mem_frontend; 920 goto err_remove_mem_frontend;
896 921
897 ret = frontend_init(dm1105dvb); 922 ret = frontend_init(dev);
898 if (ret < 0) 923 if (ret < 0)
899 goto err_disconnect_frontend; 924 goto err_disconnect_frontend;
900 925
901 dvb_net_init(dvb_adapter, &dm1105dvb->dvbnet, dmx); 926 dvb_net_init(dvb_adapter, &dev->dvbnet, dmx);
902 dm1105_ir_init(dm1105dvb); 927 dm1105_ir_init(dev);
903 928
904 INIT_WORK(&dm1105dvb->work, dm1105_dmx_buffer); 929 INIT_WORK(&dev->work, dm1105_dmx_buffer);
905 sprintf(dm1105dvb->wqn, "%s/%d", dvb_adapter->name, dvb_adapter->num); 930 sprintf(dev->wqn, "%s/%d", dvb_adapter->name, dvb_adapter->num);
906 dm1105dvb->wq = create_singlethread_workqueue(dm1105dvb->wqn); 931 dev->wq = create_singlethread_workqueue(dev->wqn);
907 if (!dm1105dvb->wq) 932 if (!dev->wq)
908 goto err_dvb_net; 933 goto err_dvb_net;
909 934
910 ret = request_irq(pdev->irq, dm1105dvb_irq, IRQF_SHARED, 935 ret = request_irq(pdev->irq, dm1105_irq, IRQF_SHARED,
911 DRIVER_NAME, dm1105dvb); 936 DRIVER_NAME, dev);
912 if (ret < 0) 937 if (ret < 0)
913 goto err_workqueue; 938 goto err_workqueue;
914 939
915 return 0; 940 return 0;
916 941
917err_workqueue: 942err_workqueue:
918 destroy_workqueue(dm1105dvb->wq); 943 destroy_workqueue(dev->wq);
919err_dvb_net: 944err_dvb_net:
920 dvb_net_release(&dm1105dvb->dvbnet); 945 dvb_net_release(&dev->dvbnet);
921err_disconnect_frontend: 946err_disconnect_frontend:
922 dmx->disconnect_frontend(dmx); 947 dmx->disconnect_frontend(dmx);
923err_remove_mem_frontend: 948err_remove_mem_frontend:
924 dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend); 949 dmx->remove_frontend(dmx, &dev->mem_frontend);
925err_remove_hw_frontend: 950err_remove_hw_frontend:
926 dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend); 951 dmx->remove_frontend(dmx, &dev->hw_frontend);
927err_dvb_dmxdev_release: 952err_dvb_dmxdev_release:
928 dvb_dmxdev_release(&dm1105dvb->dmxdev); 953 dvb_dmxdev_release(&dev->dmxdev);
929err_dvb_dmx_release: 954err_dvb_dmx_release:
930 dvb_dmx_release(dvbdemux); 955 dvb_dmx_release(dvbdemux);
931err_dvb_unregister_adapter: 956err_dvb_unregister_adapter:
932 dvb_unregister_adapter(dvb_adapter); 957 dvb_unregister_adapter(dvb_adapter);
933err_i2c_del_adapter: 958err_i2c_del_adapter:
934 i2c_del_adapter(&dm1105dvb->i2c_adap); 959 i2c_del_adapter(&dev->i2c_adap);
935err_dm1105dvb_hw_exit: 960err_dm1105_hw_exit:
936 dm1105dvb_hw_exit(dm1105dvb); 961 dm1105_hw_exit(dev);
937err_pci_iounmap: 962err_pci_iounmap:
938 pci_iounmap(pdev, dm1105dvb->io_mem); 963 pci_iounmap(pdev, dev->io_mem);
939err_pci_release_regions: 964err_pci_release_regions:
940 pci_release_regions(pdev); 965 pci_release_regions(pdev);
941err_pci_disable_device: 966err_pci_disable_device:
942 pci_disable_device(pdev); 967 pci_disable_device(pdev);
943err_kfree: 968err_kfree:
944 pci_set_drvdata(pdev, NULL); 969 pci_set_drvdata(pdev, NULL);
945 kfree(dm1105dvb); 970 kfree(dev);
946 return ret; 971 return ret;
947} 972}
948 973
949static void __devexit dm1105_remove(struct pci_dev *pdev) 974static void __devexit dm1105_remove(struct pci_dev *pdev)
950{ 975{
951 struct dm1105dvb *dm1105dvb = pci_get_drvdata(pdev); 976 struct dm1105_dev *dev = pci_get_drvdata(pdev);
952 struct dvb_adapter *dvb_adapter = &dm1105dvb->dvb_adapter; 977 struct dvb_adapter *dvb_adapter = &dev->dvb_adapter;
953 struct dvb_demux *dvbdemux = &dm1105dvb->demux; 978 struct dvb_demux *dvbdemux = &dev->demux;
954 struct dmx_demux *dmx = &dvbdemux->dmx; 979 struct dmx_demux *dmx = &dvbdemux->dmx;
955 980
956 dm1105_ir_exit(dm1105dvb); 981 dm1105_ir_exit(dev);
957 dmx->close(dmx); 982 dmx->close(dmx);
958 dvb_net_release(&dm1105dvb->dvbnet); 983 dvb_net_release(&dev->dvbnet);
959 if (dm1105dvb->fe) 984 if (dev->fe)
960 dvb_unregister_frontend(dm1105dvb->fe); 985 dvb_unregister_frontend(dev->fe);
961 986
962 dmx->disconnect_frontend(dmx); 987 dmx->disconnect_frontend(dmx);
963 dmx->remove_frontend(dmx, &dm1105dvb->mem_frontend); 988 dmx->remove_frontend(dmx, &dev->mem_frontend);
964 dmx->remove_frontend(dmx, &dm1105dvb->hw_frontend); 989 dmx->remove_frontend(dmx, &dev->hw_frontend);
965 dvb_dmxdev_release(&dm1105dvb->dmxdev); 990 dvb_dmxdev_release(&dev->dmxdev);
966 dvb_dmx_release(dvbdemux); 991 dvb_dmx_release(dvbdemux);
967 dvb_unregister_adapter(dvb_adapter); 992 dvb_unregister_adapter(dvb_adapter);
968 if (&dm1105dvb->i2c_adap) 993 if (&dev->i2c_adap)
969 i2c_del_adapter(&dm1105dvb->i2c_adap); 994 i2c_del_adapter(&dev->i2c_adap);
970 995
971 dm1105dvb_hw_exit(dm1105dvb); 996 dm1105_hw_exit(dev);
972 synchronize_irq(pdev->irq); 997 synchronize_irq(pdev->irq);
973 free_irq(pdev->irq, dm1105dvb); 998 free_irq(pdev->irq, dev);
974 pci_iounmap(pdev, dm1105dvb->io_mem); 999 pci_iounmap(pdev, dev->io_mem);
975 pci_release_regions(pdev); 1000 pci_release_regions(pdev);
976 pci_disable_device(pdev); 1001 pci_disable_device(pdev);
977 pci_set_drvdata(pdev, NULL); 1002 pci_set_drvdata(pdev, NULL);
978 dm1105_devcount--; 1003 dm1105_devcount--;
979 kfree(dm1105dvb); 1004 kfree(dev);
980} 1005}
981 1006
982static struct pci_device_id dm1105_id_table[] __devinitdata = { 1007static struct pci_device_id dm1105_id_table[] __devinitdata = {