diff options
author | Andrew de Quincy <devnull@localhost> | 2004-11-12 17:30:07 +0000 |
---|---|---|
committer | Andrew de Quincy <devnull@localhost> | 2004-11-12 17:30:07 +0000 |
commit | 0f191893b127c16c0a9ccfc3557ddf4dbae2f1a9 (patch) | |
tree | d43ab2a49c06c0f98080aa61b059a91c218abc2b /linux/drivers | |
parent | ff1fec5eac165d66fb5693c745a8ab7930d09fd2 (diff) | |
download | mediapointer-dvb-s2-0f191893b127c16c0a9ccfc3557ddf4dbae2f1a9.tar.gz mediapointer-dvb-s2-0f191893b127c16c0a9ccfc3557ddf4dbae2f1a9.tar.bz2 |
Updated to fix problems with some CAMs on KNC1 cards
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/dvb/ttpci/av7110.c | 30 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/av7110_hw.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/budget-av.c | 47 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/budget-ci.c | 34 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/budget-core.c | 53 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/budget.h | 4 |
6 files changed, 97 insertions, 87 deletions
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c index 053ac9c66..9185b0aef 100644 --- a/linux/drivers/media/dvb/ttpci/av7110.c +++ b/linux/drivers/media/dvb/ttpci/av7110.c @@ -582,7 +582,7 @@ static void gpioirq (unsigned long data) wake_up(&cibuf->queue); iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); - saa7146_wait_for_debi_done(av7110->dev); + saa7146_wait_for_debi_done(av7110->dev, 1); saa7146_write(av7110->dev, IER, saa7146_read(av7110->dev, IER) | MASK_19); if (len < 5) @@ -620,7 +620,7 @@ static void gpioirq (unsigned long data) dprintk(8, "GPIO0 PES_PLAY len=%04x\n", len); iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2); iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2); - saa7146_wait_for_debi_done(av7110->dev); + saa7146_wait_for_debi_done(av7110->dev, 1); saa7146_write(av7110->dev, IER, saa7146_read(av7110->dev, IER) | MASK_19); @@ -647,7 +647,7 @@ static void gpioirq (unsigned long data) memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len); av7110->bmpp += len; av7110->bmplen -= len; - saa7146_wait_for_debi_done(av7110->dev); + saa7146_wait_for_debi_done(av7110->dev, 1); saa7146_write(av7110->dev, IER, saa7146_read(av7110->dev, IER) | MASK_19); if (len < 5) @@ -669,7 +669,7 @@ static void gpioirq (unsigned long data) case DATA_TS_RECORD: case DATA_PES_RECORD: - saa7146_wait_for_debi_done(av7110->dev); + saa7146_wait_for_debi_done(av7110->dev, 1); saa7146_write(av7110->dev, IER, saa7146_read(av7110->dev, IER) | MASK_19); irdebi(av7110, DEBISWAB, DPRAM_BASE+rxbuf, 0, len); @@ -677,7 +677,7 @@ static void gpioirq (unsigned long data) return; case DATA_DEBUG_MESSAGE: - saa7146_wait_for_debi_done(av7110->dev); + saa7146_wait_for_debi_done(av7110->dev, 1); if (!len || len > 0xff) { iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); break; @@ -1401,7 +1401,7 @@ static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param // NOTE: since we're using a prescaler of 2, we set the // divisor frequency to 62.5kHz and divide by 125 above - if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) + if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) return -EIO; return 0; } @@ -1654,13 +1654,13 @@ static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ int i; // this calculation does not match the TDA6405TS datasheet! - div = (params->frequency + 36150000) / 62500; + div = (params->frequency + 36150000 + 31250) / 62500; data[0] = (div >> 8) & 0x7f; data[1] = div & 0xff; data[2] = 0xce; // this value does not match the TDA6405TS datasheet! - if (params->frequency < 45000000) + if (params->frequency < 45000000) return -EINVAL; else if (params->frequency < 137000000) data[3] = 0x01; @@ -1701,13 +1701,13 @@ static void av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status) msleep (50); av7110->fe_synced = (status & FE_HAS_LOCK) ? 1 : 0; - + if (av7110->playing) return; if (down_interruptible(&av7110->pid_mutex)) return; - + if (av7110->fe_synced) { SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO], av7110->pids[DMX_PES_AUDIO], @@ -1763,7 +1763,7 @@ static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_ av7110_fe_lock_fix(av7110, 0); return av7110->fe_diseqc_send_master_cmd(fe, cmd); } - + static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd) { struct av7110* av7110 = (struct av7110*) fe->dvb->priv; @@ -1815,7 +1815,7 @@ static void frontend_init(struct av7110 *av7110) switch(av7110->dev->pci->subsystem_device) { case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??)) av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap, read_pwm(av7110)); - if (av7110->fe) + if (av7110->fe) break; break; } @@ -1858,14 +1858,14 @@ static void frontend_init(struct av7110 *av7110) // ALPS TDLB7 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap); - if (av7110->fe) + if (av7110->fe) break; break; case 0x0002: // Hauppauge/TT DVB-C premium rev2.X av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); - if (av7110->fe) + if (av7110->fe) break; break; @@ -1929,7 +1929,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d } dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name, THIS_MODULE); - + /* the Siemens DVB needs this if you want to have the i2c chips get recognized before the main driver is fully loaded */ saa7146_write(dev, GPIO_CTRL, 0x500000); diff --git a/linux/drivers/media/dvb/ttpci/av7110_hw.c b/linux/drivers/media/dvb/ttpci/av7110_hw.c index 3f58e097c..f80b8f633 100644 --- a/linux/drivers/media/dvb/ttpci/av7110_hw.c +++ b/linux/drivers/media/dvb/ttpci/av7110_hw.c @@ -55,7 +55,7 @@ int av7110_debiwrite(struct av7110 *av7110, u32 config, if (count <= 0 || count > 32764) return -1; - if (saa7146_wait_for_debi_done(av7110->dev) < 0) + if (saa7146_wait_for_debi_done(av7110->dev, 1) < 0) return -1; saa7146_write(dev, DEBI_CONFIG, config); if (count <= 4) /* immediate transfer */ @@ -74,7 +74,7 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) if (count > 32764 || count <= 0) return 0; - if (saa7146_wait_for_debi_done(av7110->dev) < 0) + if (saa7146_wait_for_debi_done(av7110->dev, 1) < 0) return 0; saa7146_write(dev, DEBI_AD, av7110->debi_bus); saa7146_write(dev, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff)); @@ -83,7 +83,7 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) saa7146_write(dev, MC2, (2 << 16) | 2); if (count > 4) return count; - saa7146_wait_for_debi_done(av7110->dev); + saa7146_wait_for_debi_done(av7110->dev, 1); result = saa7146_read(dev, DEBI_AD); result &= (0xffffffffUL >> ((4 - count) * 8)); return result; @@ -240,7 +240,7 @@ int av7110_bootarm(struct av7110 *av7110) mwdebi(av7110, DEBISWAB, DPRAM_BASE, bootcode, sizeof(bootcode)); iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); - if (saa7146_wait_for_debi_done(av7110->dev)) { + if (saa7146_wait_for_debi_done(av7110->dev, 1)) { printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " "saa7146_wait_for_debi_done() timed out\n"); return -1; @@ -258,7 +258,7 @@ int av7110_bootarm(struct av7110 *av7110) dprintk(1, "load dpram code\n"); mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram); - if (saa7146_wait_for_debi_done(av7110->dev)) { + if (saa7146_wait_for_debi_done(av7110->dev, 1)) { printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " "saa7146_wait_for_debi_done() timed out after loading DRAM\n"); return -1; @@ -740,7 +740,7 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format, int d, delta; u8 c; int ret; - + dprintk(4, "%p\n", av7110); ret = wait_event_interruptible_timeout(av7110->bmpq, av7110->bmp_state != BMP_LOADING, HZ); @@ -912,14 +912,14 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0, int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc) { int ret; - + ret = down_interruptible(&av7110->osd_sema); if (ret) return -ERESTARTSYS; /* stupid, but OSD functions don't provide a return code anyway */ ret = 0; - + switch (dc->cmd) { case OSD_Close: DestroyOSDWindow(av7110, av7110->osdwin); diff --git a/linux/drivers/media/dvb/ttpci/budget-av.c b/linux/drivers/media/dvb/ttpci/budget-av.c index 0a6f44e6d..b6babd21a 100644 --- a/linux/drivers/media/dvb/ttpci/budget-av.c +++ b/linux/drivers/media/dvb/ttpci/budget-av.c @@ -57,7 +57,6 @@ struct budget_av { struct tasklet_struct ciintf_irq_tasklet; int slot_status; struct dvb_ca_en50221 ca; - spinlock_t gpiolock; }; int enable_ci = 0; @@ -123,10 +122,11 @@ static int ciintf_read_attribute_mem (struct dvb_ca_en50221 *ca, int slot, if (slot != 0) return -EINVAL; - spin_lock(&budget_av->gpiolock); saa7146_setgpio (budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI); - result = ttpci_budget_debiread (&budget_av->budget, DEBICICAM, address & 0xfff, 1); - spin_unlock(&budget_av->gpiolock); + result = ttpci_budget_debiread (&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0); + + if (result == -ETIMEDOUT) + budget_av->slot_status = 0; return result; } @@ -139,10 +139,11 @@ static int ciintf_write_attribute_mem (struct dvb_ca_en50221 *ca, int slot, if (slot != 0) return -EINVAL; - spin_lock(&budget_av->gpiolock); saa7146_setgpio (budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI); - result = ttpci_budget_debiwrite (&budget_av->budget, DEBICICAM, address & 0xfff, 1, value); - spin_unlock(&budget_av->gpiolock); + result = ttpci_budget_debiwrite (&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0); + + if (result == -ETIMEDOUT) + budget_av->slot_status = 0; return result; } @@ -155,10 +156,11 @@ static int ciintf_read_cam_control (struct dvb_ca_en50221 *ca, int slot, if (slot != 0) return -EINVAL; - spin_lock(&budget_av->gpiolock); saa7146_setgpio (budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO); - result = ttpci_budget_debiread (&budget_av->budget, DEBICICAM, address & 3, 1); - spin_unlock(&budget_av->gpiolock); + result = ttpci_budget_debiread (&budget_av->budget, DEBICICAM, address & 3, 1, 0); + + if (result == -ETIMEDOUT) + budget_av->slot_status = 0; return result; } @@ -171,10 +173,11 @@ static int ciintf_write_cam_control (struct dvb_ca_en50221 *ca, int slot, if (slot != 0) return -EINVAL; - spin_lock(&budget_av->gpiolock); saa7146_setgpio (budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO); - result = ttpci_budget_debiwrite (&budget_av->budget, DEBICICAM, address & 3, 1, value); - spin_unlock(&budget_av->gpiolock); + result = ttpci_budget_debiwrite (&budget_av->budget, DEBICICAM, address & 3, 1, value, 0); + + if (result == -ETIMEDOUT) + budget_av->slot_status = 0; return result; } @@ -236,17 +239,14 @@ static int ciintf_poll_slot_status (struct dvb_ca_en50221 *ca, int slot) if (slot != 0) return -EINVAL; - spin_lock(&budget_av->gpiolock); - saa7146_setgpio (saa, 3, SAA7146_GPIO_INPUT); - udelay(1); - cam = saa7146_read (saa, PSR) & MASK_06; - saa7146_setgpio (saa, 3, SAA7146_GPIO_OUTLO); - spin_unlock(&budget_av->gpiolock); + if (!budget_av->slot_status) { + saa7146_setgpio (saa, 3, SAA7146_GPIO_INPUT); + udelay(1); + cam = saa7146_read (saa, PSR) & MASK_06; + saa7146_setgpio (saa, 3, SAA7146_GPIO_OUTLO); - if (cam && (!budget_av->slot_status)) { - budget_av->slot_status = 1; - } else if ((!cam) && budget_av->slot_status) { - budget_av->slot_status = 0; + if (cam) + budget_av->slot_status = 1; } if (budget_av->slot_status == 1) @@ -261,7 +261,6 @@ static int ciintf_init (struct budget_av *budget_av) int result; memset (&budget_av->ca, 0, sizeof (struct dvb_ca_en50221)); - spin_lock_init(&budget_av->gpiolock); /* setup GPIOs */ saa7146_setgpio (saa, 1, SAA7146_GPIO_OUTHI); diff --git a/linux/drivers/media/dvb/ttpci/budget-ci.c b/linux/drivers/media/dvb/ttpci/budget-ci.c index 361cab9bf..5626d7afc 100644 --- a/linux/drivers/media/dvb/ttpci/budget-ci.c +++ b/linux/drivers/media/dvb/ttpci/budget-ci.c @@ -145,7 +145,7 @@ static void msp430_ir_interrupt (unsigned long data) struct budget_ci *budget_ci = (struct budget_ci *) data; struct input_dev *dev = &budget_ci->input_dev; unsigned int code = - ttpci_budget_debiread (&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2) >> 8; + ttpci_budget_debiread (&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1) >> 8; if (code & 0x40) { code &= 0x3f; @@ -229,7 +229,7 @@ static int ciintf_read_attribute_mem (struct dvb_ca_en50221 *ca, int slot, return -EINVAL; return ttpci_budget_debiread (&budget_ci->budget, DEBICICAM, - DEBIADDR_ATTR | (address & 0xfff), 1); + DEBIADDR_ATTR | (address & 0xfff), 1, 1); } static int ciintf_write_attribute_mem (struct dvb_ca_en50221 *ca, int slot, @@ -241,7 +241,7 @@ static int ciintf_write_attribute_mem (struct dvb_ca_en50221 *ca, int slot, return -EINVAL; return ttpci_budget_debiwrite (&budget_ci->budget, DEBICICAM, - DEBIADDR_ATTR | (address & 0xfff), 1, value); + DEBIADDR_ATTR | (address & 0xfff), 1, value, 1); } static int ciintf_read_cam_control (struct dvb_ca_en50221 *ca, int slot, @@ -253,7 +253,7 @@ static int ciintf_read_cam_control (struct dvb_ca_en50221 *ca, int slot, return -EINVAL; return ttpci_budget_debiread (&budget_ci->budget, DEBICICAM, - DEBIADDR_IO | (address & 3), 1); + DEBIADDR_IO | (address & 3), 1, 1); } static int ciintf_write_cam_control (struct dvb_ca_en50221 *ca, int slot, @@ -265,7 +265,7 @@ static int ciintf_write_cam_control (struct dvb_ca_en50221 *ca, int slot, return -EINVAL; return ttpci_budget_debiwrite (&budget_ci->budget, DEBICICAM, - DEBIADDR_IO | (address & 3), 1, value); + DEBIADDR_IO | (address & 3), 1, value, 1); } static int ciintf_slot_reset (struct dvb_ca_en50221 *ca, int slot) @@ -279,10 +279,9 @@ static int ciintf_slot_reset (struct dvb_ca_en50221 *ca, int slot) // trigger on RISING edge during reset so we know when READY is re-asserted saa7146_setgpio (saa, 0, SAA7146_GPIO_IRQHI); budget_ci->slot_status = SLOTSTATUS_RESET; - ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0); + ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1); msleep (1); - ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, - CICONTROL_RESET); + ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, CICONTROL_RESET, 1); saa7146_setgpio (saa, 1, SAA7146_GPIO_OUTHI); ttpci_budget_set_video_port (saa, BUDGET_VIDEO_PORTB); @@ -313,9 +312,8 @@ static int ciintf_slot_ts_enable (struct dvb_ca_en50221 *ca, int slot) saa7146_setgpio (saa, 1, SAA7146_GPIO_OUTLO); - tmp = ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1); - ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, - tmp | CICONTROL_ENABLETS); + tmp = ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1); + ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, tmp | CICONTROL_ENABLETS, 1); ttpci_budget_set_video_port (saa, BUDGET_VIDEO_PORTA); return 0; @@ -332,7 +330,7 @@ static void ciintf_interrupt (unsigned long data) return; // read the CAM status - flags = ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1); + flags = ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1); if (flags & CICONTROL_CAMDETECT) { // GPIO should be set to trigger on falling edge if a CAM is present @@ -383,13 +381,13 @@ static int ciintf_init (struct budget_ci *budget_ci) saa7146_read (saa, MC1) | (0x800 << 16) | 0x800); // test if it is there - if ((ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1) & 0xa0) != 0xa0) { + if ((ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1) & 0xa0) != 0xa0) { result = -ENODEV; goto error; } // determine whether a CAM is present or not - flags = ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1); + flags = ttpci_budget_debiread (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1); budget_ci->slot_status = SLOTSTATUS_NONE; if (flags & CICONTROL_CAMDETECT) budget_ci->slot_status = SLOTSTATUS_PRESENT; @@ -422,8 +420,7 @@ static int ciintf_init (struct budget_ci *budget_ci) saa7146_setgpio (saa, 0, SAA7146_GPIO_IRQHI); } saa7146_write (saa, IER, saa7146_read (saa, IER) | MASK_03); - ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, - CICONTROL_RESET); + ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, CICONTROL_RESET, 1); // success! printk ("budget_ci: CI interface initialised\n"); @@ -450,10 +447,9 @@ static void ciintf_deinit (struct budget_ci *budget_ci) saa7146_write (saa, IER, saa7146_read (saa, IER) & ~MASK_03); saa7146_setgpio (saa, 0, SAA7146_GPIO_INPUT); tasklet_kill (&budget_ci->ciintf_irq_tasklet); - ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0); + ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1); msleep (1); - ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, - CICONTROL_RESET); + ttpci_budget_debiwrite (&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, CICONTROL_RESET, 1); // disable TS data stream to CI interface saa7146_setgpio (saa, 1, SAA7146_GPIO_INPUT); diff --git a/linux/drivers/media/dvb/ttpci/budget-core.c b/linux/drivers/media/dvb/ttpci/budget-core.c index 86c7d2b93..c42fc407a 100644 --- a/linux/drivers/media/dvb/ttpci/budget-core.c +++ b/linux/drivers/media/dvb/ttpci/budget-core.c @@ -163,21 +163,23 @@ static void vpeirq (unsigned long data) } -u32 ttpci_budget_debiread (struct budget *budget, u32 config, int addr, - int count) +int ttpci_budget_debiread (struct budget *budget, u32 config, int addr, + int count, int uselocks) { struct saa7146_dev *saa = budget->dev; - u32 result = 0; - unsigned long flags; + int result = 0; + unsigned long flags = 0; if (count > 4 || count <= 0) return 0; - spin_lock_irqsave (&budget->debilock, flags); + if (uselocks) + spin_lock_irqsave (&budget->debilock, flags); - if (saa7146_wait_for_debi_done (saa) < 0) { - spin_unlock_irqrestore (&budget->debilock, flags); - return 0; + if ((result = saa7146_wait_for_debi_done (saa, uselocks)) < 0) { + if (uselocks) + spin_unlock_irqrestore (&budget->debilock, flags); + return result; } saa7146_write (saa, DEBI_COMMAND, @@ -186,30 +188,38 @@ u32 ttpci_budget_debiread (struct budget *budget, u32 config, int addr, saa7146_write (saa, DEBI_PAGE, 0); saa7146_write (saa, MC2, (2 << 16) | 2); - saa7146_wait_for_debi_done (saa); + if ((result = saa7146_wait_for_debi_done (saa, uselocks)) < 0) { + if (uselocks) + spin_unlock_irqrestore (&budget->debilock, flags); + return result; + } result = saa7146_read (saa, DEBI_AD); result &= (0xffffffffUL >> ((4 - count) * 8)); - spin_unlock_irqrestore (&budget->debilock, flags); + if (uselocks) + spin_unlock_irqrestore (&budget->debilock, flags); return result; } -u8 ttpci_budget_debiwrite (struct budget *budget, u32 config, int addr, - int count, u32 value) +int ttpci_budget_debiwrite (struct budget *budget, u32 config, int addr, + int count, u32 value, int uselocks) { struct saa7146_dev *saa = budget->dev; - unsigned long flags; + unsigned long flags = 0; + int result; if (count > 4 || count <= 0) return 0; - spin_lock_irqsave (&budget->debilock, flags); + if (uselocks) + spin_lock_irqsave (&budget->debilock, flags); - if (saa7146_wait_for_debi_done (saa) < 0) { - spin_unlock_irqrestore (&budget->debilock, flags); - return 0; + if ((result = saa7146_wait_for_debi_done (saa, uselocks)) < 0) { + if (uselocks) + spin_unlock_irqrestore (&budget->debilock, flags); + return result; } saa7146_write (saa, DEBI_COMMAND, @@ -219,9 +229,14 @@ u8 ttpci_budget_debiwrite (struct budget *budget, u32 config, int addr, saa7146_write (saa, DEBI_AD, value); saa7146_write (saa, MC2, (2 << 16) | 2); - saa7146_wait_for_debi_done (saa); + if ((result = saa7146_wait_for_debi_done (saa, uselocks)) < 0) { + if (uselocks) + spin_unlock_irqrestore (&budget->debilock, flags); + return result; + } - spin_unlock_irqrestore (&budget->debilock, flags); + if (uselocks) + spin_unlock_irqrestore (&budget->debilock, flags); return 0; } diff --git a/linux/drivers/media/dvb/ttpci/budget.h b/linux/drivers/media/dvb/ttpci/budget.h index de7c0bf34..9be5388b8 100644 --- a/linux/drivers/media/dvb/ttpci/budget.h +++ b/linux/drivers/media/dvb/ttpci/budget.h @@ -102,7 +102,7 @@ extern int ttpci_budget_deinit (struct budget *budget); extern void ttpci_budget_irq10_handler (struct saa7146_dev *dev, u32 * isr); extern void ttpci_budget_set_video_port (struct saa7146_dev *dev, int video_port); -extern u32 ttpci_budget_debiread (struct budget *budget, u32 config, int addr, int count); -extern u8 ttpci_budget_debiwrite (struct budget *budget, u32 config, int addr, int count, u32 value); +extern int ttpci_budget_debiread (struct budget *budget, u32 config, int addr, int count, int uselocks); +extern int ttpci_budget_debiwrite (struct budget *budget, u32 config, int addr, int count, u32 value, int uselocks); #endif |