* [PATH 0/2] ARM: OMAP2: Camera: Fixes compile errors and adds little improvements
@ 2007-11-21 16:43 Eduardo Valentin
2007-11-21 16:43 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Eduardo Valentin
0 siblings, 1 reply; 7+ messages in thread
From: Eduardo Valentin @ 2007-11-21 16:43 UTC (permalink / raw)
To: linux-omap-open-source; +Cc: Eduardo Valentin, Sakari Ailus, linux-omap
Hi All,
This patch set fixes compile erros and adds little improvements
camera code for omap2. Here is the overall description:
V4l2:
- Updates this camera driver to use correctly the new videobuf API.
Corrently, changed to use videobuf_gen and videobuf_dma_sg.
- Removed VIDEO_BUF reference from Kconfig.
S/G:
- Update this code to sg_* helper functions.
ov9640:
- Removes unecessary structures and functions when config OV9640
is not selected.
- Reduces powerset code for ov9640.
Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
Overall diffstat:
arch/arm/mach-omap2/board-h4.c | 71 +++++++++++---------------------------
drivers/media/video/Kconfig | 3 +
drivers/media/video/omap24xxcam.c | 68 +++++++++++++++++++-----------------
drivers/media/video/omap24xxcam.h | 3 -
4 files changed, 61 insertions(+), 84 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's 2007-11-21 16:43 [PATH 0/2] ARM: OMAP2: Camera: Fixes compile errors and adds little improvements Eduardo Valentin @ 2007-11-21 16:43 ` Eduardo Valentin 2007-11-21 16:43 ` [PATCH 2/2] ARM: OMAP2: Camera: Improve ov9640 code on board-h4.c Eduardo Valentin 2007-11-23 11:09 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Sakari Ailus 0 siblings, 2 replies; 7+ messages in thread From: Eduardo Valentin @ 2007-11-21 16:43 UTC (permalink / raw) To: linux-omap-open-source; +Cc: Eduardo Valentin, Sakari Ailus, linux-omap From: Eduardo Valentin <eduardo.valentin@indt.org.br> V4l2: - Updates this camera driver to use correctly the new videobuf API. Currently, changed to use videobuf_gen and videobuf_dma_sg. - Removed VIDEO_BUF reference from Kconfig. S/G: - Update this code to sg_* helper functions. Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br> --- drivers/media/video/Kconfig | 3 +- drivers/media/video/omap24xxcam.c | 68 +++++++++++++++++++----------------- drivers/media/video/omap24xxcam.h | 2 +- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 7285f08..3fd1d98 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -712,7 +712,8 @@ config VIDEO_CAFE_CCIC config VIDEO_OMAP2 tristate "OMAP 2 Camera support (EXPERIMENTAL)" - select VIDEO_BUF + select VIDEOBUF_GEN + select VIDEOBUF_DMA_SG depends on VIDEO_V4L2 && ARCH_OMAP24XX ---help--- Driver for an OMAP 2 camera controller. diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c index 8fda9e1..b61a903 100644 --- a/drivers/media/video/omap24xxcam.c +++ b/drivers/media/video/omap24xxcam.c @@ -226,27 +226,28 @@ static void omap24xxcam_core_isr(struct omap24xxcam_device *cam) */ static void omap24xxcam_vbq_free_mmap_buffer(struct videobuf_buffer *vb) { + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); int i; size_t alloc_size; struct page *page; - if (vb->dma.sglist == NULL) + if (dma->sglist == NULL) return; - i = vb->dma.sglen; + i = dma->sglen; while (i) { i--; - alloc_size = vb->dma.sglist[i].length; - page = vb->dma.sglist[i].page; + alloc_size = sg_dma_len(&dma->sglist[i]); + page = sg_page(&dma->sglist[i]); do { ClearPageReserved(page++); } while (alloc_size -= PAGE_SIZE); - __free_pages(vb->dma.sglist[i].page, - get_order(vb->dma.sglist[i].length)); + __free_pages(sg_page(&dma->sglist[i]), + get_order(sg_dma_len(&dma->sglist[i]))); } - kfree(vb->dma.sglist); - vb->dma.sglist = NULL; + kfree(dma->sglist); + dma->sglist = NULL; } /* Release all memory related to the videobuf_queue. */ @@ -278,6 +279,7 @@ static void omap24xxcam_vbq_free_mmap_buffers(struct videobuf_queue *vbq) */ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) { + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); unsigned int order; size_t alloc_size, size = vb->bsize; /* vb->bsize is page aligned */ struct page *page; @@ -288,9 +290,8 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) * overhead. We may not use as many entries as we allocate */ max_pages = vb->bsize >> PAGE_SHIFT; - vb->dma.sglist = - kcalloc(max_pages, sizeof(*vb->dma.sglist), GFP_KERNEL); - if (vb->dma.sglist == NULL) { + dma->sglist = kcalloc(max_pages, sizeof(*dma->sglist), GFP_KERNEL); + if (dma->sglist == NULL) { err = -ENOMEM; goto out; } @@ -318,9 +319,8 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) size -= (PAGE_SIZE << order); /* append allocated chunk of pages into scatter-gather list */ - vb->dma.sglist[i].page = page; - vb->dma.sglist[i].length = (PAGE_SIZE << order); - vb->dma.sglen++; + sg_set_buf(&dma->sglist[i], page, (PAGE_SIZE << order)); + dma->sglen++; i++; alloc_size = (PAGE_SIZE << order); @@ -337,8 +337,8 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) * REVISIT: not fully correct to assign nr_pages == sglen but * video-buf is passing nr_pages for e.g. unmap_sg calls */ - vb->dma.nr_pages = vb->dma.sglen; - vb->dma.direction = PCI_DMA_FROMDEVICE; + dma->nr_pages = dma->sglen; + dma->direction = PCI_DMA_FROMDEVICE; return 0; @@ -357,11 +357,12 @@ static int omap24xxcam_vbq_alloc_mmap_buffers(struct videobuf_queue *vbq, mutex_lock(&vbq->lock); for (i = 0; i < count; i++) { + struct videobuf_dmabuf *dma = videobuf_to_dma(vbq->bufs[i]); err = omap24xxcam_vbq_alloc_mmap_buffer(vbq->bufs[i]); if (err) goto out; dev_dbg(fh->cam->dev, "sglen is %d for buffer %d\n", - vbq->bufs[i]->dma.sglen, i); + dma->sglen, i); } mutex_unlock(&vbq->lock); @@ -415,7 +416,7 @@ static void omap24xxcam_vbq_complete(struct omap24xxcam_sgdma *sgdma, static void omap24xxcam_vbq_release(struct videobuf_queue *vbq, struct videobuf_buffer *vb) { - struct videobuf_dmabuf *dma = &vb->dma; + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); /* wait for buffer, especially to get out of the sgdma queue */ videobuf_waiton(vb, 0, 0); @@ -424,8 +425,8 @@ static void omap24xxcam_vbq_release(struct videobuf_queue *vbq, dma->direction); dma->direction = DMA_NONE; } else { - videobuf_dma_unmap(vbq, &vb->dma); - videobuf_dma_free(&vb->dma); + videobuf_dma_unmap(vbq, dma); + videobuf_dma_free(dma); } vb->state = STATE_NEEDS_INIT; @@ -476,6 +477,7 @@ static int omap24xxcam_vbq_prepare(struct videobuf_queue *vbq, struct videobuf_buffer *vb, enum v4l2_field field) { + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); struct omap24xxcam_fh *fh = vbq->priv_data; int err = 0; @@ -525,7 +527,7 @@ static int omap24xxcam_vbq_prepare(struct videobuf_queue *vbq, * we have built the scatter-gather list by ourself so * do the scatter-gather mapping as well */ - err = omap24xxcam_dma_iolock(vbq, &vb->dma); + err = omap24xxcam_dma_iolock(vbq, dma); else err = videobuf_iolock(vbq, vb, NULL); } @@ -541,6 +543,7 @@ static int omap24xxcam_vbq_prepare(struct videobuf_queue *vbq, static void omap24xxcam_vbq_queue(struct videobuf_queue *vbq, struct videobuf_buffer *vb) { + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); struct omap24xxcam_fh *fh = vbq->priv_data; struct omap24xxcam_device *cam = fh->cam; enum videobuf_state state = vb->state; @@ -554,8 +557,8 @@ static void omap24xxcam_vbq_queue(struct videobuf_queue *vbq, */ vb->state = STATE_ACTIVE; - err = omap24xxcam_sgdma_queue(&fh->cam->sgdma, vb->dma.sglist, - vb->dma.sglen, vb->size, + err = omap24xxcam_sgdma_queue(&fh->cam->sgdma, dma->sglist, + dma->sglen, vb->size, omap24xxcam_vbq_complete, vb); if (!err) { @@ -1401,15 +1404,17 @@ static int omap24xxcam_mmap_buffers(struct file *file, size = 0; for (i = first; i <= last; i++) { + struct videobuf_dmabuf *dma; vb = vbq->bufs[i]; - for (j = 0; j < vb->dma.sglen; j++) { + dma = videobuf_to_dma(vb); + for (j = 0; j < dma->sglen; j++) { err = remap_pfn_range( vma, vma->vm_start + size, - page_to_pfn(vb->dma.sglist[j].page), - vb->dma.sglist[j].length, vma->vm_page_prot); + page_to_pfn(sg_page(&dma->sglist[j])), + sg_dma_len(&dma->sglist[j]), vma->vm_page_prot); if (err) goto out; - size += vb->dma.sglist[j].length; + size += sg_dma_len(&dma->sglist[j]); } } @@ -1483,10 +1488,10 @@ static int omap24xxcam_open(struct inode *inode, struct file *file) spin_lock_init(&fh->vbq_lock); - videobuf_queue_init(&fh->vbq, &omap24xxcam_vbq_ops, NULL, - &fh->vbq_lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, - V4L2_FIELD_NONE, - sizeof(struct videobuf_buffer), fh); + videobuf_queue_pci_init(&fh->vbq, &omap24xxcam_vbq_ops, NULL, + &fh->vbq_lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, + V4L2_FIELD_NONE, + sizeof(struct videobuf_buffer), fh); return 0; @@ -1635,7 +1640,6 @@ static int omap24xxcam_device_register(struct v4l2_int_device *s) strlcpy(vfd->name, CAM_NAME, sizeof(vfd->name)); vfd->type = VID_TYPE_CAPTURE | VID_TYPE_CHROMAKEY; /* need to register for a VID_HARDWARE_* ID in videodev.h */ - vfd->hardware = 0; vfd->fops = &omap24xxcam_fops; vfd->priv = cam; vfd->minor = -1; diff --git a/drivers/media/video/omap24xxcam.h b/drivers/media/video/omap24xxcam.h index 7799733..00d0e31 100644 --- a/drivers/media/video/omap24xxcam.h +++ b/drivers/media/video/omap24xxcam.h @@ -27,7 +27,7 @@ #ifndef OMAP24XXCAM_H #define OMAP24XXCAM_H -#include <media/video-buf.h> +#include <media/videobuf-dma-sg.h> #include <media/v4l2-int-device.h> /* -- 1.5.3.4.206.g58ba4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] ARM: OMAP2: Camera: Improve ov9640 code on board-h4.c 2007-11-21 16:43 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Eduardo Valentin @ 2007-11-21 16:43 ` Eduardo Valentin 2007-11-22 9:10 ` Trilok Soni 2007-11-23 11:09 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Sakari Ailus 1 sibling, 1 reply; 7+ messages in thread From: Eduardo Valentin @ 2007-11-21 16:43 UTC (permalink / raw) To: linux-omap-open-source; +Cc: Eduardo Valentin, Sakari Ailus, linux-omap From: Eduardo Valentin <eduardo.valentin@indt.org.br> - Removes unnecessary structures and functions when config OV9640 is not selected. - Reduces powerset code for ov9640. Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br> --- arch/arm/mach-omap2/board-h4.c | 70 ++++++++++++--------------------------- 1 files changed, 22 insertions(+), 48 deletions(-) diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c index 85649bb..8fde838 100644 --- a/arch/arm/mach-omap2/board-h4.c +++ b/arch/arm/mach-omap2/board-h4.c @@ -525,6 +525,7 @@ static void __init tusb_evm_setup(void) #endif +#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE) /* * Common OV9640 register initialization for all image sizes, pixel formats, * and frame rates @@ -563,63 +564,37 @@ const static struct ov9640_reg ov9640_common[] = { { OV9640_REG_TERM, OV9640_VAL_TERM } }; -#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE) -static int ov9640_sensor_powerup(void) +static int ov9640_sensor_power_set(int power) { unsigned char expa; int err; /* read current state of GPIO EXPA outputs */ if ((err = read_gpio_expa(&expa, 0x20))) { - printk(KERN_ERR "Error reading GPIO EXPA\n"); - return err; - } - /* Set GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up sensor */ - if ((err = write_gpio_expa(expa | 0x08, 0x20))) { - printk(KERN_ERR "Error writing to GPIO EXPA\n"); - return err; - } - - /* read current state of GPIO EXPA outputs */ - if ((err = read_gpio_expa(&expa, 0x22))) { - printk(KERN_ERR "Error reading GPIO EXPA\n"); - return err; - } - /* Clear GPIO EXPA P7 (CAM_RST) */ - if ((err = write_gpio_expa(expa & ~0x80, 0x22))) { - printk(KERN_ERR "Error writing to GPIO EXPA\n"); + printk(KERN_ERR "Error reading GPIO EXPA 0x20\n"); return err; } - return 0; -} -static int ov9640_sensor_powerdown(void) -{ - unsigned char expa; - int err; + expa = power ? expa | 0x80 : expa & ~0x08; - /* read current state of GPIO EXPA outputs */ - if ((err = read_gpio_expa(&expa, 0x20))) { - printk(KERN_ERR "Error reading GPIO EXPA\n"); - return err; - } - /* Clear GPIO EXPA P3 (CAMERA_MODULE_EN) to power-down sensor */ - if ((err = write_gpio_expa(expa & ~0x08, 0x20))) { - printk(KERN_ERR "Error writing to GPIO EXPA\n"); + /* Set GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up sensor */ + if ((err = write_gpio_expa(expa, 0x20))) { + printk(KERN_ERR "Error writing to GPIO EXPA 0x20\n"); return err; } - return 0; -} - -static int ov9640_sensor_power_set(int power) -{ - int err = 0; - - if (power) - err = ov9640_sensor_powerup(); - else - err = ov9640_sensor_powerdown(); + if (power) { + /* read current state of GPIO EXPA outputs */ + if ((err = read_gpio_expa(&expa, 0x22))) { + printk(KERN_ERR "Error reading GPIO EXPA\n"); + return err; + } + /* Clear GPIO EXPA P7 (CAM_RST) */ + if ((err = write_gpio_expa(expa & ~0x80, 0x22))) { + printk(KERN_ERR "Error writing to GPIO EXPA\n"); + return err; + } + } return err; } @@ -643,16 +618,13 @@ static int ov9640_ifparm(struct v4l2_ifparm *p) return 0; } -#else -static int ov9640_sensor_power_set(int power) { return 0; } -static int ov9640_ifparm(struct v4l2_ifparm *p) { return 0; } -#endif static struct ov9640_platform_data h4_ov9640_platform_data = { .power_set = ov9640_sensor_power_set, .default_regs = ov9640_common, .ifparm = ov9640_ifparm, }; +#endif static struct i2c_board_info __initdata h4_i2c_board_info[] = { { @@ -664,10 +636,12 @@ static struct i2c_board_info __initdata h4_i2c_board_info[] = { I2C_BOARD_INFO("menelaus", 0x72), .irq = INT_24XX_SYS_NIRQ, }, +#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE) { I2C_BOARD_INFO("ov9640", 0x30), .platform_data = &h4_ov9640_platform_data, }, +#endif }; static void __init omap_h4_init(void) -- 1.5.3.4.206.g58ba4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ARM: OMAP2: Camera: Improve ov9640 code on board-h4.c 2007-11-21 16:43 ` [PATCH 2/2] ARM: OMAP2: Camera: Improve ov9640 code on board-h4.c Eduardo Valentin @ 2007-11-22 9:10 ` Trilok Soni 0 siblings, 0 replies; 7+ messages in thread From: Trilok Soni @ 2007-11-22 9:10 UTC (permalink / raw) To: Eduardo Valentin Cc: Eduardo Valentin, Sakari Ailus, linux-omap, linux-omap-open-source Hi Eduardo, On Nov 21, 2007 10:13 PM, Eduardo Valentin <edubezval@gmail.com> wrote: > From: Eduardo Valentin <eduardo.valentin@indt.org.br> > > - Removes unnecessary structures and functions when config OV9640 > is not selected. > - Reduces powerset code for ov9640. > > Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br> > --- Thanx for the changes. Looks good to me. We have to make changes related to gpio expander apis if gpiolib goes upstrem by David Brownell. Acked-by: Trilok Soni <soni.trilok@gmail.com> -- --Trilok Soni ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's 2007-11-21 16:43 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Eduardo Valentin 2007-11-21 16:43 ` [PATCH 2/2] ARM: OMAP2: Camera: Improve ov9640 code on board-h4.c Eduardo Valentin @ 2007-11-23 11:09 ` Sakari Ailus 2007-11-23 11:16 ` [PATCH] OMAP2: Camera: Adapt to use new videobuf and scatterlist code Sakari Ailus 1 sibling, 1 reply; 7+ messages in thread From: Sakari Ailus @ 2007-11-23 11:09 UTC (permalink / raw) To: Eduardo Valentin; +Cc: Eduardo Valentin, linux-omap, linux-omap-open-source Eduardo Valentin wrote: > From: Eduardo Valentin <eduardo.valentin@indt.org.br> > > V4l2: > - Updates this camera driver to use correctly the new videobuf API. > Currently, changed to use videobuf_gen and videobuf_dma_sg. > - Removed VIDEO_BUF reference from Kconfig. > > S/G: > - Update this code to sg_* helper functions. > > Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br> Thanks for the patch, Eduardo! I was actually preparing a fix but perhaps a bit late. I was waiting for the MUSB patch to make testing it a bit easier. ;) There's one a bit subtle change in new videobuf code (?): videobuf_mmap_setup now returns the number of buffers instead of zero when it succeeds. (I ran into this...) Cheers, -- Sakari Ailus sakari.ailus@nokia.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] OMAP2: Camera: Adapt to use new videobuf and scatterlist code 2007-11-23 11:09 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Sakari Ailus @ 2007-11-23 11:16 ` Sakari Ailus 2007-11-23 21:39 ` Tony Lindgren 0 siblings, 1 reply; 7+ messages in thread From: Sakari Ailus @ 2007-11-23 11:16 UTC (permalink / raw) To: linux-omap; +Cc: eduardo.valentin, linux-omap-open-source Also take into account that videobuf_reqbufs now returns number of buffers when it succeeds. (Thanks for Eduardo Valentin for initial patch.) Signed-off-by: Sakari Ailus <sakari.ailus@nokia.com> --- drivers/media/video/Kconfig | 3 +- drivers/media/video/omap24xxcam.c | 75 ++++++++++++++++++------------------- drivers/media/video/omap24xxcam.h | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 0cb82fd..29eb904 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -712,7 +712,8 @@ config VIDEO_CAFE_CCIC config VIDEO_OMAP2 tristate "OMAP 2 Camera support (EXPERIMENTAL)" - select VIDEO_BUF + select VIDEOBUF_GEN + select VIDEOBUF_DMA_SG depends on VIDEO_V4L2 && ARCH_OMAP24XX ---help--- Driver for an OMAP 2 camera controller. diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c index 8fda9e1..d394eab 100644 --- a/drivers/media/video/omap24xxcam.c +++ b/drivers/media/video/omap24xxcam.c @@ -226,27 +226,28 @@ static void omap24xxcam_core_isr(struct omap24xxcam_device *cam) */ static void omap24xxcam_vbq_free_mmap_buffer(struct videobuf_buffer *vb) { - int i; + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); size_t alloc_size; struct page *page; + int i; - if (vb->dma.sglist == NULL) + if (dma->sglist == NULL) return; - i = vb->dma.sglen; + i = dma->sglen; while (i) { i--; - alloc_size = vb->dma.sglist[i].length; - page = vb->dma.sglist[i].page; + alloc_size = sg_dma_len(&dma->sglist[i]); + page = sg_page(&dma->sglist[i]); do { ClearPageReserved(page++); } while (alloc_size -= PAGE_SIZE); - __free_pages(vb->dma.sglist[i].page, - get_order(vb->dma.sglist[i].length)); + __free_pages(sg_page(&dma->sglist[i]), + get_order(sg_dma_len(&dma->sglist[i]))); } - kfree(vb->dma.sglist); - vb->dma.sglist = NULL; + kfree(dma->sglist); + dma->sglist = NULL; } /* Release all memory related to the videobuf_queue. */ @@ -282,15 +283,15 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) size_t alloc_size, size = vb->bsize; /* vb->bsize is page aligned */ struct page *page; int max_pages, err = 0, i = 0; + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); /* * allocate maximum size scatter-gather list. Note this is * overhead. We may not use as many entries as we allocate */ max_pages = vb->bsize >> PAGE_SHIFT; - vb->dma.sglist = - kcalloc(max_pages, sizeof(*vb->dma.sglist), GFP_KERNEL); - if (vb->dma.sglist == NULL) { + dma->sglist = kcalloc(max_pages, sizeof(*dma->sglist), GFP_KERNEL); + if (dma->sglist == NULL) { err = -ENOMEM; goto out; } @@ -318,9 +319,8 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) size -= (PAGE_SIZE << order); /* append allocated chunk of pages into scatter-gather list */ - vb->dma.sglist[i].page = page; - vb->dma.sglist[i].length = (PAGE_SIZE << order); - vb->dma.sglen++; + sg_set_page(&dma->sglist[i], page, PAGE_SIZE << order, 0); + dma->sglen++; i++; alloc_size = (PAGE_SIZE << order); @@ -337,8 +337,8 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) * REVISIT: not fully correct to assign nr_pages == sglen but * video-buf is passing nr_pages for e.g. unmap_sg calls */ - vb->dma.nr_pages = vb->dma.sglen; - vb->dma.direction = PCI_DMA_FROMDEVICE; + dma->nr_pages = dma->sglen; + dma->direction = PCI_DMA_FROMDEVICE; return 0; @@ -361,7 +361,7 @@ static int omap24xxcam_vbq_alloc_mmap_buffers(struct videobuf_queue *vbq, if (err) goto out; dev_dbg(fh->cam->dev, "sglen is %d for buffer %d\n", - vbq->bufs[i]->dma.sglen, i); + videobuf_to_dma(vbq->bufs[i])->sglen, i); } mutex_unlock(&vbq->lock); @@ -415,7 +415,7 @@ static void omap24xxcam_vbq_complete(struct omap24xxcam_sgdma *sgdma, static void omap24xxcam_vbq_release(struct videobuf_queue *vbq, struct videobuf_buffer *vb) { - struct videobuf_dmabuf *dma = &vb->dma; + struct videobuf_dmabuf *dma = videobuf_to_dma(vb); /* wait for buffer, especially to get out of the sgdma queue */ videobuf_waiton(vb, 0, 0); @@ -424,8 +424,8 @@ static void omap24xxcam_vbq_release(struct videobuf_queue *vbq, dma->direction); dma->direction = DMA_NONE; } else { - videobuf_dma_unmap(vbq, &vb->dma); - videobuf_dma_free(&vb->dma); + videobuf_dma_unmap(vbq, videobuf_to_dma(vb)); + videobuf_dma_free(videobuf_to_dma(vb)); } vb->state = STATE_NEEDS_INIT; @@ -525,7 +525,7 @@ static int omap24xxcam_vbq_prepare(struct videobuf_queue *vbq, * we have built the scatter-gather list by ourself so * do the scatter-gather mapping as well */ - err = omap24xxcam_dma_iolock(vbq, &vb->dma); + err = omap24xxcam_dma_iolock(vbq, videobuf_to_dma(vb)); else err = videobuf_iolock(vbq, vb, NULL); } @@ -554,8 +554,9 @@ static void omap24xxcam_vbq_queue(struct videobuf_queue *vbq, */ vb->state = STATE_ACTIVE; - err = omap24xxcam_sgdma_queue(&fh->cam->sgdma, vb->dma.sglist, - vb->dma.sglen, vb->size, + err = omap24xxcam_sgdma_queue(&fh->cam->sgdma, + videobuf_to_dma(vb)->sglist, + videobuf_to_dma(vb)->sglen, vb->size, omap24xxcam_vbq_complete, vb); if (!err) { @@ -1087,10 +1088,10 @@ static int vidioc_reqbufs(struct file *file, void *fh, * Either videobuf_reqbufs failed or the buffers are not * memory-mapped (which would need special attention). */ - if (rval || b->memory != V4L2_MEMORY_MMAP) + if (rval < 0 || b->memory != V4L2_MEMORY_MMAP) goto out; - rval = omap24xxcam_vbq_alloc_mmap_buffers(&ofh->vbq, b->count); + rval = omap24xxcam_vbq_alloc_mmap_buffers(&ofh->vbq, rval); if (rval) omap24xxcam_vbq_free_mmap_buffers(&ofh->vbq); @@ -1366,7 +1367,6 @@ static int omap24xxcam_mmap_buffers(struct file *file, struct omap24xxcam_fh *fh = file->private_data; struct omap24xxcam_device *cam = fh->cam; struct videobuf_queue *vbq = &fh->vbq; - struct videobuf_buffer *vb; unsigned int first, last, size, i, j; int err = 0; @@ -1401,15 +1401,16 @@ static int omap24xxcam_mmap_buffers(struct file *file, size = 0; for (i = first; i <= last; i++) { - vb = vbq->bufs[i]; - for (j = 0; j < vb->dma.sglen; j++) { + struct videobuf_dmabuf *dma = videobuf_to_dma(vbq->bufs[i]); + + for (j = 0; j < dma->sglen; j++) { err = remap_pfn_range( vma, vma->vm_start + size, - page_to_pfn(vb->dma.sglist[j].page), - vb->dma.sglist[j].length, vma->vm_page_prot); + page_to_pfn(sg_page(&dma->sglist[j])), + sg_dma_len(&dma->sglist[j]), vma->vm_page_prot); if (err) goto out; - size += vb->dma.sglist[j].length; + size += sg_dma_len(&dma->sglist[j]); } } @@ -1483,10 +1484,10 @@ static int omap24xxcam_open(struct inode *inode, struct file *file) spin_lock_init(&fh->vbq_lock); - videobuf_queue_init(&fh->vbq, &omap24xxcam_vbq_ops, NULL, - &fh->vbq_lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, - V4L2_FIELD_NONE, - sizeof(struct videobuf_buffer), fh); + videobuf_queue_pci_init(&fh->vbq, &omap24xxcam_vbq_ops, NULL, + &fh->vbq_lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, + V4L2_FIELD_NONE, + sizeof(struct videobuf_buffer), fh); return 0; @@ -1634,8 +1635,6 @@ static int omap24xxcam_device_register(struct v4l2_int_device *s) strlcpy(vfd->name, CAM_NAME, sizeof(vfd->name)); vfd->type = VID_TYPE_CAPTURE | VID_TYPE_CHROMAKEY; - /* need to register for a VID_HARDWARE_* ID in videodev.h */ - vfd->hardware = 0; vfd->fops = &omap24xxcam_fops; vfd->priv = cam; vfd->minor = -1; diff --git a/drivers/media/video/omap24xxcam.h b/drivers/media/video/omap24xxcam.h index 7799733..00d0e31 100644 --- a/drivers/media/video/omap24xxcam.h +++ b/drivers/media/video/omap24xxcam.h @@ -27,7 +27,7 @@ #ifndef OMAP24XXCAM_H #define OMAP24XXCAM_H -#include <media/video-buf.h> +#include <media/videobuf-dma-sg.h> #include <media/v4l2-int-device.h> /* -- 1.5.0.6 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] OMAP2: Camera: Adapt to use new videobuf and scatterlist code 2007-11-23 11:16 ` [PATCH] OMAP2: Camera: Adapt to use new videobuf and scatterlist code Sakari Ailus @ 2007-11-23 21:39 ` Tony Lindgren 0 siblings, 0 replies; 7+ messages in thread From: Tony Lindgren @ 2007-11-23 21:39 UTC (permalink / raw) To: Sakari Ailus; +Cc: eduardo.valentin, linux-omap, linux-omap-open-source * Sakari Ailus <sakari.ailus@nokia.com> [071123 03:17]: > Also take into account that videobuf_reqbufs now returns number of > buffers when it succeeds. > > (Thanks for Eduardo Valentin for initial patch.) Pushing this and Eduardo's second patch today. Tony ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-11-23 21:39 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-11-21 16:43 [PATH 0/2] ARM: OMAP2: Camera: Fixes compile errors and adds little improvements Eduardo Valentin 2007-11-21 16:43 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Eduardo Valentin 2007-11-21 16:43 ` [PATCH 2/2] ARM: OMAP2: Camera: Improve ov9640 code on board-h4.c Eduardo Valentin 2007-11-22 9:10 ` Trilok Soni 2007-11-23 11:09 ` [PATCH 1/2] ARM: OMAP2: Camera: Update camera driver for correct use of API's Sakari Ailus 2007-11-23 11:16 ` [PATCH] OMAP2: Camera: Adapt to use new videobuf and scatterlist code Sakari Ailus 2007-11-23 21:39 ` Tony Lindgren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox