From bbff4037e33929d1353b8f065862d9fc66ef05a9 Mon Sep 17 00:00:00 2001 From: Michael Hunold Date: Thu, 20 Nov 2003 10:50:15 +0000 Subject: - 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 --- linux/drivers/media/common/saa7146_core.c | 54 +++++++++++++++++++++++++++++++ linux/drivers/media/common/saa7146_hlp.c | 18 ----------- 2 files changed, 54 insertions(+), 18 deletions(-) (limited to 'linux/drivers/media/common') 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 @@ -44,6 +44,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) { -- cgit v1.2.3