@@ -21,3 +21,23 @@ config VIDEO_MMP_CAMERA
processors (and likely beyond). This is the controller found
in OLPC XO 1.75 systems.
+menu
+ prompt "Memory access type for Marvell Cafe/Armada"
+ depends on VIDEO_MMP_CAMERA || VIDEO_CAFE_CCIC
+ help
+ Select the type of memory access to be used by Marvell 88ALP01
+ (Cafe) and Marvell Armada 610 drivers.
+
+config MARVELL_DMA_SG
+ bool "Allow DMA S/G"
+ select VIDEOBUF2_DMA_SG
+
+config MARVELL_DMA_CONTIG
+ bool "Allow DMA Contiguous"
+ select VIDEOBUF2_DMA_CONTIG
+
+config MARVELL_DMA_VMALLOC
+ bool "Allow virtual memory"
+ select VIDEOBUF2_VMALLOC
+
+endmenu
@@ -37,7 +37,7 @@ static int frames;
static int singles;
static int delivered;
-#ifdef MCAM_MODE_VMALLOC
+#ifdef CONFIG_MARVELL_VMALLOC
/*
* Internal DMA buffer management. Since the controller cannot do S/G I/O,
* we must have physically contiguous buffers to bring frames into.
@@ -72,10 +72,10 @@ MODULE_PARM_DESC(dma_buf_size,
"The size of the allocated DMA buffers. If actual operating "
"parameters require larger buffers, an attempt to reallocate "
"will be made.");
-#else /* MCAM_MODE_VMALLOC */
+#else /* CONFIG_MARVELL_VMALLOC */
static const bool alloc_bufs_at_read = 0;
static const int n_dma_bufs = 3; /* Used by S/G_PARM */
-#endif /* MCAM_MODE_VMALLOC */
+#endif /* CONFIG_MARVELL_VMALLOC */
static bool flip;
module_param(flip, bool, 0444);
@@ -262,7 +262,7 @@ static void mcam_ctlr_stop(struct mcam_camera *cam)
/* ------------------------------------------------------------------- */
-#ifdef MCAM_MODE_VMALLOC
+#ifdef CONFIG_MARVELL_VMALLOC
/*
* Code specific to the vmalloc buffer mode.
*/
@@ -405,7 +405,7 @@ static void mcam_vmalloc_done(struct mcam_camera *cam, int frame)
tasklet_schedule(&cam->s_tasklet);
}
-#else /* MCAM_MODE_VMALLOC */
+#else /* CONFIG_MARVELL_VMALLOC */
static inline int mcam_alloc_dma_bufs(struct mcam_camera *cam, int loadtime)
{
@@ -424,10 +424,10 @@ static inline int mcam_check_dma_buffers(struct mcam_camera *cam)
-#endif /* MCAM_MODE_VMALLOC */
+#endif /* CONFIG_MARVELL_VMALLOC */
-#ifdef MCAM_MODE_DMA_CONTIG
+#ifdef CONFIG_MARVELL_DMA_CONTIG
/* ---------------------------------------------------------------------- */
/*
* DMA-contiguous code.
@@ -491,9 +491,9 @@ static void mcam_dma_contig_done(struct mcam_camera *cam, int frame)
mcam_set_contig_buffer(cam, frame);
}
-#endif /* MCAM_MODE_DMA_CONTIG */
+#endif /* CONFIG_MARVELL_DMA_CONTIG */
-#ifdef MCAM_MODE_DMA_SG
+#ifdef CONFIG_MARVELL_DMA_SG
/* ---------------------------------------------------------------------- */
/*
* Scatter/gather-specific code.
@@ -602,14 +602,14 @@ static void mcam_sg_restart(struct mcam_camera *cam)
clear_bit(CF_SG_RESTART, &cam->flags);
}
-#else /* MCAM_MODE_DMA_SG */
+#else /* CONFIG_MARVELL_DMA_SG */
static inline void mcam_sg_restart(struct mcam_camera *cam)
{
return;
}
-#endif /* MCAM_MODE_DMA_SG */
+#endif /* CONFIG_MARVELL_DMA_SG */
/* ---------------------------------------------------------------------- */
/*
@@ -1021,7 +1021,7 @@ static const struct vb2_ops mcam_vb2_ops = {
};
-#ifdef MCAM_MODE_DMA_SG
+#ifdef CONFIG_MARVELL_DMA_SG
/*
* Scatter/gather mode uses all of the above functions plus a
* few extras to deal with DMA mapping.
@@ -1096,7 +1096,7 @@ static const struct vb2_ops mcam_vb2_sg_ops = {
.wait_finish = mcam_vb_wait_finish,
};
-#endif /* MCAM_MODE_DMA_SG */
+#endif /* CONFIG_MARVELL_DMA_SG */
static int mcam_setup_vb2(struct mcam_camera *cam)
{
@@ -1108,7 +1108,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
INIT_LIST_HEAD(&cam->buffers);
switch (cam->buffer_mode) {
case B_DMA_contig:
-#ifdef MCAM_MODE_DMA_CONTIG
+#ifdef CONFIG_MARVELL_DMA_CONTIG
vq->ops = &mcam_vb2_ops;
vq->mem_ops = &vb2_dma_contig_memops;
cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev);
@@ -1118,7 +1118,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
#endif
break;
case B_DMA_sg:
-#ifdef MCAM_MODE_DMA_SG
+#ifdef CONFIG_MARVELL_DMA_SG
vq->ops = &mcam_vb2_sg_ops;
vq->mem_ops = &vb2_dma_sg_memops;
vq->io_modes = VB2_MMAP | VB2_USERPTR;
@@ -1127,7 +1127,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
#endif
break;
case B_vmalloc:
-#ifdef MCAM_MODE_VMALLOC
+#ifdef CONFIG_MARVELL_VMALLOC
tasklet_init(&cam->s_tasklet, mcam_frame_tasklet,
(unsigned long) cam);
vq->ops = &mcam_vb2_ops;
@@ -1145,7 +1145,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
static void mcam_cleanup_vb2(struct mcam_camera *cam)
{
vb2_queue_release(&cam->vb_queue);
-#ifdef MCAM_MODE_DMA_CONTIG
+#ifdef CONFIG_MARVELL_DMA_CONTIG
if (cam->buffer_mode == B_DMA_contig)
vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx);
#endif
@@ -11,28 +11,6 @@
#include <media/v4l2-dev.h>
#include <media/videobuf2-core.h>
-/*
- * Create our own symbols for the supported buffer modes, but, for now,
- * base them entirely on which videobuf2 options have been selected.
- */
-#if defined(CONFIG_VIDEOBUF2_VMALLOC) || defined(CONFIG_VIDEOBUF2_VMALLOC_MODULE)
-#define MCAM_MODE_VMALLOC 1
-#endif
-
-#if defined(CONFIG_VIDEOBUF2_DMA_CONTIG) || defined(CONFIG_VIDEOBUF2_DMA_CONTIG_MODULE)
-#define MCAM_MODE_DMA_CONTIG 1
-#endif
-
-#if defined(CONFIG_VIDEOBUF2_DMA_SG) || defined(CONFIG_VIDEOBUF2_DMA_SG_MODULE)
-#define MCAM_MODE_DMA_SG 1
-#endif
-
-#if !defined(MCAM_MODE_VMALLOC) && !defined(MCAM_MODE_DMA_CONTIG) && \
- !defined(MCAM_MODE_DMA_SG)
-#error One of the videobuf buffer modes must be selected in the config
-#endif
-
-
enum mcam_state {
S_NOTREADY, /* Not yet initialized */
S_IDLE, /* Just hanging around */
@@ -58,13 +36,13 @@ enum mcam_buffer_mode {
static inline int mcam_buffer_mode_supported(enum mcam_buffer_mode mode)
{
switch (mode) {
-#ifdef MCAM_MODE_VMALLOC
+#ifdef CONFIG_MARVELL_VMALLOC
case B_vmalloc:
#endif
-#ifdef MCAM_MODE_DMA_CONTIG
+#ifdef CONFIG_MARVELL_DMA_CONTIG
case B_DMA_contig:
#endif
-#ifdef MCAM_MODE_DMA_SG
+#ifdef CONFIG_MARVELL_DMA_SG
case B_DMA_sg:
#endif
return 1;
@@ -123,7 +101,7 @@ struct mcam_camera {
int next_buf; /* Next to consume (dev_lock) */
/* DMA buffers - vmalloc mode */
-#ifdef MCAM_MODE_VMALLOC
+#ifdef CONFIG_MARVELL_VMALLOC
unsigned int dma_buf_size; /* allocated size */
void *dma_bufs[MAX_DMA_BUFS]; /* Internal buffer addresses */
dma_addr_t dma_handles[MAX_DMA_BUFS]; /* Buffer bus addresses */