diff options
author | Michael Hunold <devnull@localhost> | 2003-03-17 21:21:56 +0000 |
---|---|---|
committer | Michael Hunold <devnull@localhost> | 2003-03-17 21:21:56 +0000 |
commit | 0e0505bca61e2877a5283e37ad447f1496fb5503 (patch) | |
tree | 480e781f36aebe33f461e4d73c16267cb054b0b5 /linux/drivers/media/common | |
parent | 8dd52d823f399f39d02e35cbd32da30175d0429b (diff) | |
download | mediapointer-dvb-s2-0e0505bca61e2877a5283e37ad447f1496fb5503.tar.gz mediapointer-dvb-s2-0e0505bca61e2877a5283e37ad447f1496fb5503.tar.bz2 |
- Fixed the build-2.4 tree to compile with 2.4.18 kernels.
- Moved some generic stuff from budget-core.c to saa7146_core.c where it belongs
----------------------------------------------------------------------
Diffstat (limited to 'linux/drivers/media/common')
-rw-r--r-- | linux/drivers/media/common/saa7146.h | 9 | ||||
-rw-r--r-- | linux/drivers/media/common/saa7146_core.c | 63 | ||||
-rw-r--r-- | linux/drivers/media/common/saa7146_fops.c | 13 |
3 files changed, 66 insertions, 19 deletions
diff --git a/linux/drivers/media/common/saa7146.h b/linux/drivers/media/common/saa7146.h index fd1cb221d..dcb4510c5 100644 --- a/linux/drivers/media/common/saa7146.h +++ b/linux/drivers/media/common/saa7146.h @@ -14,17 +14,13 @@ #include <asm/io.h> /* for accessing devices */ #include <linux/stringify.h> +#include "compat.h" + #define SAA7146_VERSION_CODE KERNEL_VERSION(0,5,0) #define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr))) #define saa7146_read(sxy,adr) readl(sxy->mem+(adr)) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) -#define BUG_ON(condition) do { if ((condition)!=0) BUG(); } while(0) -#endif -#endif - extern unsigned int saa7146_debug; //#define DEBUG_PROLOG printk("(0x%08x)(0x%08x) %s: %s(): ",(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,RPS_ADDR0))),(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,IER))),__stringify(KBUILD_MODNAME),__FUNCTION__) @@ -152,6 +148,7 @@ struct saa7146_format* format_by_fourcc(struct saa7146_dev *dev, int fourcc); int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt); void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt); void 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); /* some memory sizes */ diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c index 8142adb55..8f894a102 100644 --- a/linux/drivers/media/common/saa7146_core.c +++ b/linux/drivers/media/common/saa7146_core.c @@ -45,11 +45,73 @@ static void dump_registers(struct saa7146_dev* dev) } } +/**************************************************************************** + * general helper functions + ****************************************************************************/ + +/* this is videobuf_vmalloc_to_sg() from video-buf.c */ +static +struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) +{ + struct scatterlist *sglist; + struct page *pg; + int i; + + sglist = kmalloc(sizeof(struct scatterlist)*nr_pages, GFP_KERNEL); + if (NULL == sglist) + return NULL; + memset(sglist,0,sizeof(struct scatterlist)*nr_pages); + for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { + pg = vmalloc_to_page(virt); + if (NULL == pg) + goto err; + if (PageHighMem(pg)) + BUG(); + sglist[i].page = pg; + sglist[i].length = PAGE_SIZE; + } + return sglist; + + err: + kfree(sglist); + return NULL; +} + /********************************************************************************/ /* common page table functions */ #define SAA7146_PGTABLE_SIZE 4096 +char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt) +{ + struct scatterlist *slist = NULL; + int pages = (length+PAGE_SIZE-1)/PAGE_SIZE; + char *mem = vmalloc(length); + int slen = 0; + + if (NULL == mem) { + return NULL; + } + + if (!(slist = vmalloc_to_sg(mem, pages))) { + vfree(mem); + return NULL; + } + + if (saa7146_pgtable_alloc(pci, pt)) { + kfree(slist); + vfree(mem); + return NULL; + } + + slen = pci_map_sg(pci,slist,pages,PCI_DMA_FROMDEVICE); + saa7146_pgtable_build_single(pci, pt, slist, slen); + + /* fixme: here's a memory leak: slist never gets freed by any other + function ...*/ + return mem; +} + void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) { //fm DEB_EE(("pci:%p, pt:%p\n",pci,pt)); @@ -443,6 +505,7 @@ EXPORT_SYMBOL_GPL(saa7146_unregister_extension); 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_setgpio); diff --git a/linux/drivers/media/common/saa7146_fops.c b/linux/drivers/media/common/saa7146_fops.c index 9048bc339..9ff5b1650 100644 --- a/linux/drivers/media/common/saa7146_fops.c +++ b/linux/drivers/media/common/saa7146_fops.c @@ -4,19 +4,6 @@ #define KBUILD_MODNAME saa7146 #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,48)) -static inline -int try_module_get(struct module *mod) -{ - if (!MOD_CAN_QUERY(mod)) - return 0; - __MOD_INC_USE_COUNT(mod); - return 1; -} - -#define module_put(mod) __MOD_DEC_USE_COUNT(mod) -#endif - #define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1) /********************************************************************************/ |