aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2012-06-02 13:09:29 +0200
committercodeworkx <daniel.hillenbrand@codeworkx.de>2012-06-02 13:09:29 +0200
commitc6da2cfeb05178a11c6d062a06f8078150ee492f (patch)
treef3b4021d252c52d6463a9b3c1bb7245e399b009c /include/media
parentc6d7c4dbff353eac7919342ae6b3299a378160a6 (diff)
downloadkernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.zip
kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.gz
kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.bz2
samsung update 1
Diffstat (limited to 'include/media')
-rw-r--r--include/media/db8131m_platform.h23
-rw-r--r--include/media/exynos_camera.h59
-rw-r--r--include/media/exynos_fimc_is.h134
-rw-r--r--include/media/exynos_flite.h45
-rw-r--r--include/media/exynos_gscaler.h56
-rw-r--r--include/media/exynos_mc.h161
-rw-r--r--include/media/isx012_platform.h56
-rw-r--r--include/media/m5mo_platform.h23
-rw-r--r--include/media/m5mols.h20
-rw-r--r--include/media/m9mo_platform.h23
-rw-r--r--include/media/s5c73m3_platform.h22
-rw-r--r--include/media/s5k4ba_platform.h33
-rw-r--r--include/media/s5k4ea_platform.h35
-rw-r--r--include/media/s5k4ecgx_platform.h25
-rw-r--r--include/media/s5k5bafx_platform.h42
-rw-r--r--include/media/s5k5ccgx_platform.h54
-rw-r--r--include/media/s5p_fimc.h28
-rw-r--r--include/media/sr200pc20_platform.h36
-rw-r--r--include/media/sr200pc20m_platform.h36
-rw-r--r--include/media/v4l2-fh.h2
-rw-r--r--include/media/v4l2-mem2mem.h3
-rw-r--r--include/media/v4l2-subdev.h12
-rw-r--r--include/media/videobuf2-cma-phys.h45
-rw-r--r--include/media/videobuf2-core.h50
-rw-r--r--include/media/videobuf2-ion.h220
25 files changed, 1228 insertions, 15 deletions
diff --git a/include/media/db8131m_platform.h b/include/media/db8131m_platform.h
new file mode 100644
index 0000000..38f0833
--- /dev/null
+++ b/include/media/db8131m_platform.h
@@ -0,0 +1,23 @@
+/*
+ * Driver for DB8131M (1.3M camera) from SAMSUNG ELECTRONICS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#define VT_DEFAULT_FMT V4L2_PIX_FMT_UYVY /* YUV422 */
+#define DEFAULT_PREVIEW_WIDTH 640
+#define DEFAULT_PREVIEW_HEIGHT 480
+#define DEFAULT_CAPTURE_WIDTH 1600
+#define DEFAULT_CAPTURE_HEIGHT 1200
+
+struct db8131m_platform_data {
+ unsigned int default_width;
+ unsigned int default_height;
+ unsigned int pixelformat;
+ int freq; /* MCLK in KHz */
+ /* This SoC supports Parallel & CSI-2 */
+ int is_mipi;
+};
diff --git a/include/media/exynos_camera.h b/include/media/exynos_camera.h
new file mode 100644
index 0000000..e7fafd1
--- /dev/null
+++ b/include/media/exynos_camera.h
@@ -0,0 +1,59 @@
+/* include/media/exynos_camera.h
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * The header file related to camera
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef EXYNOS_CAMERA_H_
+#define EXYNOS_CAMERA_H_
+
+#include <media/exynos_mc.h>
+
+enum cam_bus_type {
+ CAM_TYPE_ITU = 1,
+ CAM_TYPE_MIPI,
+};
+
+enum cam_port {
+ CAM_PORT_A,
+ CAM_PORT_B,
+};
+
+#define CAM_CLK_INV_PCLK (1 << 0)
+#define CAM_CLK_INV_VSYNC (1 << 1)
+#define CAM_CLK_INV_HREF (1 << 2)
+#define CAM_CLK_INV_HSYNC (1 << 3)
+
+struct i2c_board_info;
+
+/**
+ * struct exynos_isp_info - image sensor information required for host
+ * interface configuration.
+ *
+ * @board_info: pointer to I2C subdevice's board info
+ * @clk_frequency: frequency of the clock the host interface provides to sensor
+ * @bus_type: determines bus type, MIPI, ITU-R BT.601 etc.
+ * @csi_data_align: MIPI-CSI interface data alignment in bits
+ * @i2c_bus_num: i2c control bus id the sensor is attached to
+ * @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
+ * @flags: flags defining bus signals polarity inversion (High by default)
+ * @use_cam: a means of used by GSCALER
+ */
+struct exynos_isp_info {
+ struct i2c_board_info *board_info;
+ unsigned long clk_frequency;
+ const char *cam_srclk_name;
+ const char *cam_clk_name;
+ enum cam_bus_type bus_type;
+ u16 csi_data_align;
+ u16 i2c_bus_num;
+ enum cam_port cam_port;
+ u16 flags;
+};
+#endif /* EXYNOS_CAMERA_H_ */
diff --git a/include/media/exynos_fimc_is.h b/include/media/exynos_fimc_is.h
new file mode 100644
index 0000000..4e35644
--- /dev/null
+++ b/include/media/exynos_fimc_is.h
@@ -0,0 +1,134 @@
+/* linux/arch/arm/plat-s5p/include/plat/fimc_is.h
+ *
+ * Copyright (C) 2011 Samsung Electronics, Co. Ltd
+ *
+ * Exynos 4 series FIMC-IS slave device support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef EXYNOS_FIMC_IS_H_
+#define EXYNOS_FIMC_IS_H_ __FILE__
+
+#include <linux/videodev2.h>
+
+#define FIMC_IS_MAX_CAMIF_CLIENTS 2
+#define FIMC_IS_MAX_SENSOR_NAME_LEN 16
+#define EXYNOS4_FIMC_IS_MAX_DIV_CLOCKS 2
+#define EXYNOS4_FIMC_IS_MAX_CONTROL_CLOCKS 16
+
+#define UART_ISP_SEL 0
+#define UART_ISP_RATIO 1
+
+#define to_fimc_is_plat(d) (to_platform_device(d)->dev.platform_data)
+
+#if defined(CONFIG_ARCH_EXYNOS5)
+enum exynos5_csi_id {
+ CSI_ID_A = 0,
+ CSI_ID_B
+};
+
+enum exynos5_flite_id {
+ FLITE_ID_A = 0,
+ FLITE_ID_B
+};
+
+enum exynos5_sensor_position {
+ SENSOR_POSITION_REAR = 0,
+ SENSOR_POSITION_FRONT
+};
+enum exynos5_sensor_id {
+ SENSOR_NAME_S5K3H2 = 1,
+ SENSOR_NAME_S5K6A3 = 2,
+ SENSOR_NAME_S5K4E5 = 3,
+ SENSOR_NAME_S5K3H7 = 4,
+ SENSOR_NAME_CUSTOM = 5,
+ SENSOR_NAME_END
+};
+
+enum exynos5_sensor_channel {
+ SENSOR_CONTROL_I2C0 = 0,
+ SENSOR_CONTROL_I2C1 = 1
+};
+#endif
+
+struct platform_device;
+
+#if defined(CONFIG_ARCH_EXYNOS5)
+/**
+ * struct exynos5_fimc_is_sensor_info - image sensor information required for host
+ * interace configuration.
+*/
+struct exynos5_fimc_is_sensor_info {
+ char sensor_name[FIMC_IS_MAX_SENSOR_NAME_LEN];
+ enum exynos5_sensor_position sensor_position;
+ enum exynos5_sensor_id sensor_id;
+ enum exynos5_csi_id csi_id;
+ enum exynos5_flite_id flite_id;
+ enum exynos5_sensor_channel i2c_channel;
+
+ int max_width;
+ int max_height;
+ int max_frame_rate;
+
+
+ int mipi_lanes; /* MIPI data lanes */
+ int mipi_settle; /* MIPI settle */
+ int mipi_align; /* MIPI data align: 24/32 */
+};
+#endif
+/**
+ * struct exynos4_platform_fimc_is - camera host interface platform data
+ *
+ * @isp_info: properties of camera sensor required for host interface setup
+*/
+struct exynos4_platform_fimc_is {
+ int hw_ver;
+ struct clk *div_clock[EXYNOS4_FIMC_IS_MAX_DIV_CLOCKS];
+ struct clk *control_clock[EXYNOS4_FIMC_IS_MAX_CONTROL_CLOCKS];
+ void (*cfg_gpio)(struct platform_device *pdev);
+ int (*clk_get)(struct platform_device *pdev);
+ int (*clk_put)(struct platform_device *pdev);
+ int (*clk_cfg)(struct platform_device *pdev);
+ int (*clk_on)(struct platform_device *pdev);
+ int (*clk_off)(struct platform_device *pdev);
+};
+
+#if defined(CONFIG_ARCH_EXYNOS5)
+struct exynos5_platform_fimc_is {
+ int hw_ver;
+ struct exynos5_fimc_is_sensor_info
+ *sensor_info[FIMC_IS_MAX_CAMIF_CLIENTS];
+ void (*cfg_gpio)(struct platform_device *pdev);
+ int (*clk_cfg)(struct platform_device *pdev);
+ int (*clk_on)(struct platform_device *pdev);
+ int (*clk_off)(struct platform_device *pdev);
+};
+#endif
+
+extern struct exynos4_platform_fimc_is exynos4_fimc_is_default_data;
+extern void exynos4_fimc_is_set_platdata(struct exynos4_platform_fimc_is *pd);
+#if defined(CONFIG_ARCH_EXYNOS5)
+extern void exynos5_fimc_is_set_platdata(struct exynos5_platform_fimc_is *pd);
+#endif
+/* defined by architecture to configure gpio */
+extern void exynos_fimc_is_cfg_gpio(struct platform_device *pdev);
+
+/* platform specific clock functions */
+extern int exynos_fimc_is_cfg_clk(struct platform_device *pdev);
+extern int exynos_fimc_is_clk_on(struct platform_device *pdev);
+extern int exynos_fimc_is_clk_off(struct platform_device *pdev);
+extern int exynos_fimc_is_clk_get(struct platform_device *pdev);
+extern int exynos_fimc_is_clk_put(struct platform_device *pdev);
+
+#if defined(CONFIG_ARCH_EXYNOS5)
+/* defined by architecture to configure gpio */
+extern void exynos5_fimc_is_cfg_gpio(struct platform_device *pdev);
+
+/* platform specific clock functions */
+extern int exynos5_fimc_is_cfg_clk(struct platform_device *pdev);
+extern int exynos5_fimc_is_clk_on(struct platform_device *pdev);
+extern int exynos5_fimc_is_clk_off(struct platform_device *pdev);
+#endif
+#endif /* EXYNOS_FIMC_IS_H_ */
diff --git a/include/media/exynos_flite.h b/include/media/exynos_flite.h
new file mode 100644
index 0000000..47dd93b
--- /dev/null
+++ b/include/media/exynos_flite.h
@@ -0,0 +1,45 @@
+/*
+ * Samsung S5P SoC camera interface driver header
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef EXYNOS_FLITE_H_
+#define EXYNOS_FLITE_H_
+
+#if defined(CONFIG_ARCH_EXYNOS4) && defined(CONFIG_VIDEO_FIMC)
+#define MAX_CAMIF_CLIENTS 3
+#include <plat/fimc.h>
+#else
+#include <media/exynos_camera.h>
+
+struct s3c_platform_camera {
+ enum cam_bus_type type;
+ bool use_isp;
+ int inv_pclk;
+ int inv_vsync;
+ int inv_href;
+ int inv_hsync;
+};
+#endif
+
+/**
+ * struct exynos_platform_flite - camera host interface platform data
+ *
+ * @cam: properties of camera sensor required for host interface setup
+ */
+struct exynos_platform_flite {
+ struct s3c_platform_camera *cam[MAX_CAMIF_CLIENTS];
+ struct exynos_isp_info *isp_info[MAX_CAMIF_CLIENTS];
+ u32 active_cam_index;
+ u32 num_clients;
+};
+
+extern struct exynos_platform_flite exynos_flite0_default_data;
+extern struct exynos_platform_flite exynos_flite1_default_data;
+extern struct exynos_platform_flite exynos_flite2_default_data;
+#endif /* EXYNOS_FLITE_H_*/
diff --git a/include/media/exynos_gscaler.h b/include/media/exynos_gscaler.h
new file mode 100644
index 0000000..4087e70
--- /dev/null
+++ b/include/media/exynos_gscaler.h
@@ -0,0 +1,56 @@
+/* include/media/exynos_gscaler.h
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Samsung EXYNOS SoC Gscaler driver header
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef EXYNOS_GSCALER_H_
+#define EXYNOS_GSCALER_H_
+
+#include <media/exynos_camera.h>
+
+/**
+ * struct exynos_platform_gscaler - camera host interface platform data
+ *
+ * @isp_info: properties of camera sensor required for host interface setup
+ */
+struct exynos_platform_gscaler {
+ struct exynos_isp_info *isp_info[MAX_CAMIF_CLIENTS];
+ u32 active_cam_index;
+ u32 num_clients;
+ u32 cam_preview:1;
+ u32 cam_camcording:1;
+};
+
+extern struct exynos_platform_gscaler exynos_gsc0_default_data;
+extern struct exynos_platform_gscaler exynos_gsc1_default_data;
+extern struct exynos_platform_gscaler exynos_gsc2_default_data;
+extern struct exynos_platform_gscaler exynos_gsc3_default_data;
+
+/**
+ * exynos5_gsc_set_pdev_name() = Exynos setup function for gscaler pdev name
+ * @ id: gscaler device number
+ * @ name: pdev name for gscaler
+ */
+void __init exynos5_gsc_set_pdev_name(int id, char *name);
+
+/**
+ * exynos5_gsc_set_parent_clock() = Exynos5 setup function for parent clock.
+ * @child: child clock used for gscaler
+ * @parent: parent clock used for gscaler
+ */
+int __init exynos5_gsc_set_parent_clock(const char *child, const char *parent);
+
+/**
+ * exynos5_gsc_set_clock_rate() = Exynos5 setup function for clock rate.
+ * @clk: name of clock used for gscaler
+ * @clk_rate: clock_rate for gscaler clock
+ */
+int __init exynos5_gsc_set_clock_rate(const char *clk, unsigned long clk_rate);
+#endif /* EXYNOS_GSCALER_H_ */
diff --git a/include/media/exynos_mc.h b/include/media/exynos_mc.h
new file mode 100644
index 0000000..a96b038
--- /dev/null
+++ b/include/media/exynos_mc.h
@@ -0,0 +1,161 @@
+/* linux/inclue/media/exynos_mc.h
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * header file for exynos media device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef GSC_MDEVICE_H_
+#define GSC_MDEVICE_H_
+
+#include <linux/clk.h>
+#include <linux/platform_device.h>
+#include <linux/mutex.h>
+#include <linux/device.h>
+#include <media/media-device.h>
+#include <media/media-entity.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-subdev.h>
+
+#define err(fmt, args...) \
+ printk(KERN_ERR "%s:%d: " fmt "\n", __func__, __LINE__, ##args)
+
+#define MDEV_MODULE_NAME "exynos-mdev"
+#define MAX_GSC_SUBDEV 4
+#define MDEV_MAX_NUM 3
+
+#define GSC_OUT_PAD_SINK 0
+#define GSC_OUT_PAD_SOURCE 1
+
+#define GSC_CAP_PAD_SINK 0
+#define GSC_CAP_PAD_SOURCE 1
+
+#define FLITE_PAD_SINK 0
+#define FLITE_PAD_SOURCE_PREV 1
+#define FLITE_PAD_SOURCE_CAMCORD 2
+#define FLITE_PAD_SOURCE_MEM 3
+#define FLITE_PADS_NUM 4
+
+#define CSIS_PAD_SINK 0
+#define CSIS_PAD_SOURCE 1
+#define CSIS_PADS_NUM 2
+
+#define MAX_CAMIF_CLIENTS 2
+
+#define MXR_SUBDEV_NAME "s5p-mixer"
+
+#define GSC_MODULE_NAME "exynos-gsc"
+#define GSC_SUBDEV_NAME "exynos-gsc-sd"
+#define FIMD_MODULE_NAME "s5p-fimd1"
+#define FIMD_ENTITY_NAME "s3c-fb-window"
+#define FLITE_MODULE_NAME "exynos-fimc-lite"
+#define CSIS_MODULE_NAME "s5p-mipi-csis"
+
+#define GSC_CAP_GRP_ID (1 << 0)
+#define FLITE_GRP_ID (1 << 1)
+#define CSIS_GRP_ID (1 << 2)
+#define SENSOR_GRP_ID (1 << 3)
+#define FIMD_GRP_ID (1 << 4)
+
+#define SENSOR_MAX_ENTITIES MAX_CAMIF_CLIENTS
+#define FLITE_MAX_ENTITIES 2
+#define CSIS_MAX_ENTITIES 2
+
+enum mdev_node {
+ MDEV_OUTPUT,
+ MDEV_CAPTURE,
+ MDEV_ISP,
+};
+
+enum mxr_data_from {
+ FROM_GSC_SD,
+ FROM_MXR_VD,
+};
+
+struct exynos_media_ops {
+ int (*power_off)(struct v4l2_subdev *sd);
+};
+
+struct exynos_entity_data {
+ const struct exynos_media_ops *media_ops;
+ enum mxr_data_from mxr_data_from;
+};
+
+/**
+ * struct exynos_md - Exynos media device information
+ * @media_dev: top level media device
+ * @v4l2_dev: top level v4l2_device holding up the subdevs
+ * @pdev: platform device this media device is hooked up into
+ * @slock: spinlock protecting @sensor array
+ * @id: media device IDs
+ * @gsc_sd: each pointer of g-scaler's subdev array
+ */
+struct exynos_md {
+ struct media_device media_dev;
+ struct v4l2_device v4l2_dev;
+ struct platform_device *pdev;
+ struct v4l2_subdev *gsc_sd[MAX_GSC_SUBDEV];
+ struct v4l2_subdev *gsc_cap_sd[MAX_GSC_SUBDEV];
+ struct v4l2_subdev *csis_sd[CSIS_MAX_ENTITIES];
+ struct v4l2_subdev *flite_sd[FLITE_MAX_ENTITIES];
+ struct v4l2_subdev *sensor_sd[SENSOR_MAX_ENTITIES];
+ u16 id;
+ bool is_flite_on;
+ spinlock_t slock;
+};
+
+static int dummy_callback(struct device *dev, void *md)
+{
+ /* non-zero return stops iteration */
+ return -1;
+}
+
+static inline void *module_name_to_driver_data(char *module_name)
+{
+ struct device_driver *drv;
+ struct device *dev;
+ void *driver_data;
+
+ drv = driver_find(module_name, &platform_bus_type);
+ if (drv) {
+ dev = driver_find_device(drv, NULL, NULL, dummy_callback);
+ driver_data = dev_get_drvdata(dev);
+ put_driver(drv);
+ return driver_data;
+ } else
+ return NULL;
+}
+
+/* print entity information for debug*/
+static inline void entity_info_print(struct media_entity *me, struct device *dev)
+{
+ u16 num_pads = me->num_pads;
+ u16 num_links = me->num_links;
+ int i;
+
+ dev_dbg(dev, "entity name : %s\n", me->name);
+ dev_dbg(dev, "number of pads = %d\n", num_pads);
+ for (i = 0; i < num_pads; ++i) {
+ dev_dbg(dev, "pad[%d] flag : %s\n", i,
+ (me->pads[i].flags == 1) ? "SINK" : "SOURCE");
+ }
+
+ dev_dbg(dev, "number of links = %d\n", num_links);
+
+ for (i = 0; i < num_links; ++i) {
+ dev_dbg(dev, "link[%d] info = ", i);
+ dev_dbg(dev, "%s : %s[%d] ---> %s : %s[%d]\n",
+ me->links[i].source->entity->name,
+ me->links[i].source->flags == 1 ? "SINK" : "SOURCE",
+ me->links[i].source->index,
+ me->links[i].sink->entity->name,
+ me->links[i].sink->flags == 1 ? "SINK" : "SOURCE",
+ me->links[i].sink->index);
+ }
+}
+#endif
diff --git a/include/media/isx012_platform.h b/include/media/isx012_platform.h
new file mode 100644
index 0000000..c66b41f
--- /dev/null
+++ b/include/media/isx012_platform.h
@@ -0,0 +1,56 @@
+/*
+ * Driver for ISX012 (5MP camera) from Sony
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#define DEFAULT_PIX_FMT V4L2_PIX_FMT_UYVY /* YUV422 */
+#define DEFAULT_MCLK 24000000
+#define ISX012_STREAMOFF_DELAY 150
+
+
+enum {
+ ISX012_FLASH_MODE_NORMAL,
+ ISX012_FLASH_MODE_MOVIE,
+ ISX012_FLASH_MODE_MAX,
+};
+
+enum {
+ ISX012_FLASH_OFF = 0,
+ ISX012_FLASH_ON = 1,
+};
+
+/* Define debug level */
+#define CAMDBG_LEVEL_ERR (1 << 0)
+#define CAMDBG_LEVEL_WARN (1 << 1)
+#define CAMDBG_LEVEL_INFO (1 << 2)
+#define CAMDBG_LEVEL_DEBUG (1 << 3)
+#define CAMDBG_LEVEL_TRACE (1 << 4)
+#define CAMDBG_LEVEL_DEFAULT \
+ (CAMDBG_LEVEL_ERR | CAMDBG_LEVEL_WARN | CAMDBG_LEVEL_INFO)
+
+struct isx012_platform_data {
+ u32 default_width;
+ u32 default_height;
+ u32 pixelformat;
+ u32 freq; /* MCLK in Hz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ u32 is_mipi; /* set to 1 if mipi */
+ s32 streamoff_delay; /* ms, type is signed */
+
+ /* ISP interrupt */
+ /* int (*config_isp_irq)(void);*/
+
+ #define ISX012_SUPPORT_FLASH
+ int (*flash_en)(u32 mode, u32 onoff);
+ int (*is_flash_on)(void);
+
+ int (*stby_on)(bool);
+
+ u8 dbg_level;
+};
+
diff --git a/include/media/m5mo_platform.h b/include/media/m5mo_platform.h
new file mode 100644
index 0000000..6d79097
--- /dev/null
+++ b/include/media/m5mo_platform.h
@@ -0,0 +1,23 @@
+/*
+ * Driver for M5MO (5MP camera) from NEC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+struct m5mo_platform_data {
+ unsigned int default_width;
+ unsigned int default_height;
+ unsigned int pixelformat;
+ int freq; /* MCLK in Hz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ int is_mipi;
+
+ /* ISP interrupt */
+ int (*config_isp_irq)(void);
+ int irq;
+};
+
diff --git a/include/media/m5mols.h b/include/media/m5mols.h
index aac2c0e..544a284 100644
--- a/include/media/m5mols.h
+++ b/include/media/m5mols.h
@@ -1,5 +1,5 @@
/*
- * Driver header for M-5MOLS 8M Pixel camera sensor with ISP
+ * Driver for M5MOLS 8M Pixel camera sensor with ISP
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* Author: HeungJun Kim <riverful.kim@samsung.com>
@@ -17,19 +17,19 @@
#define MEDIA_M5MOLS_H
/**
- * struct m5mols_platform_data - platform data for M-5MOLS driver
- * @irq: GPIO getting the irq pin of M-5MOLS
- * @gpio_reset: GPIO driving the reset pin of M-5MOLS
- * @reset_polarity: active state for gpio_rst pin, 0 or 1
- * @set_power: an additional callback to the board setup code
+* struct m5mols_platform_data - platform data for M5MOLS driver
+* @irq: GPIO getting the irq pin of M5MOLS
+* @gpio_rst: GPIO driving the reset pin of M5MOLS
+ * @enable_rst: the pin state when reset pin is enabled
+* @set_power: an additional callback to a board setup code
* to be called after enabling and before disabling
- * the sensor's supply regulators
+* the sensor device supply regulators
*/
struct m5mols_platform_data {
- int irq;
- int gpio_reset;
- u8 reset_polarity;
int (*set_power)(struct device *dev, int on);
+ int irq;
+ int gpio_rst;
+ bool enable_rst;
};
#endif /* MEDIA_M5MOLS_H */
diff --git a/include/media/m9mo_platform.h b/include/media/m9mo_platform.h
new file mode 100644
index 0000000..ba9799a
--- /dev/null
+++ b/include/media/m9mo_platform.h
@@ -0,0 +1,23 @@
+/*
+ * Driver for M9MO (16MP camera) from NEC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+struct m9mo_platform_data {
+ unsigned int default_width;
+ unsigned int default_height;
+ unsigned int pixelformat;
+ int freq; /* MCLK in Hz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ int is_mipi;
+
+ /* ISP interrupt */
+ int (*config_isp_irq)(void);
+ int (*config_sambaz)(int);
+ int irq;
+};
diff --git a/include/media/s5c73m3_platform.h b/include/media/s5c73m3_platform.h
new file mode 100644
index 0000000..092ba78
--- /dev/null
+++ b/include/media/s5c73m3_platform.h
@@ -0,0 +1,22 @@
+/*
+ * Driver for S5C73M3
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+struct s5c73m3_platform_data {
+ unsigned int default_width;
+ unsigned int default_height;
+ unsigned int pixelformat;
+ int freq; /* MCLK in Hz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ int is_mipi;
+
+ void (*set_vdd_core)(int);
+ bool (*is_vdd_core_set)(void);
+ int (*is_isp_reset)(void);
+};
diff --git a/include/media/s5k4ba_platform.h b/include/media/s5k4ba_platform.h
new file mode 100644
index 0000000..91fcb4c
--- /dev/null
+++ b/include/media/s5k4ba_platform.h
@@ -0,0 +1,33 @@
+/* linux/include/media/s5k4ba_platform.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ *
+ * Driver for S5K4BA (UXGA camera) from Samsung Electronics
+ * 1/4" 2.0Mp CMOS Image Sensor SoC with an Embedded Image Processor
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/device.h>
+#include <media/v4l2-mediabus.h>
+
+struct s5k4ba_platform_data {
+ unsigned int default_width;
+ unsigned int default_height;
+ unsigned int pixelformat;
+ int freq; /* MCLK in KHz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ int is_mipi;
+};
+
+struct s5k4ba_mbus_platform_data {
+ int id;
+ struct v4l2_mbus_framefmt fmt;
+ unsigned long clk_rate; /* master clock frequency in Hz */
+ int (*set_power)(int on);
+ int (*set_clock)(struct device *dev, int on);
+};
diff --git a/include/media/s5k4ea_platform.h b/include/media/s5k4ea_platform.h
new file mode 100644
index 0000000..bc7fbe2
--- /dev/null
+++ b/include/media/s5k4ea_platform.h
@@ -0,0 +1,35 @@
+/* linux/include/media/s5k4ea_platform.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ *
+ * Driver for S5K4EA from Samsung Electronics
+ * CMOS Image Sensor SoC with an Embedded Image Processor
+ * supporting MIPI CSI-2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/device.h>
+#include <media/v4l2-mediabus.h>
+
+struct s5k4ea_platform_data {
+ unsigned int default_width;
+ unsigned int default_height;
+ unsigned int pixelformat;
+ int freq; /* MCLK in KHz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ int is_mipi;
+};
+
+struct s5k4ea_mbus_platform_data {
+ int id;
+ struct v4l2_mbus_framefmt fmt;
+ unsigned int bus_width;
+ unsigned long clk_rate; /* master clock frequency in Hz */
+ int (*set_power)(int on);
+ int (*set_clock)(struct device *dev, int on);
+};
diff --git a/include/media/s5k4ecgx_platform.h b/include/media/s5k4ecgx_platform.h
new file mode 100644
index 0000000..421e93c
--- /dev/null
+++ b/include/media/s5k4ecgx_platform.h
@@ -0,0 +1,25 @@
+/*
+ * Driver for S5K4ECGX (1.3M camera) from SAMSUNG ELECTRONICS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#define DEFAULT_FMT V4L2_PIX_FMT_UYVY /* YUV422 */
+
+#define CAM_FLASH_ON 0
+#define CAM_FLASH_TORCH 1
+#define CAM_FLASH_OFF 2
+
+struct s5k4ecgx_platform_data {
+ unsigned int default_width;
+ unsigned int default_height;
+ unsigned int pixelformat;
+ int freq; /* MCLK in KHz */
+ /* This SoC supports Parallel & CSI-2 */
+ int is_mipi;
+
+ int (*flash_ctrl)(int ctrl);
+};
diff --git a/include/media/s5k5bafx_platform.h b/include/media/s5k5bafx_platform.h
new file mode 100644
index 0000000..18ebb2b
--- /dev/null
+++ b/include/media/s5k5bafx_platform.h
@@ -0,0 +1,42 @@
+/*
+ * Driver for S5K5BAFX (VGA camera) from SAMSUNG ELECTRONICS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#define DEFAULT_FMT V4L2_PIX_FMT_UYVY /* YUV422 */
+#ifdef CONFIG_MACH_PX
+#define DEFAULT_PREVIEW_WIDTH 800
+#define DEFAULT_PREVIEW_HEIGHT 600
+#else
+#define DEFAULT_PREVIEW_WIDTH 640
+#define DEFAULT_PREVIEW_HEIGHT 480
+#endif
+#define DEFAULT_CAPTURE_WIDTH 1600
+#define DEFAULT_CAPTURE_HEIGHT 1200
+#define S5K5BAFX_STREAMOFF_DELAY 150
+
+/* Define debug level */
+#define CAMDBG_LEVEL_ERR (1 << 0)
+#define CAMDBG_LEVEL_WARN (1 << 1)
+#define CAMDBG_LEVEL_INFO (1 << 2)
+#define CAMDBG_LEVEL_DEBUG (1 << 3)
+#define CAMDBG_LEVEL_TRACE (1 << 4)
+#define CAMDBG_LEVEL_DEFAULT \
+ (CAMDBG_LEVEL_ERR | CAMDBG_LEVEL_WARN | CAMDBG_LEVEL_INFO)
+
+struct s5k5bafx_platform_data {
+ u32 default_width;
+ u32 default_height;
+ u32 pixelformat;
+ u32 freq; /* MCLK in KHz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ u32 is_mipi; /* set to 1 if mipi */
+ s32 streamoff_delay; /* ms, type is signed */
+
+ u8 dbg_level;
+};
diff --git a/include/media/s5k5ccgx_platform.h b/include/media/s5k5ccgx_platform.h
new file mode 100644
index 0000000..2630c2f
--- /dev/null
+++ b/include/media/s5k5ccgx_platform.h
@@ -0,0 +1,54 @@
+/*
+ * Driver for S5K5CCGX (3MP camera) from LSI
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#define DEFAULT_PIX_FMT V4L2_PIX_FMT_UYVY /* YUV422 */
+#define DEFAULT_MCLK 24000000
+#define S5K5CCGX_STREAMOFF_DELAY 120
+
+
+enum {
+ S5K5CCGX_FLASH_MODE_NORMAL,
+ S5K5CCGX_FLASH_MODE_MOVIE,
+ S5K5CCGX_FLASH_MODE_MAX,
+};
+
+enum {
+ S5K5CCGX_FLASH_OFF = 0,
+ S5K5CCGX_FLASH_ON = 1,
+};
+
+/* Define debug level */
+#define CAMDBG_LEVEL_ERR (1 << 0)
+#define CAMDBG_LEVEL_WARN (1 << 1)
+#define CAMDBG_LEVEL_INFO (1 << 2)
+#define CAMDBG_LEVEL_DEBUG (1 << 3)
+#define CAMDBG_LEVEL_TRACE (1 << 4)
+#define CAMDBG_LEVEL_DEFAULT \
+ (CAMDBG_LEVEL_ERR | CAMDBG_LEVEL_WARN | CAMDBG_LEVEL_INFO)
+
+struct s5k5ccgx_platform_data {
+ u32 default_width;
+ u32 default_height;
+ u32 pixelformat;
+ u32 freq; /* MCLK in Hz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ u32 is_mipi; /* set to 1 if mipi */
+ s32 streamoff_delay; /* ms, type is signed */
+
+ /* ISP interrupt */
+ /* int (*config_isp_irq)(void);*/
+
+ #define S5K5CCGX_SUPPORT_FLASH
+ int (*flash_en)(u32 mode, u32 onoff);
+ int (*is_flash_on)(void);
+
+ u8 dbg_level;
+};
+
diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h
index 9fdff8a..d0a1dc2 100644
--- a/include/media/s5p_fimc.h
+++ b/include/media/s5p_fimc.h
@@ -12,13 +12,20 @@
#ifndef S5P_FIMC_H_
#define S5P_FIMC_H_
-enum cam_bus_type {
+#define FLITE_MAX_NUM 2
+
+enum fimc_cam_bus_type {
FIMC_ITU_601 = 1,
FIMC_ITU_656,
FIMC_MIPI_CSI2,
FIMC_LCD_WB, /* FIFO link from LCD mixer */
};
+enum flite_index {
+ FLITE_IDX_A = 0,
+ FLITE_IDX_B = 1,
+};
+
#define FIMC_CLK_INV_PCLK (1 << 0)
#define FIMC_CLK_INV_VSYNC (1 << 1)
#define FIMC_CLK_INV_HREF (1 << 2)
@@ -37,25 +44,36 @@ struct i2c_board_info;
* @i2c_bus_num: i2c control bus id the sensor is attached to
* @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
* @flags: flags defining bus signals polarity inversion (High by default)
+ * @use_cam: a means of used by FIMC
*/
struct s5p_fimc_isp_info {
struct i2c_board_info *board_info;
unsigned long clk_frequency;
- enum cam_bus_type bus_type;
+ enum fimc_cam_bus_type bus_type;
u16 csi_data_align;
u16 i2c_bus_num;
u16 mux_id;
u16 flags;
+ bool use_cam;
+ bool use_isp;
+ enum flite_index flite_id;
+ int (*cam_power)(int onoff);
};
+#define FIMC_MAX_CAMIF_CLIENTS 2
+#define FIMC_MAX_CSIS_NUM 2
+
/**
* struct s5p_platform_fimc - camera host interface platform data
*
* @isp_info: properties of camera sensor required for host interface setup
- * @num_clients: the number of attached image sensors
*/
struct s5p_platform_fimc {
- struct s5p_fimc_isp_info *isp_info;
- int num_clients;
+ struct s5p_fimc_isp_info *isp_info[FIMC_MAX_CAMIF_CLIENTS];
};
+
+extern struct s5p_platform_fimc s3c_fimc0_default_data;
+extern struct s5p_platform_fimc s3c_fimc1_default_data;
+extern struct s5p_platform_fimc s3c_fimc2_default_data;
+extern struct s5p_platform_fimc s3c_fimc3_default_data;
#endif /* S5P_FIMC_H_ */
diff --git a/include/media/sr200pc20_platform.h b/include/media/sr200pc20_platform.h
new file mode 100644
index 0000000..994aa3b
--- /dev/null
+++ b/include/media/sr200pc20_platform.h
@@ -0,0 +1,36 @@
+/*
+ * Driver for SR200PC20 (2M camera) from SAMSUNG ELECTRONICS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#define DEFAULT_FMT V4L2_PIX_FMT_UYVY /* YUV422 */
+#define DEFAULT_PREVIEW_WIDTH 800
+#define DEFAULT_PREVIEW_HEIGHT 600
+#define DEFAULT_CAPTURE_WIDTH 1600
+#define DEFAULT_CAPTURE_HEIGHT 1200
+
+/* Define debug level */
+#define CAMDBG_LEVEL_ERR (1 << 0)
+#define CAMDBG_LEVEL_WARN (1 << 1)
+#define CAMDBG_LEVEL_INFO (1 << 2)
+#define CAMDBG_LEVEL_DEBUG (1 << 3)
+#define CAMDBG_LEVEL_TRACE (1 << 4)
+#define CAMDBG_LEVEL_DEFAULT \
+ (CAMDBG_LEVEL_ERR | CAMDBG_LEVEL_WARN | CAMDBG_LEVEL_INFO)
+
+struct sr200pc20_platform_data {
+ u32 default_width;
+ u32 default_height;
+ u32 pixelformat;
+ u32 freq; /* MCLK in KHz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ u32 is_mipi; /* set to 1 if mipi */
+ s32 streamoff_delay; /* ms, type is signed */
+
+ u8 dbg_level;
+};
diff --git a/include/media/sr200pc20m_platform.h b/include/media/sr200pc20m_platform.h
new file mode 100644
index 0000000..2291304
--- /dev/null
+++ b/include/media/sr200pc20m_platform.h
@@ -0,0 +1,36 @@
+/*
+ * Driver for SR200PC20M (2M camera) from SAMSUNG ELECTRONICS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#define DEFAULT_FMT V4L2_PIX_FMT_UYVY /* YUV422 */
+#define DEFAULT_PREVIEW_WIDTH 640
+#define DEFAULT_PREVIEW_HEIGHT 480
+#define DEFAULT_CAPTURE_WIDTH 1600
+#define DEFAULT_CAPTURE_HEIGHT 1200
+
+/* Define debug level */
+#define CAMDBG_LEVEL_ERR (1 << 0)
+#define CAMDBG_LEVEL_WARN (1 << 1)
+#define CAMDBG_LEVEL_INFO (1 << 2)
+#define CAMDBG_LEVEL_DEBUG (1 << 3)
+#define CAMDBG_LEVEL_TRACE (1 << 4)
+#define CAMDBG_LEVEL_DEFAULT \
+ (CAMDBG_LEVEL_ERR | CAMDBG_LEVEL_WARN | CAMDBG_LEVEL_INFO)
+
+struct sr200pc20m_platform_data {
+ u32 default_width;
+ u32 default_height;
+ u32 pixelformat;
+ u32 freq; /* MCLK in KHz */
+
+ /* This SoC supports Parallel & CSI-2 */
+ u32 is_mipi; /* set to 1 if mipi */
+ s32 streamoff_delay; /* ms, type is signed */
+
+ u8 dbg_level;
+};
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index 0206aa5..d247111 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -30,11 +30,13 @@
struct video_device;
struct v4l2_events;
+struct v4l2_ctrl_handler;
struct v4l2_fh {
struct list_head list;
struct video_device *vdev;
struct v4l2_events *events; /* events, pending and subscribed */
+ struct v4l2_ctrl_handler *ctrl_handler;
enum v4l2_priority prio;
};
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 16ac473..4f001d2 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -88,6 +88,9 @@ struct v4l2_m2m_buffer {
void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev);
+void v4l2_m2m_get_next_job(struct v4l2_m2m_dev *m2m_dev,
+ struct v4l2_m2m_ctx *m2m_ctx);
+
struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx,
enum v4l2_buf_type type);
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 2884e3e..4cadb78 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -229,6 +229,12 @@ struct v4l2_subdev_audio_ops {
s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
video input devices.
+ g_std_output: get current standard for video OUTPUT devices. This is ignored
+ by video input devices.
+
+ g_tvnorms_output: get v4l2_std_id with all standards supported by video
+ OUTPUT device. This is ignored by video input devices.
+
s_crystal_freq: sets the frequency of the crystal used to generate the
clocks in Hz. An extra flags field allows device specific configuration
regarding clock frequency dividers, etc. If not used, then set flags
@@ -243,6 +249,8 @@ struct v4l2_subdev_audio_ops {
s_dv_preset: set dv (Digital Video) preset in the sub device. Similar to
s_std()
+ g_dv_preset: get current dv (Digital Video) preset in the sub device.
+
query_dv_preset: query dv preset in the sub device. This is similar to
querystd()
@@ -264,7 +272,9 @@ struct v4l2_subdev_video_ops {
int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
+ int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
+ int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
int (*s_stream)(struct v4l2_subdev *sd, int enable);
int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc);
@@ -282,6 +292,8 @@ struct v4l2_subdev_video_ops {
struct v4l2_dv_enum_preset *preset);
int (*s_dv_preset)(struct v4l2_subdev *sd,
struct v4l2_dv_preset *preset);
+ int (*g_dv_preset)(struct v4l2_subdev *sd,
+ struct v4l2_dv_preset *preset);
int (*query_dv_preset)(struct v4l2_subdev *sd,
struct v4l2_dv_preset *preset);
int (*s_dv_timings)(struct v4l2_subdev *sd,
diff --git a/include/media/videobuf2-cma-phys.h b/include/media/videobuf2-cma-phys.h
new file mode 100644
index 0000000..7022cf3
--- /dev/null
+++ b/include/media/videobuf2-cma-phys.h
@@ -0,0 +1,45 @@
+/* linux/inclue/media/videobuf2-cma-phys.h
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ *
+ * CMA-phys memory allocator for videobuf2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef _MEDIA_VIDEOBUF2_CMA_PHYS_H
+#define _MEDIA_VIDEOBUF2_CMA_PHYS_H
+
+#include <media/videobuf2-core.h>
+
+static inline unsigned long vb2_cma_phys_plane_paddr(struct vb2_buffer *vb,
+ unsigned int plane_no)
+{
+ return (unsigned long)vb2_plane_cookie(vb, plane_no);
+}
+
+struct vb2_alloc_ctx *vb2_cma_phys_init(struct device *dev, const char *type,
+ unsigned long alignment,
+ bool cacheable);
+void vb2_cma_phys_cleanup(void *alloc_ctx);
+
+struct vb2_alloc_ctx **vb2_cma_phys_init_multi(struct device *dev,
+ unsigned int num_planes, const char *types[],
+ unsigned long alignments[],
+ bool cacheable);
+void vb2_cma_phys_cleanup_multi(void **alloc_ctxes);
+
+void vb2_cma_phys_set_cacheable(void *alloc_ctx, bool cacheable);
+bool vb2_cma_phys_get_cacheable(void *alloc_ctx);
+int vb2_cma_phys_cache_flush(struct vb2_buffer *vb, u32 num_planes);
+int vb2_cma_phys_cache_inv(struct vb2_buffer *vb, u32 num_planes);
+int vb2_cma_phys_cache_clean(struct vb2_buffer *vb, u32 num_planes);
+int vb2_cma_phys_cache_clean2(struct vb2_buffer *vb, u32 num_planes);
+
+extern const struct vb2_mem_ops vb2_cma_phys_memops;
+
+#endif
+
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index f87472a..dcfcdd1 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -16,6 +16,7 @@
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/videodev2.h>
+#include <linux/dma-buf.h>
struct vb2_alloc_ctx;
struct vb2_fileio_data;
@@ -41,21 +42,48 @@ struct vb2_fileio_data;
* argument to other ops in this structure
* @put_userptr: inform the allocator that a USERPTR buffer will no longer
* be used
+ * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation;
+ * used for DMABUF memory types; alloc_ctx is the alloc context
+ * dbuf is the shared dma_buf; returns NULL on failure;
+ * allocator private per-buffer structure on success;
+ * this needs to be used for further accesses to the buffer.
+ * @detach_dmabuf: inform the exporter of the buffer that the current DMABUF
+ * buffer is no longer used; the buf_priv argument is the
+ * allocator private per-buffers structure previously returned
+ * from the attach_dmabuf callback.
+ * @map_dmabuf: request for access to the dmabuf from allocator; the allocator
+ * of dmabuf is informed that this driver is going to use the
+ * dmabuf.
+ * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified
+ * that this driver is done using the dmabuf for now.
+ * @export_dmabuf: export an allocated buffer to the dmabuf for that user can
+ * access the buffer through the fd of it.
* @vaddr: return a kernel virtual address to a given memory buffer
* associated with the passed private structure or NULL if no
* such mapping exists
* @cookie: return allocator specific cookie for a given memory buffer
* associated with the passed private structure or NULL if not
* available
+ * @share: return allocator specific object to share a given memory buffer
+ * associated with the passed private structure or NULL if not
+ * available
* @num_users: return the current number of users of a memory buffer;
* return 1 if the videobuf layer (or actually the driver using
* it) is the only user
* @mmap: setup a userspace mapping for a given memory buffer under
* the provided virtual memory region
+ * @sync_to_dev: change the ownership of the buffer from CPU to device; this
+ * ensures that all stuffs related to the buffer visible to CPU
+ * are also visible to the device.
+ * @sync_from_dev: change the ownership of the buffer from device to CPU; this
+ * ensures that all stuffs related to the buffer visible to
+ * the device are also visible to the CPU.
*
* Required ops for USERPTR types: get_userptr, put_userptr.
* Required ops for MMAP types: alloc, put, num_users, mmap.
* Required ops for read/write access types: alloc, put, num_users, vaddr
+ * Required ops for DMABUF types: attach_dmabuf, detach_dmabuf, map_dmabuf,
+ * unmap_dmabuf, export_dmabuf.
*/
struct vb2_mem_ops {
void *(*alloc)(void *alloc_ctx, unsigned long size);
@@ -65,16 +93,36 @@ struct vb2_mem_ops {
unsigned long size, int write);
void (*put_userptr)(void *buf_priv);
+ int (*export_dmabuf)(void *alloc_ctx, void *buf_priv,
+ int *export_fd);
+
+ /*
+ * XXX really, I think the attach/detach could be handled in the
+ * vb2 core, and vb2_mem_ops really just need to get/put the sglist
+ * (and make sure that the sglist fits it's needs..)
+ */
+ void *(*attach_dmabuf)(void *alloc_ctx,
+ struct dma_buf *dbuf);
+ void (*detach_dmabuf)(void *buf_priv);
+ void (*map_dmabuf)(void *buf_priv);
+ void (*unmap_dmabuf)(void *buf_priv);
+
void *(*vaddr)(void *buf_priv);
void *(*cookie)(void *buf_priv);
+ void *(*share)(void *buf_priv);
unsigned int (*num_users)(void *buf_priv);
int (*mmap)(void *buf_priv, struct vm_area_struct *vma);
+ void (*sync_to_dev)(void *alloc_ctx[], void *privs[],
+ int nplanes, enum v4l2_buf_type type);
+ void (*sync_from_dev)(void *alloc_ctx[], void *privs[],
+ int nplanes, enum v4l2_buf_type type);
};
struct vb2_plane {
void *mem_priv;
+ struct dma_buf *dbuf;
int mapped:1;
};
@@ -84,12 +132,14 @@ struct vb2_plane {
* @VB2_USERPTR: driver supports USERPTR with streaming API
* @VB2_READ: driver supports read() style access
* @VB2_WRITE: driver supports write() style access
+ * @VB2_DMABUF: driver supports DMABUF with streaming API
*/
enum vb2_io_modes {
VB2_MMAP = (1 << 0),
VB2_USERPTR = (1 << 1),
VB2_READ = (1 << 2),
VB2_WRITE = (1 << 3),
+ VB2_DMABUF = (1 << 4),
};
/**
diff --git a/include/media/videobuf2-ion.h b/include/media/videobuf2-ion.h
new file mode 100644
index 0000000..48a6a8a
--- /dev/null
+++ b/include/media/videobuf2-ion.h
@@ -0,0 +1,220 @@
+/* include/media/videobuf2-ion.h
+ *
+ * Copyright 2011-2012 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ *
+ * Definition of Android ION memory allocator for videobuf2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _MEDIA_VIDEOBUF2_ION_H
+#define _MEDIA_VIDEOBUF2_ION_H
+
+#include <linux/scatterlist.h>
+#include <linux/dma-mapping.h>
+#include <linux/ion.h>
+#include <linux/err.h>
+
+/* flags to vb2_ion_create_context
+ * These flags are dependet upon heap flags in ION.
+ *
+ * bit 0 ~ ION_NUM_HEAPS: ion heap flags
+ * bit ION_NUM_HEAPS+1 ~ 20: non-ion flags (cached, iommu)
+ * bit 21 ~ BITS_PER_LONG - 1: ion specific flags
+ */
+
+/* Allocate physically contiguous memory */
+#define VB2ION_CTX_PHCONTIG ION_HEAP_EXYNOS_CONTIG_MASK
+/* Allocate virtually contiguous memory */
+#define VB2ION_CTX_VMCONTIG ION_HEAP_EXYNOS_MASK
+/* Provide device a virtual address space */
+#define VB2ION_CTX_IOMMU (1 << (ION_NUM_HEAPS + 1))
+/* Non-cached mapping to user when mmap */
+#define VB2ION_CTX_UNCACHED (1 << (ION_NUM_HEAPS + 2))
+
+/* flags for contents protection */
+#define VB2ION_CTX_DRM_MFCSH ION_HEAP_EXYNOS_MFC_SH_MASK
+#define VB2ION_CTX_DRM_VIDEO ION_HEAP_EXYNOS_VIDEO_MASK
+#define VB2ION_CTX_DRM_MFCFW ION_HEAP_EXYNOS_MFC_FW_MASK
+
+#define VB2ION_CTX_MASK_ION (~((1 << (BITS_PER_LONG - 12)) - 1) \
+ | ((1 << ION_NUM_HEAPS) - 1))
+/* mask out all non-ion flags */
+#define ion_heapflag(flag) (flag & VB2ION_CTX_MASK_ION)
+
+struct device;
+struct vb2_buffer;
+
+/* vb2_ion_create_context - create a new vb2 context for buffer manipulation
+ * dev - device that needs to use vb2
+ * alignment - minimum alignment requirement for the start address of the
+ * allocated buffer from vb2.
+ * flags - detailed control to the vb2 context. See above flags that stats
+ * with VB2ION_*
+ *
+ * This function creates a new videobuf2 context which is internal data of
+ * videobuf2 for allocating and manipulating buffers. Drivers that obtain vb2
+ * contexts must regard the contexts as keys for videobuf2 to access the
+ * requirments of the drivers for the buffers allocated from videobuf2.
+ *
+ * Once a driver obtains vb2 contexts from vb2_ion_create_context(), it must
+ * assign those contexts to alloc_ctxs[] argument of vb2_ops.queue_setup().
+ *
+ * Some specifications of a vb2 context can be changed after it has been created
+ * and assigned to vb2 core with vb2_ops.queue_setup():
+ * - vb2_ion_set_cached(): Changes cached attribute of the buffer which will be
+ * allocated after calling this function. Cached attribute of a buffer is
+ * effected when it is mapped to user with mmap() function call.
+ * - vb2_ion_set_alignment(): Changes alignment requirement of the buffer which
+ * will be allocated after calling this function.
+ *
+ * For the devices that needs internal buffers for firmwares or devices'
+ * context buffers, their drivers can generate a vb2 context which is not
+ * handled by vb2 core but only by vb2-ion.
+ * That kinds of vb2 contexts can be passed to the first parameter of
+ * vb2_ion_private_alloc(void *alloc_ctx, size_t size).
+ *
+ * Drivers can generate vb2 contexts as many as they require with different
+ * requirements specified in flags argument. The only _restriction_ on
+ * generating a vb2 context is that the drivers must call
+ * vb2_ion_create_context() in a kernel thread due to the behavior of
+ * ion_client_create().
+ */
+void *vb2_ion_create_context(struct device *dev, size_t alignment, long flags);
+
+/* vb2_ion_destroy_context - destroys a vb2 context
+ * This function removes the given vb2 context which is created by
+ * vb2_ion_create_context()
+ */
+void vb2_ion_destroy_context(void *ctx);
+
+void vb2_ion_set_cached(void *ctx, bool cached);
+int vb2_ion_set_alignment(void *ctx, size_t alignment);
+
+/* Data type of the cookie returned by vb2_plane_cookie() function call.
+ * The drivers do not need the definition of this structure. The only reason
+ * why it is defined outside of videobuf2-ion.c is to make some functions
+ * inline.
+ */
+struct vb2_ion_cookie {
+ dma_addr_t ioaddr;
+ struct scatterlist *sg;
+ int nents;
+ off_t offset;
+};
+
+/* vb2_ion_phys_address - returns the physical address of the given buffer
+ * - cookie: pointer returned by vb2_plane_cookie()
+ * - phys_addr: pointer to the store of the physical address of the buffer
+ * specified by cookie.
+ *
+ * Returns -EINVAL if the buffer does not have nor physically contiguous memory.
+ */
+static inline int vb2_ion_phys_address(void *cookie, phys_addr_t *phys_addr)
+{
+ struct vb2_ion_cookie *vb2cookie = cookie;
+
+ if (WARN_ON(!phys_addr || IS_ERR_OR_NULL(cookie)))
+ return -EINVAL;
+
+ if (vb2cookie->nents == 1)
+ *phys_addr = sg_phys(vb2cookie->sg) + vb2cookie->offset;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
+/* vb2_ion_dma_address - returns the DMA address that device can see
+ * - cookie: pointer returned by vb2_plane_cookie()
+ * - dma_addr: pointer to the store of the address of the buffer specified
+ * by cookie. It can be either IO virtual address or physical address
+ * depending on the specification of allocation context which allocated
+ * the buffer.
+ *
+ * Returns -EINVAL if the buffer has neither IO virtual address nor physically
+ * contiguous memory
+ */
+static inline int vb2_ion_dma_address(void *cookie, dma_addr_t *dma_addr)
+{
+ struct vb2_ion_cookie *vb2cookie = cookie;
+
+ if (WARN_ON(!dma_addr || IS_ERR_OR_NULL(cookie)))
+ return -EINVAL;
+
+ if (vb2cookie->ioaddr == 0)
+ return vb2_ion_phys_address(cookie, (phys_addr_t *)dma_addr);
+
+ *dma_addr = vb2cookie->ioaddr;
+
+ return 0;
+}
+
+/* vb2_ion_get_sg - returns scatterlist of the given cookie.
+ * - cookie: pointer returned by vb2_plane_cookie()
+ * - nents: pointer to the store of number of elements in the returned
+ * scatterlist
+ *
+ * Returns the scatterlist of the buffer specified by cookie.
+ * If the arguments are not correct, returns NULL.
+ */
+static inline struct scatterlist *vb2_ion_get_sg(void *cookie, int *nents)
+{
+ struct vb2_ion_cookie *vb2cookie = cookie;
+
+ if (WARN_ON(!nents || IS_ERR_OR_NULL(cookie)))
+ return NULL;
+
+ *nents = vb2cookie->nents;
+ return vb2cookie->sg;
+}
+
+/***** Device's internal/context buffer support *****/
+
+/* vb2_ion_private_vaddr - the kernelspace address for the given cookie
+ * cookie - pointer returned by vb2_ion_private_alloc()
+ *
+ * This function returns minus error value on error.
+ */
+void *vb2_ion_private_vaddr(void *cookie);
+
+/* vb2_ion_private_alloc - allocate a buffer for device drivers's private use
+ * alloc_ctx - pointer returned by vb2_ion_create_context
+ * size - size of the buffer allocated
+ *
+ * This function returns the pointer to a cookie that represents the allocated
+ * buffer or minus error value. With the cookie you can:
+ * - retrieve scatterlist of the buffer.
+ * - retrieve dma address. (IO virutal address if IOMMU is enabled when
+ * creating alloc_ctx or physical address)
+ * - retrieve virtual address in the kernel space.
+ * - free the allocated buffer
+ */
+void *vb2_ion_private_alloc(void *alloc_ctx, size_t size);
+
+/* vb2_ion_private_free - free the buffer allocated by vb2_ion_private_alloc */
+void vb2_ion_private_free(void *cookie);
+
+/***** Cache mainatenance operations *****/
+void vb2_ion_sync_for_device(void *cookie, off_t offset, size_t size,
+ enum dma_data_direction dir);
+void vb2_ion_sync_for_cpu(void *cookie, off_t offset, size_t size,
+ enum dma_data_direction dir);
+
+int vb2_ion_cache_flush(struct vb2_buffer *vb, u32 num_planes);
+int vb2_ion_cache_inv(struct vb2_buffer *vb, u32 num_planes);
+
+/* IOMMU support */
+
+/* vb2_ion_attach_iommu - enables IOMMU of the device specified in alloc_ctx */
+int vb2_ion_attach_iommu(void *alloc_ctx);
+
+/* vb2_ion_attach_iommu - disables IOMMU of the device specified in alloc_ctx */
+void vb2_ion_detach_iommu(void *alloc_ctx);
+
+extern const struct vb2_mem_ops vb2_ion_memops;
+
+#endif