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 | |
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
----------------------------------------------------------------------
-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 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/compat.h | 5 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci-budget/budget-core.c | 54 | ||||
-rw-r--r-- | linux/drivers/media/video/dpc7146.c | 8 |
6 files changed, 73 insertions, 79 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) /********************************************************************************/ diff --git a/linux/drivers/media/dvb/dvb-core/compat.h b/linux/drivers/media/dvb/dvb-core/compat.h index c78e849ef..35471c721 100644 --- a/linux/drivers/media/dvb/dvb-core/compat.h +++ b/linux/drivers/media/dvb/dvb-core/compat.h @@ -81,11 +81,10 @@ int try_module_get(struct module *mod) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20) - extern struct page * vmalloc_to_page(void *addr); - +#define unlikely(x) __builtin_expect((x),0) +#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) #endif - #endif diff --git a/linux/drivers/media/dvb/ttpci-budget/budget-core.c b/linux/drivers/media/dvb/ttpci-budget/budget-core.c index 684177f8e..71cbcfffd 100644 --- a/linux/drivers/media/dvb/ttpci-budget/budget-core.c +++ b/linux/drivers/media/dvb/ttpci-budget/budget-core.c @@ -9,35 +9,6 @@ int budget_debug = 0; * 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; -} - - static inline void ddelay(int i) { current->state=TASK_INTERRUPTIBLE; @@ -262,10 +233,7 @@ int ttpci_budget_init (struct budget *budget, struct saa7146_dev* dev, struct saa7146_pci_extension_data *info) { - struct scatterlist *slist = NULL; - int slen = 0; int length = TS_WIDTH*TS_HEIGHT; - int pages = (length+PAGE_SIZE-1)/PAGE_SIZE; int ret = 0; struct budget_info *bi = info->ext_priv; @@ -297,28 +265,11 @@ int ttpci_budget_init (struct budget *budget, return -ENOMEM; } - budget->grabbing = vmalloc(length); - if (!budget->grabbing) { - printk(KERN_ERR "dvb: vmalloc() failed.\n"); + if( NULL == (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci,length,&budget->pt))) { ret = -ENOMEM; goto err; } - if (!(slist = vmalloc_to_sg(budget->grabbing, pages))) { - printk(KERN_ERR "dvb: vmalloc_to_sg() failed.\n"); - ret = -ENOMEM; - goto err; - } - - if (saa7146_pgtable_alloc(dev->pci, &budget->pt)) { - printk(KERN_ERR "dvb: saa7146_pgtable_alloc() failed.\n"); - ret = -ENOMEM; - goto err; - } - - slen = pci_map_sg(dev->pci,slist,pages,PCI_DMA_FROMDEVICE); - saa7146_pgtable_build_single(dev->pci, &budget->pt, slist, slen); - saa7146_write(dev, PCI_BT_V1, 0x001c0000); /* upload all */ saa7146_write(dev, GPIO_CTRL, 0x000000); @@ -331,9 +282,6 @@ int ttpci_budget_init (struct budget *budget, return 0; err: - if (slist) - kfree(slist); - if (budget->grabbing) vfree(budget->grabbing); diff --git a/linux/drivers/media/video/dpc7146.c b/linux/drivers/media/video/dpc7146.c index 4c524568f..2d0b45e9a 100644 --- a/linux/drivers/media/video/dpc7146.c +++ b/linux/drivers/media/video/dpc7146.c @@ -92,8 +92,7 @@ struct dpc int cur_input; /* current input */ }; -/* fixme: add vbi stuff here, look at dpc.c */ - +/* fixme: add vbi stuff here */ static int dpc_probe(struct saa7146_dev* dev) { struct dpc* dpc = 0; @@ -101,7 +100,7 @@ static int dpc_probe(struct saa7146_dev* dev) dpc = (struct dpc*)kmalloc(sizeof(struct dpc), GFP_KERNEL); if( NULL == dpc ) { - printk("dpc_v4l2.o: dpc_attach: not enough kernel memory.\n"); + printk("dpc_v4l2.o: dpc_probe: not enough kernel memory.\n"); return -ENOMEM; } memset(dpc, 0x0, sizeof(struct dpc)); @@ -202,7 +201,6 @@ static int dpc_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data i2c_use_client(dpc->saa7111a); printk("dpc: found 'dpc7146 demonstration board'-%d.\n",dpc_num); - dpc_num++; /* the rest */ @@ -334,6 +332,8 @@ struct pci_device_id pci_tbl[] = { .subvendor = 0x0000, .subdevice = 0x0000, .driver_data = (unsigned long)&dpc, + }, { + .vendor = 0, } }; |