Skip to contentSkip to conversation

marvell-ccic: add soc_camera support in mcam core

PATCH Superseded Albert Wang 1 participant 1 message Nov 23, 2012 Media (V4L/DVB)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 11/15 marvell-ccic: add soc_camera support in mcam core

This patch adds the soc_camera support in mcam core.

It creates the file mcam-core-soc.c and mcam-core-soc.h to support soc_camera in mcam core.

To use the soc_camera feature, platform driver, such as mmp-driver.c, should also be modified.

---
 drivers/media/platform/marvell-ccic/Makefile       |    2 +
 .../media/platform/marvell-ccic/mcam-core-soc.c    |  414 ++++++++++++++++++++
 .../media/platform/marvell-ccic/mcam-core-soc.h    |   19 +
 drivers/media/platform/marvell-ccic/mcam-core.c    |   13 +-
 drivers/media/platform/marvell-ccic/mcam-core.h    |   37 ++
 include/media/mmp-camera.h                         |    3 +
 6 files changed, 485 insertions(+), 3 deletions(-)
 create mode 100644 drivers/media/platform/marvell-ccic/mcam-core-soc.c
 create mode 100644 drivers/media/platform/marvell-ccic/mcam-core-soc.h
drivers/media/platform/marvell-ccic/Makefile +2 -0
index 595ebdf..b3e87d4 100755
@@ -4,3 +4,5 @@ cafe_ccic-y := cafe-driver.o mcam-core.o
 obj-$(CONFIG_VIDEO_MMP_CAMERA) += mmp_camera_standard.o
 mmp_camera_standard-y := mmp-driver.o mcam-core.o mcam-core-standard.o
 
+obj-$(CONFIG_VIDEO_MMP_SOC_CAMERA) += mmp_camera_soc.o
+mmp_camera_soc-y := mmp-driver.o mcam-core.o mcam-core-soc.o
drivers/media/platform/marvell-ccic/mcam-core-soc.c new file +414 -0

414 lines not on this page · raw message

drivers/media/platform/marvell-ccic/mcam-core-soc.h new file +19 -0
new file mode 100644
index 0000000..a5b5fa6
@@ -0,0 +1,19 @@
+/*
+ * Marvell camera core structures.
+ *
+ * Copyright (C) 2009-2012 Marvell International Ltd.
+ *
+ * Author: Libin Yang <[email protected]>
+ *         Albert Wang <[email protected]>
+ *
+ */
+extern const struct vb2_ops mcam_soc_vb2_ops;
+
+extern void mcam_ctlr_power_up(struct mcam_camera *cam);
+extern void mcam_ctlr_power_down(struct mcam_camera *cam);
+extern void mcam_dma_contig_done(struct mcam_camera *cam, int frame);
+extern void mcam_ctlr_stop(struct mcam_camera *cam);
+extern int mcam_config_mipi(struct mcam_camera *mcam, int enable);
+extern void mcam_ctlr_image(struct mcam_camera *cam);
+extern void mcam_set_config_needed(struct mcam_camera *cam, int needed);
+extern void mcam_ctlr_dma_contig(struct mcam_camera *cam);
drivers/media/platform/marvell-ccic/mcam-core.c +10 -3
index 189463c..3b05d8c 100755
@@ -3,6 +3,12 @@
  * so it needs platform-specific support outside of the core.
  *
  * Copyright 2011 Jonathan Corbet [email protected]
+ *
+ * History:
+ * Support Soc Camera
+ * Support MIPI interface and Dual CCICs in Soc Camera mode
+ * Sep-2012: Libin Yang <[email protected]>
+ *           Albert Wang <[email protected]>
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -704,8 +710,7 @@ static void mcam_ctlr_irq_disable(struct mcam_camera *cam)
 	mcam_reg_clear_bit(cam, REG_IRQMASK, FRAMEIRQS);
 }
 
-
-
+#ifndef CONFIG_VIDEO_MRVL_SOC_CAMERA
 void mcam_ctlr_init(struct mcam_camera *cam)
 {
 	unsigned long flags;
@@ -727,7 +732,7 @@ void mcam_ctlr_init(struct mcam_camera *cam)
 	mcam_reg_write_mask(cam, REG_CLKCTRL, 2, CLK_DIV_MASK);
 	spin_unlock_irqrestore(&cam->dev_lock, flags);
 }
-
+#endif
 
 /*
  * Stop the controller, and don't return until we're really sure that no
@@ -802,6 +807,7 @@ int __mcam_cam_reset(struct mcam_camera *cam)
 	return sensor_call(cam, core, reset, 0);
 }
 
+#ifndef CONFIG_VIDEO_MRVL_SOC_CAMERA
 /*
  * We have found the sensor on the i2c.  Let's try to have a
  * conversation.
@@ -838,6 +844,7 @@ out:
 	mutex_unlock(&cam->s_mutex);
 	return ret;
 }
+#endif
 
 /*
  * Configure the sensor to match the parameters we have.  Caller should
drivers/media/platform/marvell-ccic/mcam-core.h +37 -0
index bba8aa0..e149aa3 100755
@@ -2,6 +2,12 @@
  * Marvell camera core structures.
  *
  * Copyright 2011 Jonathan Corbet [email protected]
+ *
+ * History:
+ * Support Soc Camera
+ * Support MIPI interface and Dual CCICs in Soc Camera mode
+ * Sep-2012: Libin Yang <[email protected]>
+ *           Albert Wang <[email protected]>
  */
 #ifndef _MCAM_CORE_H
 #define _MCAM_CORE_H
