Commit a9b36e85 authored by Jonathan Corbet's avatar Jonathan Corbet Committed by Mauro Carvalho Chehab

[media] marvell-cam: implement contiguous DMA operation

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.
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 6c895d54
......@@ -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
......
......@@ -481,6 +481,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.
*/
......
......@@ -27,10 +27,20 @@ enum mcam_state {
S_NOTREADY, /* Not yet initialized */
S_IDLE, /* Just hanging around */
S_FLAKED, /* Some sort of problem */
S_STREAMING /* Streaming data */
S_STREAMING, /* Streaming data */
S_BUFWAIT /* streaming requested but no buffers yet */
};
#define MAX_DMA_BUFS 3
/*
* Different platforms work best with different buffer modes, so we
* let the platform pick.
*/
enum mcam_buffer_mode {
B_vmalloc = 0,
B_DMA_contig
};
/*
* A description of one of our devices.
* Locking: controlled by s_mutex. Certain fields, however, require
......@@ -49,7 +59,7 @@ struct mcam_camera {
unsigned int chip_id;
short int clock_speed; /* Sensor clock speed, default 30 */
short int use_smbus; /* SMBUS or straight I2c? */
enum mcam_buffer_mode buffer_mode;
/*
* Callbacks from the core to the platform code.
*/
......@@ -79,7 +89,7 @@ struct mcam_camera {
struct vb2_queue vb_queue;
struct list_head buffers; /* Available frames */
/* DMA buffers */
/* DMA buffers - vmalloc mode */
unsigned int nbufs; /* How many are alloc'd */
int next_buf; /* Next to consume (dev_lock) */
unsigned int dma_buf_size; /* allocated size */
......@@ -88,6 +98,11 @@ struct mcam_camera {
unsigned int sequence; /* Frame sequence number */
unsigned int buf_seq[MAX_DMA_BUFS]; /* Sequence for individual bufs */
/* DMA buffers - contiguous DMA mode */
struct mcam_vb_buffer *vb_bufs[MAX_DMA_BUFS];
struct vb2_alloc_ctx *vb_alloc_ctx;
unsigned short last_delivered;
struct tasklet_struct s_tasklet;
/* Current operating parameters */
......
......@@ -180,6 +180,7 @@ static int mmpcam_probe(struct platform_device *pdev)
mcam->dev = &pdev->dev;
mcam->use_smbus = 0;
mcam->chip_id = V4L2_IDENT_ARMADA610;
mcam->buffer_mode = B_vmalloc; /* Switch to dma */
spin_lock_init(&mcam->dev_lock);
/*
* Get our I/O memory.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment