RE: [PATCH 5/5] marvell-cam: implement contiguous DMA operation

2011-06-22 Thread Marek Szyprowski
Hello,

On Tuesday, June 21, 2011 10:26 PM Mauro Carvalho Chehab wrote:

 Em 20-06-2011 16:14, Jonathan Corbet escreveu:
  The core driver can now operate in either vmalloc or dma-contig modes;
  obviously the latter is preferable when it is supported.  Default is
  currently vmalloc on all platforms; load the module with buffer_mode=1
 for contiguous DMA mode.
 
 Patch looks correct.
 
 A side note for vb2 maintainers:
 
 IMO, vb2 core should take the responsibility to allow to switch between DMA
 scatter/gather and continuous (and, eventually, vmalloc), where the bridge
 driver support more than one option.

 Otherwise, we'll end by having codes similar to that on all drivers that
 can be used on different architectures.

Could you elaborate a bit more on this issue? Depending on driver needs, on
just sets queue-mem_ops to vb2_vmalloc_memops, vb2_dma-contig_memops or 
vb2_dma-sg_memops. There is no dependencies between the core and memory
allocators/handlers.

Best regards
-- 
Marek Szyprowski
Samsung Poland RD Center


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] marvell-cam: implement contiguous DMA operation

2011-06-21 Thread Mauro Carvalho Chehab
Em 20-06-2011 16:14, Jonathan Corbet escreveu:
 The core driver can now operate in either vmalloc or dma-contig modes;
 obviously the latter is preferable when it is supported.  Default is
 currently vmalloc on all platforms; load the module with buffer_mode=1 for
 contiguous DMA mode.

Patch looks correct.

A side note for vb2 maintainers:

IMO, vb2 core should take the responsibility to allow to switch between DMA
scatter/gather and continuous (and, eventually, vmalloc), where the bridge 
driver
support more than one option.

Otherwise, we'll end by having codes similar to that on all drivers that can be 
used
on different architectures.

 Signed-off-by: Jonathan Corbet cor...@lwn.net
 ---
  drivers/media/video/marvell-ccic/Kconfig   |1 +
  drivers/media/video/marvell-ccic/cafe-driver.c |6 +
  drivers/media/video/marvell-ccic/mcam-core.c   |  230 
 ++--
  drivers/media/video/marvell-ccic/mcam-core.h   |   21 ++-
  drivers/media/video/marvell-ccic/mmp-driver.c  |1 +
  5 files changed, 205 insertions(+), 54 deletions(-)

 diff --git a/drivers/media/video/marvell-ccic/Kconfig 
 b/drivers/media/video/marvell-ccic/Kconfig
 index eb535b1..22314a0 100644
 --- a/drivers/media/video/marvell-ccic/Kconfig
 +++ b/drivers/media/video/marvell-ccic/Kconfig
 @@ -14,6 +14,7 @@ config VIDEO_MMP_CAMERA
   select VIDEO_OV7670
   select I2C_GPIO
   select VIDEOBUF2_VMALLOC
 + select VIDEOBUF2_DMA_CONTIG
   ---help---
 This is a Video4Linux2 driver for the integrated camera
 controller found on Marvell Armada 610 application
 diff --git a/drivers/media/video/marvell-ccic/cafe-driver.c 
 b/drivers/media/video/marvell-ccic/cafe-driver.c
 index 6a29cc1..d030f9b 100644
 --- a/drivers/media/video/marvell-ccic/cafe-driver.c
 +++ b/drivers/media/video/marvell-ccic/cafe-driver.c
 @@ -482,6 +482,12 @@ static int cafe_pci_probe(struct pci_dev *pdev,
   mcam-clock_speed = 45;
   mcam-use_smbus = 1;
   /*
 +  * Vmalloc mode for buffers is traditional with this driver.
 +  * We *might* be able to run DMA_contig, especially on a system
 +  * with CMA in it.
 +  */
 + mcam-buffer_mode = B_vmalloc;
 + /*
* Get set up on the PCI bus.
*/
   ret = pci_enable_device(pdev);
 diff --git a/drivers/media/video/marvell-ccic/mcam-core.c 
 b/drivers/media/video/marvell-ccic/mcam-core.c
 index ca3c56f..419b4e5 100644
 --- a/drivers/media/video/marvell-ccic/mcam-core.c
 +++ b/drivers/media/video/marvell-ccic/mcam-core.c
 @@ -25,9 +25,16 @@
  #include media/v4l2-chip-ident.h
  #include media/ov7670.h
  #include media/videobuf2-vmalloc.h
 +#include media/videobuf2-dma-contig.h
  
  #include mcam-core.h
  
 +/*
 + * Basic frame stats - to be deleted shortly
 + */
 +static int frames;
 +static int singles;
 +static int delivered;
  
  /*
   * Internal DMA buffer management.  Since the controller cannot do S/G I/O,
 @@ -48,7 +55,8 @@ MODULE_PARM_DESC(alloc_bufs_at_read,
   Non-zero value causes DMA buffers to be allocated when the 
   video capture device is read, rather than at module load 
   time.  This saves memory, but decreases the chances of 
 - successfully getting those buffers.);
 + successfully getting those buffers.  This parameter is 
 + only used in the vmalloc buffer mode);
  
  static int n_dma_bufs = 3;
  module_param(n_dma_bufs, uint, 0644);
 @@ -82,6 +90,13 @@ MODULE_PARM_DESC(flip,
   If set, the sensor will be instructed to flip the image 
   vertically.);
  
 +static int buffer_mode = -1;
 +module_param(buffer_mode, int, 0444);
 +MODULE_PARM_DESC(buffer_mode,
 + Set the buffer mode to be used; default is to go with what 
 + the platform driver asks for.  Set to 0 for vmalloc, 1 for 
 + DMA contiguous.);
 +
  /*
   * Status flags.  Always manipulated with bit operations.
   */
 @@ -90,6 +105,7 @@ MODULE_PARM_DESC(flip,
  #define CF_BUF2_VALID 2
  #define CF_DMA_ACTIVE 3  /* A frame is incoming */
  #define CF_CONFIG_NEEDED 4   /* Must configure hardware */
 +#define CF_SINGLE_BUFFER 5   /* Running with a single buffer */
  
  #define sensor_call(cam, o, f, args...) \
   v4l2_subdev_call(cam-sensor, o, f, ##args)
 @@ -197,10 +213,9 @@ static inline struct mcam_vb_buffer *vb_to_mvb(struct 
 vb2_buffer *vb)
   */
  
  /*
 - * Do everything we think we need to have the interface operating
 - * according to the desired format.
 + * Set up DMA buffers when operating in vmalloc mode
   */
 -static void mcam_ctlr_dma(struct mcam_camera *cam)
 +static void mcam_ctlr_dma_vmalloc(struct mcam_camera *cam)
  {
   /*
* Store the first two Y buffers (we aren't supporting
 @@ -219,6 +234,57 @@ static void mcam_ctlr_dma(struct mcam_camera *cam)
   mcam_reg_write(cam, REG_UBAR, 0); /* 32 bits only */
  }
  
 +/*
 + * Set up a contiguous buffer for the