@@ -10,6 +16,8 @@
 #include <media/v4l2-common.h>
 #include <media/v4l2-dev.h>
 #include <media/videobuf2-core.h>
+#include <media/soc_camera.h>
+#include <media/soc_mediabus.h>
 
 /*
  * Create our own symbols for the supported buffer modes, but, for now,
@@ -32,8 +40,13 @@
 #error One of the videobuf buffer modes must be selected in the config
 #endif
 
+#ifdef CONFIG_VIDEO_MRVL_SOC_CAMERA
+#define sensor_call(cam, o, f, args...) \
+	v4l2_subdev_call(soc_camera_to_subdev(cam->icd), o, f, ##args)
+#else
 #define sensor_call(cam, o, f, args...) \
 	v4l2_subdev_call(cam->sensor, o, f, ##args)
+#endif
 
 /*
  * Debugging and related.
@@ -102,6 +115,10 @@ struct mmp_frame_state {
  */
 #define NR_MCAM_CLK 4
 struct mcam_camera {
+#ifdef CONFIG_VIDEO_MRVL_SOC_CAMERA
+	struct soc_camera_host soc_host;
+	struct soc_camera_device *icd;
+#endif
 	/*
 	 * These fields should be set by the platform code prior to
 	 * calling mcam_register().
@@ -115,6 +132,11 @@ struct mcam_camera {
 	short int use_smbus;	/* SMBUS or straight I2c? */
 	enum mcam_buffer_mode buffer_mode;
 
+	int mclk_min;
+	int mclk_src;
+	int mclk_div;
+	char *card_name;
+
 	int ccic_id;
 	/* MIPI support */
 	int bus_type;
@@ -260,10 +282,20 @@ static inline void mcam_reg_set_bit(struct mcam_camera *cam,
 	mcam_reg_write_mask(cam, reg, val, val);
 }
 
+#ifdef CONFIG_VIDEO_MRVL_SOC_CAMERA
+static inline struct mcam_camera *get_mcam(struct vb2_queue *vq)
+{
+	struct soc_camera_device *icd = container_of(vq,
+					struct soc_camera_device, vb2_vidq);
+	struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+	return ici->priv;
+}
+#else
 static inline struct mcam_camera *get_mcam(struct vb2_queue *vq)
 {
 	return vb2_get_drv_priv(vq);
 }
+#endif
 
 /*
  * Functions for use by platform code.
@@ -275,6 +307,9 @@ void mccic_shutdown(struct mcam_camera *cam);
 void mccic_suspend(struct mcam_camera *cam);
 int mccic_resume(struct mcam_camera *cam);
 #endif
+#ifdef CONFIG_VIDEO_MRVL_SOC_CAMERA
+int mcam_soc_camera_host_register(struct mcam_camera *mcam);
+#endif
 
 /*
  * Register definitions for the m88alp01 camera interface.  Offsets in bytes
@@ -378,6 +413,7 @@ int mccic_resume(struct mcam_camera *cam);
 
 /* Bits below C1_444ALPHA are not present in Cafe */
 #define REG_CTRL1	0x40	/* Control 1 */
+#define   C1_RESERVED	  0x0000003c	/* Reserved and shouldn't be changed */
 #define	  C1_CLKGATE	  0x00000001	/* Sensor clock gate */
 #define   C1_DESC_ENA	  0x00000100	/* DMA descriptor enable */
 #define   C1_DESC_3WORD   0x00000200	/* Three-word descriptors used */
@@ -389,6 +425,7 @@ int mccic_resume(struct mcam_camera *cam);
 #define	  C1_DMAB_MASK	  0x06000000
 #define	  C1_TWOBUFS	  0x08000000	/* Use only two DMA buffers */
 #define	  C1_PWRDWN	  0x10000000	/* Power down */
+#define   C1_DMAPOSTED	  0x40000000	/* DMA Posted Select */
 
 #define REG_CTRL3	0x1ec	/* CCIC parallel mode */
 #define REG_CLKCTRL	0x88	/* Clock control */
include/media/mmp-camera.h +3 -0
index e161ae0..36891ed 100755
@@ -6,6 +6,9 @@ struct mmp_camera_platform_data {
 	struct platform_device *i2c_device;
 	int sensor_power_gpio;
 	int sensor_reset_gpio;
+	int mclk_min;
+	int mclk_src;
+	int mclk_div;
 	/*
 	 * MIPI support
 	 */
Signature · 1 line
1.7.9.5