diff options
author | Michael Hunold <devnull@localhost> | 2003-11-20 10:50:15 +0000 |
---|---|---|
committer | Michael Hunold <devnull@localhost> | 2003-11-20 10:50:15 +0000 |
commit | bbff4037e33929d1353b8f065862d9fc66ef05a9 (patch) | |
tree | 9c54699a1dc4072a7d6660b81928b26e15a5c623 | |
parent | 73ee18fbc6b15911cd9c4f47bc90d2212e2d09dd (diff) | |
download | mediapointer-dvb-s2-bbff4037e33929d1353b8f065862d9fc66ef05a9.tar.gz mediapointer-dvb-s2-bbff4037e33929d1353b8f065862d9fc66ef05a9.tar.bz2 |
- move saa7146_set_gpio() from saa7146_vv to saa7146_core
- add "new" saa7146_wait_for_debi_done() function, remove other versions
from av7110 and budget.ci
- make budget-ci use this gpio function and the new wait_...() function,
therefore fix
BORROWED_FROM_AV7110_H_BUT_REALLY_BELONGS_IN_SAA7146_DEFS_H remark
-rw-r--r-- | linux/drivers/media/common/saa7146_core.c | 54 | ||||
-rw-r--r-- | linux/drivers/media/common/saa7146_hlp.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/av7110.c | 36 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/budget-ci.c | 89 | ||||
-rw-r--r-- | linux/include/media/saa7146.h | 4 |
5 files changed, 68 insertions, 133 deletions
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c index 84c6beb92..206a942af 100644 --- a/linux/drivers/media/common/saa7146_core.c +++ b/linux/drivers/media/common/saa7146_core.c @@ -45,6 +45,59 @@ static void dump_registers(struct saa7146_dev* dev) #endif /**************************************************************************** + * gpio and debi helper functions + ****************************************************************************/ + +/* write "data" to the gpio-pin "pin" */ +void saa7146_set_gpio(struct saa7146_dev *dev, u8 pin, u8 data) +{ + u32 value = 0; + + /* sanity check */ + if(pin > 3) + return; + + /* read old register contents */ + value = saa7146_read(dev, GPIO_CTRL ); + + value &= ~(0xff << (8*pin)); + value |= (data << (8*pin)); + + saa7146_write(dev, GPIO_CTRL, value); +} + +/* This DEBI code is based on the saa7146 Stradis driver by Nathan Laredo */ +int saa7146_wait_for_debi_done(struct saa7146_dev *dev) +{ + int start; + + /* wait for registers to be programmed */ + start = jiffies; + while (1) { + if (saa7146_read(dev, MC2) & 2) + break; + if (jiffies-start > HZ/20) { + DEB_S(("timed out while waiting for registers getting programmed\n")); + return -ETIMEDOUT; + } + } + + /* wait for transfer to complete */ + start = jiffies; + while (1) { + if (!(saa7146_read(dev, PSR) & SPCI_DEBI_S)) + break; + saa7146_read(dev, MC2); + if (jiffies-start > HZ/4) { + DEB_S(("timed out while waiting for transfer completion\n")); + return -ETIMEDOUT; + } + } + + return 0; +} + +/**************************************************************************** * general helper functions ****************************************************************************/ @@ -515,6 +568,7 @@ EXPORT_SYMBOL_GPL(saa7146_pgtable_alloc); EXPORT_SYMBOL_GPL(saa7146_pgtable_free); EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single); EXPORT_SYMBOL_GPL(saa7146_vmalloc_build_pgtable); +EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done); EXPORT_SYMBOL_GPL(saa7146_setgpio); diff --git a/linux/drivers/media/common/saa7146_hlp.c b/linux/drivers/media/common/saa7146_hlp.c index d28ef02a5..0fa8cd7ab 100644 --- a/linux/drivers/media/common/saa7146_hlp.c +++ b/linux/drivers/media/common/saa7146_hlp.c @@ -660,24 +660,6 @@ void saa7146_set_hps_source_and_sync(struct saa7146_dev *dev, int source, int sy vv->current_hps_sync = sync; } -/* write "data" to the gpio-pin "pin" */ -void saa7146_set_gpio(struct saa7146_dev *dev, u8 pin, u8 data) -{ - u32 value = 0; - - /* sanity check */ - if(pin > 3) - return; - - /* read old register contents */ - value = saa7146_read(dev, GPIO_CTRL ); - - value &= ~(0xff << (8*pin)); - value |= (data << (8*pin)); - - saa7146_write(dev, GPIO_CTRL, value); -} - /* reprogram hps, enable(1) / disable(0) video */ void saa7146_set_overlay(struct saa7146_dev *dev, struct saa7146_fh *fh, int v) { diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c index 67288e527..9d9387f10 100644 --- a/linux/drivers/media/dvb/ttpci/av7110.c +++ b/linux/drivers/media/dvb/ttpci/av7110.c @@ -116,42 +116,12 @@ int av7110_num = 0; * DEBI functions ****************************************************************************/ +#define wait_for_debi_done(x) \ + saa7146_wait_for_debi_done(x->dev) \ + /* This DEBI code is based on the Stradis driver by Nathan Laredo <laredo@gnu.org> */ -static int wait_for_debi_done(struct av7110 *av7110) -{ - struct saa7146_dev *dev = av7110->dev; - int start; - - /* wait for registers to be programmed */ - start = jiffies; - while (1) { - if (saa7146_read(dev, MC2) & 2) - break; - if (jiffies-start > HZ/20) { - printk ("%s: timed out while waiting for registers " - "getting programmed\n", __FUNCTION__); - return -ETIMEDOUT; - } - } - - /* wait for transfer to complete */ - start = jiffies; - while (1) { - if (!(saa7146_read(dev, PSR) & SPCI_DEBI_S)) - break; - saa7146_read(dev, MC2); - if (jiffies-start > HZ/4) { - printk ("%s: timed out while waiting for transfer " - "completion\n", __FUNCTION__); - return -ETIMEDOUT; - } - } - - return 0; -} - static int debiwrite(struct av7110 *av7110, u32 config, int addr, u32 val, int count) { diff --git a/linux/drivers/media/dvb/ttpci/budget-ci.c b/linux/drivers/media/dvb/ttpci/budget-ci.c index 5800d289e..d83ca6d12 100644 --- a/linux/drivers/media/dvb/ttpci/budget-ci.c +++ b/linux/drivers/media/dvb/ttpci/budget-ci.c @@ -47,75 +47,14 @@ struct budget_ci { struct tasklet_struct msp430_irq_tasklet; }; - - -#ifndef BORROWED_FROM_AV7110_H_BUT_REALLY_BELONGS_IN_SAA7146_DEFS_H - -#define DEBINOSWAP 0x000e0000 -#define GPIO_IRQHI 0x10 -#define GPIO_INPUT 0x00 - -void gpio_set(struct saa7146_dev* saa, u8 pin, u8 data) -{ - u32 value = 0; - - /* sanity check */ - if(pin > 3) - return; - - /* read old register contents */ - value = saa7146_read(saa, GPIO_CTRL ); - - value &= ~(0xff << (8*pin)); - value |= (data << (8*pin)); - - saa7146_write(saa, GPIO_CTRL, value); -} - - - -static int wait_for_debi_done(struct saa7146_dev *saa) -{ - int start = jiffies; - - /* wait for registers to be programmed */ - while (1) { - if (saa7146_read(saa, MC2) & 2) - break; - if (jiffies - start > HZ / 20) { - printk ("DVB (%s): timed out while waiting" - " for registers getting programmed\n", - __FUNCTION__); - return -ETIMEDOUT; - } - } - - /* wait for transfer to complete */ - start = jiffies; - while (1) { - if (!(saa7146_read(saa, PSR) & SPCI_DEBI_S)) - break; - saa7146_read(saa, MC2); - if (jiffies - start > HZ / 4) { - printk ("DVB (%s): timed out while waiting" - " for transfer completion\n", - __FUNCTION__); - return -ETIMEDOUT; - } - } - - return 0; -} - - -static u32 debiread (struct saa7146_dev *saa, u32 config, int addr, int count) +static u32 budget_debiread4 (struct saa7146_dev *saa, u32 config, int addr, int count) { u32 result = 0; if (count > 4 || count <= 0) return 0; - if (wait_for_debi_done(saa) < 0) + if (saa7146_wait_for_debi_done(saa) < 0) return 0; saa7146_write (saa, DEBI_COMMAND, @@ -124,7 +63,7 @@ static u32 debiread (struct saa7146_dev *saa, u32 config, int addr, int count) saa7146_write(saa, DEBI_CONFIG, config); saa7146_write(saa, MC2, (2 << 16) | 2); - wait_for_debi_done(saa); + saa7146_wait_for_debi_done(saa); result = saa7146_read(saa, DEBI_AD); result &= (0xffffffffUL >> ((4 - count) * 8)); @@ -132,20 +71,6 @@ static u32 debiread (struct saa7146_dev *saa, u32 config, int addr, int count) return result; } - - -/* DEBI during interrupt */ -static inline u32 irdebi(struct saa7146_dev *saa, u32 config, int addr, u32 val, int count) -{ - u32 res; - res = debiread(saa, config, addr, count); - return res; -} -#endif - - - - /* from reading the following remotes: Zenith Universal 7 / TV Mode 807 / VCR Mode 837 Hauppauge (from NOVA-CI-s box product) @@ -223,7 +148,7 @@ static void msp430_ir_interrupt (unsigned long data) struct budget_ci *budget_ci = (struct budget_ci*) data; struct saa7146_dev *saa = budget_ci->budget.dev; struct input_dev *dev = &budget_ci->input_dev; - unsigned int code = irdebi(saa, DEBINOSWAP, 0x1234, 0, 2) >> 8; + unsigned int code = budget_debiread4(saa, DEBINOSWAP, 0x1234, 2) >> 8; if (code & 0x40) { code &= 0x3f; @@ -277,7 +202,7 @@ static int msp430_ir_init (struct budget_ci *budget_ci) saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); - gpio_set(saa, 3, GPIO_IRQHI); + saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); return 0; } @@ -289,8 +214,8 @@ static void msp430_ir_deinit (struct budget_ci *budget_ci) struct input_dev *dev = &budget_ci->input_dev; saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06); - gpio_set(saa, 3, GPIO_INPUT); - gpio_set(saa, 2, GPIO_INPUT); + saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); + saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT); if (del_timer(&dev->timer)) input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0); diff --git a/linux/include/media/saa7146.h b/linux/include/media/saa7146.h index 24e392cc3..f06db5313 100644 --- a/linux/include/media/saa7146.h +++ b/linux/include/media/saa7146.h @@ -165,6 +165,7 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt); int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length ); char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt); void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data); +int saa7146_wait_for_debi_done(struct saa7146_dev *dev); /* some memory sizes */ #define SAA7146_I2C_MEM ( 1*PAGE_SIZE) @@ -187,6 +188,9 @@ void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data); #define SAA7146_GPIO_OUTLO 0x40 #define SAA7146_GPIO_OUTHI 0x50 +/* debi defines */ +#define DEBINOSWAP 0x000e0000 + /* define for the register programming sequencer (rps) */ #define CMD_NOP 0x00000000 /* No operation */ #define CMD_CLR_EVENT 0x00000000 /* Clear event */ |