V4L2 driver for Exynos4x12 Imaging Subsystem
Subsystems (3)
v2 cover V4L2 driver for Exynos4x12 Imaging Subsystem
This iteration includes couple bug fixes and minor cleanup comparing to the original version (original cover letter can be found below). A patch adding ISP capture node has been removed as I'll need more time to enable this feature and I'd like to possibly have this series included in 3.10.
-------
This patch series is an initial version of a driver for the camera ISP subsystem (FIMC-IS) found in Samsung Exynos4x12 SoCs.
The FIMC-IS subsystem is build around a ARM Cortex-A5 CPU that controls its dedicated peripherals, like I2C, SPI, UART, PWM, ADC,... and the ISP chain. There are 3 hardware image processing blocks: ISP, DRC (dynamic range compression) and FD (face detection) that are normally controlled by the Cortex-A5 firmware.
The driver currently exposes two additional sub-devices to user space:
the image sensor and FIMC-IS-ISP sub-device. Another one might be added in future for the FD features.
The FIMC-IS has various data inputs, it can capture data from memory or from other SoC IP blocks (FIMC-LITE). It is currently plugged between FIMC-LITE and FIMC IP blocks, so there is a media pipeline like:
sensor -> MIPI-CSIS -> FIMC-LITE -> FIMC-IS-ISP -> FIMC -> memory
A raw Bayer image data can be captured from the ISP block which has it's own DMA engines. Support for this is not really included in this series though, only a video capture node driver stubs are added.
This is a bit complicated code, nevertheless I would really appreciate any review comments you might have.
And this is just a basic set of futures this patch series addresses. Others include input/output DMA support for the DRC and FD blocks, support for more ISP controls, etc.
Full git tree with all dependencies can be found at:
http://git.linuxtv.org/snawrocki/samsung.git/exynos4-fimc-is-v2
Sylwester Nawrocki (7):
exynos4-is: Add Exynos4x12 FIMC-IS driver
exynos4-is: Add FIMC-IS ISP I2C bus driver
exynos4-is: Add FIMC-IS parameter region definitions
exynos4-is: Add common FIMC-IS image sensor driver
exynos4-is: Add Exynos4x12 FIMC-IS device tree bindings documentation
s5p-fimc: Add fimc-is subdevs registration
s5p-fimc: Create media links for the FIMC-IS entities
.../devicetree/bindings/media/exynos4-fimc-is.txt | 45 + drivers/media/platform/exynos4-is/Kconfig | 13 + drivers/media/platform/exynos4-is/Makefile | 3 + .../media/platform/exynos4-is/fimc-is-command.h | 147 +++ drivers/media/platform/exynos4-is/fimc-is-errno.c | 272 ++++++ drivers/media/platform/exynos4-is/fimc-is-errno.h | 248 +++++ drivers/media/platform/exynos4-is/fimc-is-i2c.c | 81 ++ drivers/media/platform/exynos4-is/fimc-is-i2c.h | 15 + drivers/media/platform/exynos4-is/fimc-is-param.c | 971 +++++++++++++++++++ drivers/media/platform/exynos4-is/fimc-is-param.h | 1022 ++++++++++++++++++++ drivers/media/platform/exynos4-is/fimc-is-regs.c | 242 +++++ drivers/media/platform/exynos4-is/fimc-is-regs.h | 164 ++++ drivers/media/platform/exynos4-is/fimc-is-sensor.c | 307 ++++++ drivers/media/platform/exynos4-is/fimc-is-sensor.h | 80 ++ drivers/media/platform/exynos4-is/fimc-is.c | 962 ++++++++++++++++++ drivers/media/platform/exynos4-is/fimc-is.h | 340 +++++++ drivers/media/platform/exynos4-is/fimc-isp.c | 707 ++++++++++++++ drivers/media/platform/exynos4-is/fimc-isp.h | 181 ++++ drivers/media/platform/exynos4-is/media-dev.c | 120 ++- drivers/media/platform/exynos4-is/media-dev.h | 13 + 20 files changed, 5911 insertions(+), 22 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt create mode 100644 drivers/media/platform/exynos4-is/fimc-is-command.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is.h create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.c create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.h
--
1.7.9.5
PATCH v2 1/7 exynos4-is: Add Exynos4x12 FIMC-IS driver
This patch adds a set of core files of the Exynos4x12 FIMC-IS V4L2 driver. This includes main functionality like allocating memory, loading the firmware, FIMC-IS register interface and host CPU <-> IS command and error code definitions.
The driver currently exposes a single subdev named FIMC-IS-ISP, which corresponds to the FIMC-IS ISP and DRC IP blocks.
The FIMC-IS-ISP subdev currently supports only a subset of user controls. For other controls we need several extensions at the V4L2 API. The supported standard controls are:
brightness, contrast, saturation, hue, sharpness, 3a_lock, exposure_time_absolute, white_balance_auto_preset, iso_sensitivity, iso_sensitivity_auto, exposure_metering_mode.
--- .../media/platform/exynos4-is/fimc-is-command.h | 147 +++ drivers/media/platform/exynos4-is/fimc-is-errno.c | 272 ++++++ drivers/media/platform/exynos4-is/fimc-is-errno.h | 248 +++++ drivers/media/platform/exynos4-is/fimc-is-regs.c | 242 +++++ drivers/media/platform/exynos4-is/fimc-is-regs.h | 164 ++++ drivers/media/platform/exynos4-is/fimc-is.c | 962 ++++++++++++++++++++ drivers/media/platform/exynos4-is/fimc-is.h | 340 +++++++ drivers/media/platform/exynos4-is/fimc-isp.c | 707 ++++++++++++++ drivers/media/platform/exynos4-is/fimc-isp.h | 181 ++++ 9 files changed, 3263 insertions(+) create mode 100644 drivers/media/platform/exynos4-is/fimc-is-command.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.h create mode 100644 drivers/media/platform/exynos4-is/fimc-is.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is.h create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.c create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.h
drivers/media/platform/exynos4-is/fimc-is-command.h new file +147 -0
@@ -0,0 +1,147 @@ +/* +* Samsung Exynos4x12 FIMC-IS (Imaging Subsystem) driver +* +* FIMC-IS command set definitions +* +* Copyright (C) 2013 Samsung Electronics Co., Ltd. +* +* Authors: Younghwan Joo <[email protected]> +* Sylwester Nawrocki <[email protected]> +* +* 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 FIMC_IS_CMD_H_ +#define FIMC_IS_CMD_H_ + +#define FIMC_IS_COMMAND_VER 110/* FIMC-IS command set version 1.10 */ + +/* Enumeration of commands beetween the FIMC-IS and the host processor. */ + +/* HOST to FIMC-IS */ +#define FIMC_IS_HIC_PREVIEW_STILL 0x0001 +#define FIMC_IS_HIC_PREVIEW_VIDEO 0x0002 +#define FIMC_IS_HIC_CAPTURE_STILL 0x0003 +#define FIMC_IS_HIC_CAPTURE_VIDEO 0x0004 +#define FIMC_IS_HIC_STREAM_ON 0x0005 +#define FIMC_IS_HIC_STREAM_OFF 0x0006 +#define FIMC_IS_HIC_SET_PARAMETER 0x0007 +#define FIMC_IS_HIC_GET_PARAMETER 0x0008 +#define FIMC_IS_HIC_SET_TUNE 0x0009 +#define FIMC_IS_HIC_GET_STATUS 0x000b +/* Sensor part */ +#define FIMC_IS_HIC_OPEN_SENSOR 0x000c +#define FIMC_IS_HIC_CLOSE_SENSOR 0x000d +#define FIMC_IS_HIC_SIMMIAN_INIT 0x000e +#define FIMC_IS_HIC_SIMMIAN_WRITE 0x000f +#define FIMC_IS_HIC_SIMMIAN_READ 0x0010 +#define FIMC_IS_HIC_POWER_DOWN 0x0011 +#define FIMC_IS_HIC_GET_SET_FILE_ADDR 0x0012 +#define FIMC_IS_HIC_LOAD_SET_FILE 0x0013 +#define FIMC_IS_HIC_MSG_CONFIG 0x0014 +#define FIMC_IS_HIC_MSG_TEST 0x0015 +/* FIMC-IS to HOST */ +#define FIMC_IS_IHC_GET_SENSOR_NUM 0x1000 +#define FIMC_IS_IHC_SET_SHOT_MARK 0x1001 +/* parameter1: frame number */ +/* parameter2: confidence level (smile 0~100) */ +/* parameter3: confidence level (blink 0~100) */ +#define FIMC_IS_IHC_SET_FACE_MARK 0x1002 +/* parameter1: coordinate count */ +/* parameter2: coordinate buffer address */ +#define FIMC_IS_IHC_FRAME_DONE 0x1003 +/* parameter1: frame start number */ +/* parameter2: frame count */ +#define FIMC_IS_IHC_AA_DONE 0x1004 +#define FIMC_IS_IHC_NOT_READY 0x1005 + +#define FIMC_IS_REPLY_DONE 0x2000 +#define FIMC_IS_REPLY_NOT_DONE 0x2001 + +enum fimc_is_scenario { +IS_SC_PREVIEW_STILL , +IS_SC_PREVIEW_VIDEO , +IS_SC_CAPTURE_STILL , +IS_SC_CAPTURE_VIDEO , +IS_SC_MAX +}; + +enum fimc_is_sub_scenario { +IS_SC_SUB_DEFAULT , +IS_SC_SUB_PS_VTCALL , +IS_SC_SUB_CS_VTCALL , +IS_SC_SUB_PV_VTCALL , +IS_SC_SUB_CV_VTCALL , +}; + +struct fimc_is_capability { +u32 support_af; +u32 iso_gain; +u32 aperture; +u32 min_exposure; +u32 max_exposure; +u32 min_gain; +u32 max_gain; +} __packed; + +struct is_common_reg { +u32 hicmd; +u32 hic_sensorid; +u32 hic_param[4 ]; +u32 reserved1[4 ]; + +u32 ihcmd; +u32 ihc_sensorid; +u32 ihc_param[4 ]; +u32 reserved2[4 ]; + +u32 isp_sensor_id; +u32 isp_param[2 ]; +u32 reserved3[1 ]; + +u32 scc_sensor_id; +u32 scc_param[2 ]; +u32 reserved4[1 ]; + +u32 dnr_sensor_id; +u32 dnr_param[2 ]; +u32 reserved5[1 ]; + +u32 scp_sensor_id; +u32 scp_param[2 ]; +u32 reserved6[29 ]; +} __packed; + +struct is_mcuctl_reg { +u32 mcuctl; +u32 bboar; + +u32 intgr0; +u32 intcr0; +u32 intmr0; +u32 intsr0; +u32 intmsr0; + +u32 intgr1; +u32 intcr1; +u32 intmr1; +u32 intsr1; +u32 intmsr1; + +u32 intcr2; +u32 intmr2; +u32 intsr2; +u32 intmsr2; + +u32 gpoctrl; +u32 cpoenctlr; +u32 gpictlr; + +u32 pad[0xd ]; + +struct is_common_reg common; +} __packed; + +#endif /* FIMC_IS_CMD_H_ */
drivers/media/platform/exynos4-is/fimc-is-errno.c new file +272 -0
272 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-is-errno.h new file +248 -0
248 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-is-regs.c new file +242 -0
242 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-is-regs.h new file +164 -0
164 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-is.c new file +962 -0
962 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-is.h new file +340 -0
340 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-isp.c new file +707 -0
625 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-isp.h new file +181 -0
181 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.9.5
Part of the diff is not shown here. View the raw message.
PATCH v2 2/7 exynos4-is: Add FIMC-IS ISP I2C bus driver
In reply to Sylwester NawrockiThis patch adds the ISP I2C bus controller driver files.
Creating a standard I2C bus adapter, even if the driver doesn't actually communicates with the hardware and it is instead used by the ISP firmware running on the Cortex-A5, allows to use standard hardware description in the device tree. As the sensor would have actually had a standard V4L2 sub-device driver run on the host CPU.
This approach allows to adapt the driver with a relatively small effort should the Imaging Subsystem architecture change so that the I2C bus is controlled by the host CPU, rather than the internal FIMC-IS ARM CPU. The image sensor drivers can be standard I2C client driver, as in case of most existing image sensor driver.
--- drivers/media/platform/exynos4-is/fimc-is-i2c.c | 81 +++++++++++++++++++++++ drivers/media/platform/exynos4-is/fimc-is-i2c.h | 15 +++++ 2 files changed, 96 insertions(+) create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.h
drivers/media/platform/exynos4-is/fimc-is-i2c.c new file +81 -0
@@ -0,0 +1,81 @@ +/* +* Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver +* +* Copyright (C) 2013 Samsung Electronics Co., Ltd. +* Sylwester Nawrocki <[email protected]> +* +* 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. +*/ +#define pr_fmt (fmt) "%s:%d " fmt, __func__, __LINE__ + +#include <linux/module.h> +#include <linux/of_i2c.h> +#include <linux/platform_device.h> +#include "fimc-is-i2c.h" + +/* +* An empty algorithm is used as the actual I2C bus controller driver +* is implemented in the FIMC-IS subsystem firmware and the host CPU +* doesn't touch the hardware. +*/ +static const struct i2c_algorithm fimc_is_i2c_algorithm; + +static int fimc_is_i2c_probe (struct platform_device *pdev) +{ +struct device_node *node = pdev->dev.of_node; +struct i2c_adapter *i2c_adap; +int ret; + + i2c_adap =devm_kzalloc (&pdev->dev,sizeof (*i2c_adap),GFP_KERNEL ); + + i2c_adap->dev.of_node = node; + i2c_adap->dev.parent = &pdev->dev; +strlcpy (i2c_adap->name,"exynos4x12-is-i2c" ,sizeof (i2c_adap->name)); + i2c_adap->owner =THIS_MODULE ; + i2c_adap->algo = &fimc_is_i2c_algorithm; + i2c_adap->class =I2C_CLASS_SPD ; + + ret =i2c_add_adapter (i2c_adap); +if (ret <0 ) { +dev_err (&pdev->dev,"failed to add I2C bus %s\n" , + node->full_name); +return ret; + } +of_i2c_register_devices (i2c_adap); + +return 0 ; +} + +static int fimc_is_i2c_remove (struct platform_device *pdev) +{ +return 0 ; +} + +static const struct of_device_id fimc_is_i2c_of_match[] = { + { .compatible =FIMC_IS_I2C_COMPATIBLE }, + { }, +}; +MODULE_DEVICE_TABLE (of, fimc_is_i2c_of_match); + +static struct platform_driver fimc_is_i2c_driver = { + .probe = fimc_is_i2c_probe, + .remove = fimc_is_i2c_remove, + .driver = { + .of_match_table = fimc_is_i2c_of_match, + .name ="fimc-is-i2c" , + .owner =THIS_MODULE , + } +}; + +int fimc_is_register_i2c_driver (void ) +{ +return platform_driver_register (&fimc_is_i2c_driver); +} + +void fimc_is_unregister_i2c_driver (void ) +{ +platform_driver_unregister (&fimc_is_i2c_driver); +} +
drivers/media/platform/exynos4-is/fimc-is-i2c.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver +* +* Copyright (C) 2013 Samsung Electronics Co., Ltd. +* Sylwester Nawrocki <[email protected]> +* +* 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. +*/ + +#define FIMC_IS_I2C_COMPATIBLE "samsung,exynos4212-i2c-isp" + +int fimc_is_register_i2c_driver (void ); +void fimc_is_unregister_i2c_driver (void );
Signature · 1 line
1.7.9.5
PATCH v2 3/7 exynos4-is: Add FIMC-IS parameter region definitions
In reply to Sylwester NawrockiThis patch adds ISP processing parameters interface files.
--- drivers/media/platform/exynos4-is/fimc-is-param.c | 971 ++++++++++++++++++++ drivers/media/platform/exynos4-is/fimc-is-param.h | 1022 +++++++++++++++++++++ 2 files changed, 1993 insertions(+) create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.h
drivers/media/platform/exynos4-is/fimc-is-param.c new file +971 -0
@@ -0,0 +1,971 @@ +/* +* Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver +* +* Copyright (C) 2013 Samsung Electronics Co., Ltd. +* +* Authors: Younghwan Joo <[email protected]> +* Sylwester Nawrocki <[email protected]> +* +* 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. +*/ +#define pr_fmt (fmt) "%s:%d " fmt, __func__, __LINE__ + +#include <linux/bug.h> +#include <linux/device.h> +#include <linux/delay.h> +#include <linux/errno.h> +#include <linux/firmware.h> +#include <linux/gpio.h> +#include <plat/gpio-cfg.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/list.h> +#include <linux/module.h> +#include <linux/types.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> +#include <linux/slab.h> +#include <linux/videodev2.h> + +#include <media/v4l2-device.h> +#include <media/v4l2-ioctl.h> +#include <media/v4l2-mem2mem.h> +#include <media/videobuf2-core.h> +#include <media/videobuf2-dma-contig.h> + +#include "fimc-is.h" +#include "fimc-is-command.h" +#include "fimc-is-errno.h" +#include "fimc-is-param.h" +#include "fimc-is-regs.h" +#include "fimc-is-sensor.h" + +static void __hw_param_copy (void *dst,void *src) +{ +memcpy (dst, src,FIMC_IS_PARAM_MAX_SIZE ); +} + +void __fimc_is_hw_update_param_global_shotmode (struct fimc_is *is) +{ +struct param_global_shotmode *dst, *src; + + dst = &is->is_p_region->parameter.global.shotmode; + src = &is->cfg_param[is->scenario_id].global.shotmode; +__hw_param_copy (dst, src); +} + +void __fimc_is_hw_update_param_sensor_framerate (struct fimc_is *is) +{ +struct param_sensor_framerate *dst, *src; + + dst = &is->is_p_region->parameter.sensor.frame_rate; + src = &is->cfg_param[is->scenario_id].sensor.frame_rate; +__hw_param_copy (dst, src); +} + +int __fimc_is_hw_update_param (struct fimc_is *is,u32 offset) +{ +struct is_param_region *par = &is->is_p_region->parameter; +struct is_config_param *cfg = &is->cfg_param[is->scenario_id]; + +switch (offset) { +case PARAM_ISP_CONTROL : +__hw_param_copy (&par->isp.control, &cfg->isp.control); +break ; + +case PARAM_ISP_OTF_INPUT : +__hw_param_copy (&par->isp.otf_input, &cfg->isp.otf_input); +break ; + +case PARAM_ISP_DMA1_INPUT : +__hw_param_copy (&par->isp.dma1_input, &cfg->isp.dma1_input); +break ; + +case PARAM_ISP_DMA2_INPUT : +__hw_param_copy (&par->isp.dma2_input, &cfg->isp.dma2_input); +break ; + +case PARAM_ISP_AA : +__hw_param_copy (&par->isp.aa, &cfg->isp.aa); +break ; + +case PARAM_ISP_FLASH : +__hw_param_copy (&par->isp.flash, &cfg->isp.flash); +break ; + +case PARAM_ISP_AWB : +__hw_param_copy (&par->isp.awb, &cfg->isp.awb); +break ; + +case PARAM_ISP_IMAGE_EFFECT : +__hw_param_copy (&par->isp.effect, &cfg->isp.effect); +break ; + +case PARAM_ISP_ISO : +__hw_param_copy (&par->isp.iso, &cfg->isp.iso); +break ; + +case PARAM_ISP_ADJUST : +__hw_param_copy (&par->isp.adjust, &cfg->isp.adjust); +break ; + +case PARAM_ISP_METERING : +__hw_param_copy (&par->isp.metering, &cfg->isp.metering); +break ; + +case PARAM_ISP_AFC : +__hw_param_copy (&par->isp.afc, &cfg->isp.afc); +break ; + +case PARAM_ISP_OTF_OUTPUT : +__hw_param_copy (&par->isp.otf_output, &cfg->isp.otf_output); +break ; + +case PARAM_ISP_DMA1_OUTPUT : +__hw_param_copy (&par->isp.dma1_output, &cfg->isp.dma1_output); +break ; + +case PARAM_ISP_DMA2_OUTPUT : +__hw_param_copy (&par->isp.dma2_output, &cfg->isp.dma2_output); +break ; + +case PARAM_DRC_CONTROL : +__hw_param_copy (&par->drc.control, &cfg->drc.control); +break ; + +case PARAM_DRC_OTF_INPUT : +__hw_param_copy (&par->drc.otf_input, &cfg->drc.otf_input); +break ; + +case PARAM_DRC_DMA_INPUT : +__hw_param_copy (&par->drc.dma_input, &cfg->drc.dma_input); +break ; + +case PARAM_DRC_OTF_OUTPUT : +__hw_param_copy (&par->drc.otf_output, &cfg->drc.otf_output); +break ; + +case PARAM_FD_CONTROL : +__hw_param_copy (&par->fd.control, &cfg->fd.control); +break ; + +case PARAM_FD_OTF_INPUT : +__hw_param_copy (&par->fd.otf_input, &cfg->fd.otf_input); +break ; + +case PARAM_FD_DMA_INPUT : +__hw_param_copy (&par->fd.dma_input, &cfg->fd.dma_input); +break ; + +case PARAM_FD_CONFIG : +__hw_param_copy (&par->fd.config, &cfg->fd.config); +break ; + +default : +return -EINVAL ; + } + +return 0 ; +} + +int __is_hw_update_params (struct fimc_is *is) +{ +unsigned long *p_index1, *p_index2; +int i, id, ret =0 ; + + id = is->scenario_id; + p_index1 = &is->cfg_param[id].p_region_index1; + p_index2 = &is->cfg_param[id].p_region_index2; + +if (test_bit (PARAM_GLOBAL_SHOTMODE , p_index1)) +__fimc_is_hw_update_param_global_shotmode (is); + +if (test_bit (PARAM_SENSOR_FRAME_RATE , p_index1)) +__fimc_is_hw_update_param_sensor_framerate (is); + +for (i =PARAM_ISP_CONTROL ; i <PARAM_DRC_CONTROL ; i++) { +if (test_bit (i, p_index1)) + ret =__fimc_is_hw_update_param (is, i); + } + +for (i =PARAM_DRC_CONTROL ; i <PARAM_SCALERC_CONTROL ; i++) { +if (test_bit (i, p_index1)) + ret =__fimc_is_hw_update_param (is, i); + } + +for (i =PARAM_FD_CONTROL ; i <=PARAM_FD_CONFIG ; i++) { +if (test_bit ((i -32 ), p_index2)) + ret =__fimc_is_hw_update_param (is, i); + } + +return ret; +} + +void __is_get_frame_size (struct fimc_is *is,struct v4l2_mbus_framefmt *mf) +{ +struct isp_param *isp; + + isp = &is->cfg_param[is->scenario_id].isp; + mf->width = isp->otf_input.width; + mf->height = isp->otf_input.height; +} + +void __is_set_frame_size (struct fimc_is *is,struct v4l2_mbus_framefmt *mf) +{ +struct isp_param *isp; +struct drc_param *drc; +struct fd_param *fd; +unsigned int mode; + + mode = is->scenario_id; + isp = &is->cfg_param[mode].isp; + drc = &is->cfg_param[mode].drc; + fd = &is->cfg_param[mode].fd; + +/* Update isp size info (OTF only) */ + isp->otf_input.width = mf->width; + isp->otf_input.height = mf->height; + isp->otf_output.width = mf->width; + isp->otf_output.height = mf->height; +/* Update drc size info (OTF only) */ + drc->otf_input.width = mf->width; + drc->otf_input.height = mf->height; + drc->otf_output.width = mf->width; + drc->otf_output.height = mf->height; +/* Update fd size info (OTF only) */ + fd->otf_input.width = mf->width; + fd->otf_input.height = mf->height; + +if (test_bit (PARAM_ISP_OTF_INPUT , + &is->cfg_param[mode].p_region_index1)) +return ; + +/* Update field */ +fimc_is_set_param_bit (is,PARAM_ISP_OTF_INPUT ); +fimc_is_inc_param_num (is); +fimc_is_set_param_bit (is,PARAM_ISP_OTF_OUTPUT ); +fimc_is_inc_param_num (is); +fimc_is_set_param_bit (is,PARAM_DRC_OTF_INPUT ); +fimc_is_inc_param_num (is); +fimc_is_set_param_bit (is,PARAM_DRC_OTF_OUTPUT ); +fimc_is_inc_param_num (is); +fimc_is_set_param_bit (is,PARAM_FD_OTF_INPUT ); +fimc_is_inc_param_num (is); +} + +int fimc_is_hw_get_sensor_max_framerate (struct fimc_is *is) +{ +switch (is->sensor->drvdata->id) { +case FIMC_IS_SENSOR_ID_S5K6A3 : +return 30 ; +default : +return 15 ; + } +} + +void __is_set_sensor (struct fimc_is *is,int fps) +{ +struct sensor_param *sensor; +struct isp_param *isp; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index1; + sensor = &is->cfg_param[mode].sensor; + isp = &is->cfg_param[mode].isp; + +if (fps ==0 ) { + sensor->frame_rate.frame_rate = +fimc_is_hw_get_sensor_max_framerate (is); + isp->otf_input.frametime_min =0 ; + isp->otf_input.frametime_max =66666 ; + }else { + sensor->frame_rate.frame_rate = fps; + isp->otf_input.frametime_min =0 ; + isp->otf_input.frametime_max = (u32 )1000000 / fps; + } + +if (!test_bit (PARAM_SENSOR_FRAME_RATE , p_index)) { +fimc_is_set_param_bit (is,PARAM_SENSOR_FRAME_RATE ); +fimc_is_inc_param_num (is); + } +if (!test_bit (PARAM_ISP_OTF_INPUT , p_index)) { +fimc_is_set_param_bit (is,PARAM_ISP_OTF_INPUT ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_init_isp_aa (struct fimc_is *is) +{ +struct isp_param *isp; + + isp = &is->cfg_param[is->scenario_id].isp; + + isp->aa.cmd =ISP_AA_COMMAND_START ; + isp->aa.target =ISP_AA_TARGET_AF |ISP_AA_TARGET_AE | +ISP_AA_TARGET_AWB ; + isp->aa.mode =0 ; + isp->aa.scene =0 ; + isp->aa.sleep =0 ; + isp->aa.face =0 ; + isp->aa.touch_x =0 ; + isp->aa.touch_y =0 ; + isp->aa.manual_af_setting =0 ; + isp->aa.err =ISP_AF_ERROR_NONE ; + +fimc_is_set_param_bit (is,PARAM_ISP_AA ); +fimc_is_inc_param_num (is); +} + +#define get_is_cfg (is, mode) (&(is)->cfg_param[mode]) + +void __is_set_isp_flash (struct fimc_is *is,u32 cmd,u32 redeye) +{ +struct is_config_param *cfg; +struct isp_param *isp; +unsigned int mode; + + mode = is->scenario_id; + cfg =get_is_cfg (is, mode); + + isp = &is->cfg_param[mode].isp; + isp->flash.cmd = cmd; + isp->flash.redeye = redeye; + isp->flash.err =ISP_FLASH_ERROR_NONE ; + +if (!test_bit (PARAM_ISP_FLASH , &cfg->p_region_index1)) { +fimc_is_set_param_bit (is,PARAM_ISP_FLASH ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_isp_awb (struct fimc_is *is,u32 cmd,u32 val) +{ +struct isp_param *isp; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index1; + isp = &is->cfg_param[mode].isp; + + isp->awb.cmd = cmd; + isp->awb.illumination = val; + isp->awb.err =ISP_AWB_ERROR_NONE ; + +if (!test_bit (PARAM_ISP_AWB , p_index)) { +fimc_is_set_param_bit (is,PARAM_ISP_AWB ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_isp_effect (struct fimc_is *is,u32 cmd) +{ +struct isp_param *isp; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index1; + isp = &is->cfg_param[mode].isp; + + isp->effect.cmd = cmd; + isp->effect.err =ISP_IMAGE_EFFECT_ERROR_NONE ; + +if (!test_bit (PARAM_ISP_IMAGE_EFFECT , p_index)) { +fimc_is_set_param_bit (is,PARAM_ISP_IMAGE_EFFECT ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_isp_iso (struct fimc_is *is,u32 cmd,u32 val) +{ +struct isp_param *isp; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index1; + isp = &is->cfg_param[mode].isp; + + isp->iso.cmd = cmd; + isp->iso.value = val; + isp->iso.err =ISP_ISO_ERROR_NONE ; + +if (!test_bit (PARAM_ISP_ISO , p_index)) { +fimc_is_set_param_bit (is,PARAM_ISP_ISO ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_isp_adjust (struct fimc_is *is,u32 cmd,u32 val) +{ +unsigned int mode = is->scenario_id; +unsigned long *p_index; +struct isp_param *isp; + + p_index = &is->cfg_param[mode].p_region_index1; + isp = &is->cfg_param[mode].isp; + +switch (cmd) { +case ISP_ADJUST_COMMAND_MANUAL_CONTRAST : + isp->adjust.contrast = val; +break ; +case ISP_ADJUST_COMMAND_MANUAL_SATURATION : + isp->adjust.saturation = val; +break ; +case ISP_ADJUST_COMMAND_MANUAL_SHARPNESS : + isp->adjust.sharpness = val; +break ; +case ISP_ADJUST_COMMAND_MANUAL_EXPOSURE : + isp->adjust.exposure = val; +break ; +case ISP_ADJUST_COMMAND_MANUAL_BRIGHTNESS : + isp->adjust.brightness = val; +break ; +case ISP_ADJUST_COMMAND_MANUAL_HUE : + isp->adjust.hue = val; +break ; +case ISP_ADJUST_COMMAND_AUTO : + isp->adjust.contrast =0 ; + isp->adjust.saturation =0 ; + isp->adjust.sharpness =0 ; + isp->adjust.exposure =0 ; + isp->adjust.brightness =0 ; + isp->adjust.hue =0 ; +break ; + } + +if (!test_bit (PARAM_ISP_ADJUST , p_index)) { + isp->adjust.cmd = cmd; + isp->adjust.err =ISP_ADJUST_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_ISP_ADJUST ); +fimc_is_inc_param_num (is); + }else { + isp->adjust.cmd |= cmd; + } +} + +void __is_set_isp_metering (struct fimc_is *is,u32 id,u32 val) +{ +struct isp_param *isp; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index1; + isp = &is->cfg_param[mode].isp; + +switch (id) { +case IS_METERING_CONFIG_CMD : + isp->metering.cmd = val; +break ; +case IS_METERING_CONFIG_WIN_POS_X : + isp->metering.win_pos_x = val; +break ; +case IS_METERING_CONFIG_WIN_POS_Y : + isp->metering.win_pos_y = val; +break ; +case IS_METERING_CONFIG_WIN_WIDTH : + isp->metering.win_width = val; +break ; +case IS_METERING_CONFIG_WIN_HEIGHT : + isp->metering.win_height = val; +break ; +default : +return ; + } + +if (!test_bit (PARAM_ISP_METERING , p_index)) { + isp->metering.err =ISP_METERING_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_ISP_METERING ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_isp_afc (struct fimc_is *is,u32 cmd,u32 val) +{ +struct isp_param *isp; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index1; + isp = &is->cfg_param[mode].isp; + + isp->afc.cmd = cmd; + isp->afc.manual = val; + isp->afc.err =ISP_AFC_ERROR_NONE ; + +if (!test_bit (PARAM_ISP_AFC , p_index)) { +fimc_is_set_param_bit (is,PARAM_ISP_AFC ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_drc_control (struct fimc_is *is,u32 val) +{ +struct drc_param *drc; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index1; + drc = &is->cfg_param[mode].drc; + + drc->control.bypass = val; + +if (!test_bit (PARAM_DRC_CONTROL , p_index)) { +fimc_is_set_param_bit (is,PARAM_DRC_CONTROL ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_fd_control (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->control.cmd = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { +fimc_is_set_param_bit (is,PARAM_FD_CONTROL ); +fimc_is_inc_param_num (is); + } +} + +void __is_set_fd_config_maxface (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.max_number = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_MAXIMUM_NUMBER ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_MAXIMUM_NUMBER ; + } +} + +void __is_set_fd_config_rollangle (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.roll_angle = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_ROLL_ANGLE ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_ROLL_ANGLE ; + } +} + +void __is_set_fd_config_yawangle (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.yaw_angle = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_YAW_ANGLE ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_YAW_ANGLE ; + } +} + +void __is_set_fd_config_smilemode (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.smile_mode = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_SMILE_MODE ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_SMILE_MODE ; + } +} + +void __is_set_fd_config_blinkmode (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.blink_mode = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_BLINK_MODE ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_BLINK_MODE ; + } +} + +void __is_set_fd_config_eyedetect (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.eye_detect = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_EYES_DETECT ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_EYES_DETECT ; + } +} + +void __is_set_fd_config_mouthdetect (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.mouth_detect = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_MOUTH_DETECT ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_MOUTH_DETECT ; + } +} + +void __is_set_fd_config_orientation (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.orientation = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_ORIENTATION ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_ORIENTATION ; + } +} + +void __is_set_fd_config_orientation_val (struct fimc_is *is,u32 val) +{ +struct fd_param *fd; +unsigned long *p_index, mode; + + mode = is->scenario_id; + p_index = &is->cfg_param[mode].p_region_index2; + fd = &is->cfg_param[mode].fd; + + fd->config.orientation_value = val; + +if (!test_bit ((PARAM_FD_CONFIG -32 ), p_index)) { + fd->config.cmd =FD_CONFIG_COMMAND_ORIENTATION_VALUE ; + fd->config.err =ERROR_FD_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_CONFIG ); +fimc_is_inc_param_num (is); + }else { + fd->config.cmd |=FD_CONFIG_COMMAND_ORIENTATION_VALUE ; + } +} + +void fimc_is_set_initial_params (struct fimc_is *is) +{ +struct global_param *global; +struct sensor_param *sensor; +struct isp_param *isp; +struct drc_param *drc; +struct fd_param *fd; +unsigned long *p_index1, *p_index2; +unsigned int mode; + + mode = is->scenario_id; + global = &is->cfg_param[mode].global; + sensor = &is->cfg_param[mode].sensor; + isp = &is->cfg_param[mode].isp; + drc = &is->cfg_param[mode].drc; + fd = &is->cfg_param[mode].fd; + p_index1 = &is->cfg_param[mode].p_region_index1; + p_index2 = &is->cfg_param[mode].p_region_index2; + +/* Global */ + global->shotmode.cmd =1 ; +fimc_is_set_param_bit (is,PARAM_GLOBAL_SHOTMODE ); +fimc_is_inc_param_num (is); + +/* ISP */ + isp->control.cmd =CONTROL_COMMAND_START ; + isp->control.bypass =CONTROL_BYPASS_DISABLE ; + isp->control.err =CONTROL_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_ISP_CONTROL ); +fimc_is_inc_param_num (is); + + isp->otf_input.cmd =OTF_INPUT_COMMAND_ENABLE ; +if (!test_bit (PARAM_ISP_OTF_INPUT , p_index1)) { + isp->otf_input.width =DEFAULT_PREVIEW_STILL_WIDTH ; + isp->otf_input.height =DEFAULT_PREVIEW_STILL_HEIGHT ; +fimc_is_set_param_bit (is,PARAM_ISP_OTF_INPUT ); +fimc_is_inc_param_num (is); + } +if (is->sensor->test_pattern) + isp->otf_input.format =OTF_INPUT_FORMAT_STRGEN_COLORBAR_BAYER ; +else + isp->otf_input.format =OTF_INPUT_FORMAT_BAYER ; + isp->otf_input.bitwidth =10 ; + isp->otf_input.order =OTF_INPUT_ORDER_BAYER_GR_BG ; + isp->otf_input.crop_offset_x =0 ; + isp->otf_input.crop_offset_y =0 ; + isp->otf_input.err =OTF_INPUT_ERROR_NONE ; + + isp->dma1_input.cmd =DMA_INPUT_COMMAND_DISABLE ; + isp->dma1_input.width =0 ; + isp->dma1_input.height =0 ; + isp->dma1_input.format =0 ; + isp->dma1_input.bitwidth =0 ; + isp->dma1_input.plane =0 ; + isp->dma1_input.order =0 ; + isp->dma1_input.buffer_number =0 ; + isp->dma1_input.width =0 ; + isp->dma1_input.err =DMA_INPUT_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_ISP_DMA1_INPUT ); +fimc_is_inc_param_num (is); + + isp->dma2_input.cmd =DMA_INPUT_COMMAND_DISABLE ; + isp->dma2_input.width =0 ; + isp->dma2_input.height =0 ; + isp->dma2_input.format =0 ; + isp->dma2_input.bitwidth =0 ; + isp->dma2_input.plane =0 ; + isp->dma2_input.order =0 ; + isp->dma2_input.buffer_number =0 ; + isp->dma2_input.width =0 ; + isp->dma2_input.err =DMA_INPUT_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_ISP_DMA2_INPUT ); +fimc_is_inc_param_num (is); + + isp->aa.cmd =ISP_AA_COMMAND_START ; + isp->aa.target =ISP_AA_TARGET_AE |ISP_AA_TARGET_AWB ; +fimc_is_set_param_bit (is,PARAM_ISP_AA ); +fimc_is_inc_param_num (is); + +if (!test_bit (PARAM_ISP_FLASH , p_index1)) +__is_set_isp_flash (is,ISP_FLASH_COMMAND_DISABLE , +ISP_FLASH_REDEYE_DISABLE ); + +if (!test_bit (PARAM_ISP_AWB , p_index1)) +__is_set_isp_awb (is,ISP_AWB_COMMAND_AUTO ,0 ); + +if (!test_bit (PARAM_ISP_IMAGE_EFFECT , p_index1)) +__is_set_isp_effect (is,ISP_IMAGE_EFFECT_DISABLE ); + +if (!test_bit (PARAM_ISP_ISO , p_index1)) +__is_set_isp_iso (is,ISP_ISO_COMMAND_AUTO ,0 ); + +if (!test_bit (PARAM_ISP_ADJUST , p_index1)) { +__is_set_isp_adjust (is,ISP_ADJUST_COMMAND_MANUAL_CONTRAST ,0 ); +__is_set_isp_adjust (is, +ISP_ADJUST_COMMAND_MANUAL_SATURATION ,0 ); +__is_set_isp_adjust (is,ISP_ADJUST_COMMAND_MANUAL_SHARPNESS ,0 ); +__is_set_isp_adjust (is,ISP_ADJUST_COMMAND_MANUAL_EXPOSURE ,0 ); +__is_set_isp_adjust (is, +ISP_ADJUST_COMMAND_MANUAL_BRIGHTNESS ,0 ); +__is_set_isp_adjust (is,ISP_ADJUST_COMMAND_MANUAL_HUE ,0 ); + } + +if (!test_bit (PARAM_ISP_METERING , p_index1)) { +__is_set_isp_metering (is,0 ,ISP_METERING_COMMAND_CENTER ); +__is_set_isp_metering (is,1 ,0 ); +__is_set_isp_metering (is,2 ,0 ); +__is_set_isp_metering (is,3 ,0 ); +__is_set_isp_metering (is,4 ,0 ); + } + +if (!test_bit (PARAM_ISP_AFC , p_index1)) +__is_set_isp_afc (is,ISP_AFC_COMMAND_AUTO ,0 ); + + isp->otf_output.cmd =OTF_OUTPUT_COMMAND_ENABLE ; +if (!test_bit (PARAM_ISP_OTF_OUTPUT , p_index1)) { + isp->otf_output.width =DEFAULT_PREVIEW_STILL_WIDTH ; + isp->otf_output.height =DEFAULT_PREVIEW_STILL_HEIGHT ; +fimc_is_set_param_bit (is,PARAM_ISP_OTF_OUTPUT ); +fimc_is_inc_param_num (is); + } + isp->otf_output.format =OTF_OUTPUT_FORMAT_YUV444 ; + isp->otf_output.bitwidth =12 ; + isp->otf_output.order =0 ; + isp->otf_output.err =OTF_OUTPUT_ERROR_NONE ; + +if (!test_bit (PARAM_ISP_DMA1_OUTPUT , p_index1)) { + isp->dma1_output.cmd =DMA_OUTPUT_COMMAND_DISABLE ; + isp->dma1_output.width =0 ; + isp->dma1_output.height =0 ; + isp->dma1_output.format =0 ; + isp->dma1_output.bitwidth =0 ; + isp->dma1_output.plane =0 ; + isp->dma1_output.order =0 ; + isp->dma1_output.buffer_number =0 ; + isp->dma1_output.buffer_address =0 ; + isp->dma1_output.notify_dma_done =0 ; + isp->dma1_output.dma_out_mask =0 ; + isp->dma1_output.err =DMA_OUTPUT_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_ISP_DMA1_OUTPUT ); +fimc_is_inc_param_num (is); + } + +if (!test_bit (PARAM_ISP_DMA2_OUTPUT , p_index1)) { + isp->dma2_output.cmd =DMA_OUTPUT_COMMAND_DISABLE ; + isp->dma2_output.width =0 ; + isp->dma2_output.height =0 ; + isp->dma2_output.format =0 ; + isp->dma2_output.bitwidth =0 ; + isp->dma2_output.plane =0 ; + isp->dma2_output.order =0 ; + isp->dma2_output.buffer_number =0 ; + isp->dma2_output.buffer_address =0 ; + isp->dma2_output.notify_dma_done =0 ; + isp->dma2_output.dma_out_mask =0 ; + isp->dma2_output.err =DMA_OUTPUT_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_ISP_DMA2_OUTPUT ); +fimc_is_inc_param_num (is); + } + +/* Sensor */ +if (!test_bit (PARAM_SENSOR_FRAME_RATE , p_index1)) { +if (!mode) +__is_set_sensor (is,0 ); + } + +/* DRC */ + drc->control.cmd =CONTROL_COMMAND_START ; +__is_set_drc_control (is,CONTROL_BYPASS_ENABLE ); + + drc->otf_input.cmd =OTF_INPUT_COMMAND_ENABLE ; +if (!test_bit (PARAM_DRC_OTF_INPUT , p_index1)) { + drc->otf_input.width =DEFAULT_PREVIEW_STILL_WIDTH ; + drc->otf_input.height =DEFAULT_PREVIEW_STILL_HEIGHT ; +fimc_is_set_param_bit (is,PARAM_DRC_OTF_INPUT ); +fimc_is_inc_param_num (is); + } + drc->otf_input.format =OTF_INPUT_FORMAT_YUV444 ; + drc->otf_input.bitwidth =12 ; + drc->otf_input.order =0 ; + drc->otf_input.err =OTF_INPUT_ERROR_NONE ; + + drc->dma_input.cmd =DMA_INPUT_COMMAND_DISABLE ; + drc->dma_input.width =0 ; + drc->dma_input.height =0 ; + drc->dma_input.format =0 ; + drc->dma_input.bitwidth =0 ; + drc->dma_input.plane =0 ; + drc->dma_input.order =0 ; + drc->dma_input.buffer_number =0 ; + drc->dma_input.width =0 ; + drc->dma_input.err =DMA_INPUT_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_DRC_DMA_INPUT ); +fimc_is_inc_param_num (is); + + drc->otf_output.cmd =OTF_OUTPUT_COMMAND_ENABLE ; +if (!test_bit (PARAM_DRC_OTF_OUTPUT , p_index1)) { + drc->otf_output.width =DEFAULT_PREVIEW_STILL_WIDTH ; + drc->otf_output.height =DEFAULT_PREVIEW_STILL_HEIGHT ; +fimc_is_set_param_bit (is,PARAM_DRC_OTF_OUTPUT ); +fimc_is_inc_param_num (is); + } + drc->otf_output.format =OTF_OUTPUT_FORMAT_YUV444 ; + drc->otf_output.bitwidth =8 ; + drc->otf_output.order =0 ; + drc->otf_output.err =OTF_OUTPUT_ERROR_NONE ; + +/* FD */ +__is_set_fd_control (is,CONTROL_COMMAND_STOP ); + fd->control.bypass =CONTROL_BYPASS_DISABLE ; + + fd->otf_input.cmd =OTF_INPUT_COMMAND_ENABLE ; +if (!test_bit ((PARAM_FD_OTF_INPUT -32 ), p_index2)) { + fd->otf_input.width =DEFAULT_PREVIEW_STILL_WIDTH ; + fd->otf_input.height =DEFAULT_PREVIEW_STILL_HEIGHT ; +fimc_is_set_param_bit (is,PARAM_FD_OTF_INPUT ); +fimc_is_inc_param_num (is); + } + fd->otf_input.format =OTF_INPUT_FORMAT_YUV444 ; + fd->otf_input.bitwidth =8 ; + fd->otf_input.order =0 ; + fd->otf_input.err =OTF_INPUT_ERROR_NONE ; + + fd->dma_input.cmd =DMA_INPUT_COMMAND_DISABLE ; + fd->dma_input.width =0 ; + fd->dma_input.height =0 ; + fd->dma_input.format =0 ; + fd->dma_input.bitwidth =0 ; + fd->dma_input.plane =0 ; + fd->dma_input.order =0 ; + fd->dma_input.buffer_number =0 ; + fd->dma_input.width =0 ; + fd->dma_input.err =DMA_INPUT_ERROR_NONE ; +fimc_is_set_param_bit (is,PARAM_FD_DMA_INPUT ); +fimc_is_inc_param_num (is); + +__is_set_fd_config_maxface (is,5 ); +__is_set_fd_config_rollangle (is,FD_CONFIG_ROLL_ANGLE_FULL ); +__is_set_fd_config_yawangle (is,FD_CONFIG_YAW_ANGLE_45_90 ); +__is_set_fd_config_smilemode (is,FD_CONFIG_SMILE_MODE_DISABLE ); +__is_set_fd_config_blinkmode (is,FD_CONFIG_BLINK_MODE_DISABLE ); +__is_set_fd_config_eyedetect (is,FD_CONFIG_EYES_DETECT_ENABLE ); +__is_set_fd_config_mouthdetect (is,FD_CONFIG_MOUTH_DETECT_DISABLE ); +__is_set_fd_config_orientation (is,FD_CONFIG_ORIENTATION_DISABLE ); +__is_set_fd_config_orientation_val (is,0 ); +}
drivers/media/platform/exynos4-is/fimc-is-param.h new file +1022 -0
1,022 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 4/7 exynos4-is: Add common FIMC-IS image sensor driver
In reply to Sylwester NawrockiThis patch adds a common image sensor driver and Makefile/Kconfig to enable cpmpilation of the whole IS drives.
The sensor subdev driver currently only handles an image sensor's power supplies and reset signal. There is no an I2C communication as it is handled by the ISP's firmware.
--- drivers/media/platform/exynos4-is/Kconfig | 13 + drivers/media/platform/exynos4-is/Makefile | 3 + drivers/media/platform/exynos4-is/fimc-is-sensor.c | 307 ++++++++++++++++++++ drivers/media/platform/exynos4-is/fimc-is-sensor.h | 80 +++++ 4 files changed, 403 insertions(+) create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.c create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.h
drivers/media/platform/exynos4-is/Kconfig +13 -0
@@ -47,4 +47,17 @@ config VIDEO_EXYNOS_FIMC_LITE module will be called exynos-fimc-lite. endif +if (SOC_EXYNOS4212 || SOC_EXYNOS4412) && OF && !ARCH_MULTIPLATFORM + +config VIDEO_EXYNOS4_FIMC_IS + tristate "EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver" + select VIDEOBUF2_DMA_CONTIG + help + This is a V4L2 driver for Samsung EXYNOS4x12 SoC series + FIMC-IS (Imaging Subsystem). + + To compile this driver as a module, choose M here: the + module will be called exynos4-fimc-is. +endif + endif # VIDEO_SAMSUNG_S5P_FIMC
drivers/media/platform/exynos4-is/Makefile +3 -0
@@ -1,7 +1,10 @@ s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-m2m.o fimc-capture.o media-dev.o exynos-fimc-lite-objs += fimc-lite-reg.o fimc-lite.o +exynos-fimc-is-objs := fimc-is.o fimc-isp.o fimc-is-sensor.o fimc-is-regs.o +exynos-fimc-is-objs += fimc-is-param.o fimc-is-errno.o fimc-is-i2c.o s5p-csis-objs := mipi-csis.o obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS) += s5p-csis.o obj-$(CONFIG_VIDEO_EXYNOS_FIMC_LITE) += exynos-fimc-lite.o +obj-$(CONFIG_VIDEO_EXYNOS4_FIMC_IS) += exynos-fimc-is.o obj-$(CONFIG_VIDEO_S5P_FIMC) += s5p-fimc.o
drivers/media/platform/exynos4-is/fimc-is-sensor.c new file +307 -0
307 lines not on this page · raw message
drivers/media/platform/exynos4-is/fimc-is-sensor.h new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 5/7 exynos4-is: Add Exynos4x12 FIMC-IS device tree bindings documentation
In reply to Sylwester Nawrocki--- .../devicetree/bindings/media/exynos4-fimc-is.txt | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
Documentation/devicetree/bindings/media/exynos4-fimc-is.txt new file +45 -0
@@ -0,0 +1,45 @@ +Exynos4x12 SoC series Imaging Subsystem (FIMC-IS) + +The FIMC-IS is a subsystem for processing image signal from an image sensor. +The Exynos4x12 SoC series FIMC-IS V1.5 comprises of a dedicated ARM Cortex-A5 +processor, ISP, DRC and FD IP blocks and peripheral devices such as UART, I2C +and SPI bus controllers, PWM and ADC. + +fimc-is node +------------ + +Required properties: + +- compatible : should be "samsung,exynos4212-fimc-is" for Exynos4212 and + Exynos4412 SoCs; +- reg : physical base address and size of the device memory mapped + registers; +- interrupts : should contain FIMC-IS interrupts; +- clocks : list of clock specifiers, corresponding to entries in + clock-names property; +- clock-names : must contain "ppmuispx", "ppmuispx", "flite0", "flite1" + entries, matching entries in the clocks property. + +pmu subnode +----------- + +Required properties: + - reg : should contain PMU physical base address and size of the memory + mapped registers, size should be 0x3000. + + +The following are the FIMC-IS peripheral device nodes and can be specified +either standalone or as the fimc-is node child nodes. + +i2c-isp (ISP I2C bus controller) nodes +------------------------------------------ + +Required properties: + +- compatible : should be "samsung,exynos4212-i2c-isp" for Exynos4212 and + Exynos4412 SoCs; +- reg : physical base address and size of the device memory mapped + registers; + +For the above nodes it is required to specify a pinctrl state named "default", +according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
Signature · 1 line
1.7.9.5
PATCH v2 6/7 s5p-fimc: Add fimc-is subdevs registration
In reply to Sylwester NawrockiThis patch allows to register FIMC-IS device represented by FIMC-IS-ISP subdev to the top level media device driver. The use_isp platform data structure field allows to select whether the fimc-is ISP subdev should be tried to be registered or not.
--- drivers/media/platform/exynos4-is/media-dev.c | 37 +++++++++++++++++++++++-- drivers/media/platform/exynos4-is/media-dev.h | 13 +++++++++ 2 files changed, 47 insertions(+), 3 deletions(-)
drivers/media/platform/exynos4-is/media-dev.c +34 -3
@@ -32,6 +32,7 @@#include "media-dev.h" #include "fimc-core.h" +#include "fimc-is.h" #include "fimc-lite.h" #include "mipi-csis.h"
@@ -85,9 +86,11 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,case GRP_ID_FIMC :/* No need to control FIMC subdev through subdev ops */ break ; +case GRP_ID_FIMC_IS : + p->subdevs[IDX_IS_ISP ] = sd; +break ;default : -pr_warn ("%s: Unknown subdev grp_id: %#x\n" , - __func__, sd->grp_id); +break ; } me = &sd->entity;if (me->num_pads ==1 )
@@ -322,6 +325,7 @@ static void fimc_md_unregister_sensor(struct v4l2_subdev *sd)if (!client)return ; +v4l2_device_unregister_subdev (sd);if (!client->dev.of_node) {
@@ -372,7 +376,11 @@ static int fimc_md_of_add_sensor(struct fimc_md *fmd, goto mod_put;v4l2_set_subdev_hostdata (sd, si); - sd->grp_id =GRP_ID_SENSOR ; +if (si->pdata.fimc_bus_type ==FIMC_BUS_TYPE_ISP_WRITEBACK ) + sd->grp_id =GRP_ID_FIMC_IS_SENSOR ; +else + sd->grp_id =GRP_ID_SENSOR ; + si->subdev = sd;v4l2_info (&fmd->v4l2_dev,"Registered sensor subdevice: %s (%d)\n" , sd->name, fmd->num_sensors);
@@ -650,6 +658,22 @@ static int register_csis_entity(struct fimc_md *fmd,return ret; } +static int register_fimc_is_entity (struct fimc_md *fmd,struct fimc_is *is) +{ +struct v4l2_subdev *sd = &is->isp.subdev; +int ret; + + ret =v4l2_device_register_subdev (&fmd->v4l2_dev, sd); +if (ret) { +v4l2_err (&fmd->v4l2_dev, +"Failed to register FIMC-ISP (%d)\n" , ret); +return ret; + } + + fmd->fimc_is = is; +return 0 ; +} +static int fimc_md_register_platform_entity (struct fimc_md *fmd,struct platform_device *pdev,int plat_entity)
@@ -677,6 +701,9 @@ static int fimc_md_register_platform_entity(struct fimc_md *fmd,case IDX_CSIS : ret =register_csis_entity (fmd, pdev, drvdata);break ; +case IDX_IS_ISP : + ret =register_fimc_is_entity (fmd, drvdata); +break ;default : ret = -ENODEV ; }
@@ -740,6 +767,8 @@ static int fimc_md_register_of_platform_entities(struct fimc_md *fmd,/* If driver of any entity isn't ready try all again later. */ if (!strcmp (node->name,CSIS_OF_NODE_NAME )) plat_entity =IDX_CSIS ; +else if (!strcmp (node->name,FIMC_IS_OF_NODE_NAME )) + plat_entity =IDX_IS_ISP ;else if (!strcmp (node->name,FIMC_LITE_OF_NODE_NAME )) plat_entity =IDX_FLITE ; else if (!strcmp(node->name, FIMC_OF_NODE_NAME) &&
@@ -1306,6 +1335,8 @@ static int fimc_md_probe(struct platform_device *pdev) v4l2_dev->notify = fimc_sensor_notify;strlcpy (v4l2_dev->name,"s5p-fimc-md" ,sizeof (v4l2_dev->name)); + fmd->use_isp =fimc_md_is_isp_available (dev->of_node); + ret =v4l2_device_register (dev, &fmd->v4l2_dev);if (ret <0 ) {v4l2_err (v4l2_dev,"Failed to register v4l2_device: %d\n" , ret);
drivers/media/platform/exynos4-is/media-dev.h +13 -0
@@ -12,6 +12,7 @@#include <linux/clk.h> #include <linux/platform_device.h> #include <linux/mutex.h> +#include <linux/of.h> #include <linux/pinctrl/consumer.h> #include <media/media-device.h> #include <media/media-entity.h>
@@ -80,6 +81,7 @@ struct fimc_sensor_info {* @num_sensors: actual number of registered sensors * @camclk: external sensor clock information * @fimc: array of registered fimc devices +* @fimc_is: fimc-is data structure * @use_isp: set to true when FIMC-IS subsystem is used * @pmf: handle to the CAMCLK clock control FIMC helper device * @media_dev: top level media device
@@ -99,6 +101,7 @@ struct fimc_md {struct clk *wbclk[FIMC_MAX_WBCLKS ];struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS ];struct fimc_dev *fimc[FIMC_MAX_DEVS ]; +struct fimc_is *fimc_is;bool use_isp;struct device *pmf;struct media_device media_dev;
@@ -139,4 +142,14 @@ static inline void fimc_md_graph_unlock(struct fimc_dev *fimc)int fimc_md_set_camclk (struct v4l2_subdev *sd,bool on); +#ifdef CONFIG_OF +static inline bool fimc_md_is_isp_available (struct device_node *node) +{ + node =of_get_child_by_name (node,FIMC_IS_OF_NODE_NAME ); +return node ?of_device_is_available (node) : false; +} +#else +#define fimc_md_is_isp_available (node) (false) +#endif /* CONFIG_OF */ +#endif
Signature · 1 line
1.7.9.5
PATCH v2 7/7 s5p-fimc: Create media links for the FIMC-IS entities
In reply to Sylwester NawrockiCreate disabled links from the FIMC-LITE subdevs to the FIMC-IS-ISP subdev and from FIMC-IS-ISP to all FIMC subdevs.
--- drivers/media/platform/exynos4-is/media-dev.c | 83 +++++++++++++++++++------ 1 file changed, 64 insertions(+), 19 deletions(-)
drivers/media/platform/exynos4-is/media-dev.c +64 -19
@@ -836,12 +836,19 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,struct v4l2_subdev *sensor, int pad, int link_mask) { - struct fimc_sensor_info *s_info = NULL; + struct fimc_sensor_info *si = NULL;struct media_entity *sink;unsigned int flags =0 ; -int ret, i; +int i, ret =0 ; -for (i =0 ; i <FIMC_MAX_DEVS ; i++) { +if (sensor) { + si =v4l2_get_subdev_hostdata (sensor); +/* Skip direct FIMC links in the logical FIMC-IS sensor path */ +if (si && si->pdata.fimc_bus_type ==FIMC_BUS_TYPE_ISP_WRITEBACK ) + ret =1 ; + } + +for (i =0 ; !ret && i <FIMC_MAX_DEVS ; i++) {if (!fmd->fimc[i])continue ;/*
@@ -870,11 +877,11 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,if (flags ==0 || sensor ==NULL )continue ; - s_info =v4l2_get_subdev_hostdata (sensor); -if (!WARN_ON (s_info ==NULL )) { + +if (!WARN_ON (si ==NULL )) {unsigned long irq_flags;spin_lock_irqsave (&fmd->slock, irq_flags); - s_info->host = fmd->fimc[i]; + si->host = fmd->fimc[i];spin_unlock_irqrestore (&fmd->slock, irq_flags); } }
@@ -883,25 +890,20 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,if (!fmd->fimc_lite[i])continue ; -if (link_mask & (1 << (i +FIMC_MAX_DEVS ))) - flags =MEDIA_LNK_FL_ENABLED ; -else - flags =0 ; - sink = &fmd->fimc_lite[i]->subdev.entity; ret =media_entity_create_link (source, pad, sink, -FLITE_SD_PAD_SINK , flags); +FLITE_SD_PAD_SINK ,0 );if (ret)return ret;/* Notify FIMC-LITE subdev entity */ ret =media_entity_call (sink, link_setup, &sink->pads[0 ], - &source->pads[pad], flags); + &source->pads[pad],0 );if (ret)break ; -v4l2_info (&fmd->v4l2_dev,"created link [%s] %c> [%s]\n" , - source->name, flags ?'=' :'-' , sink->name); +v4l2_info (&fmd->v4l2_dev,"created link [%s] -> [%s]\n" , + source->name, sink->name); }return 0 ; }
@@ -910,26 +912,59 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,static int __fimc_md_create_flite_source_links (struct fimc_md *fmd) {struct media_entity *source, *sink; -unsigned int flags =MEDIA_LNK_FL_ENABLED ;int i, ret =0 ;for (i =0 ; i <FIMC_LITE_MAX_DEVS ; i++) {struct fimc_lite *fimc = fmd->fimc_lite[i]; +if (fimc ==NULL )continue ; + source = &fimc->subdev.entity; sink = &fimc->vfd.entity;/* FIMC-LITE's subdev and video node */ ret =media_entity_create_link (source,FLITE_SD_PAD_SOURCE_DMA , - sink,0 , flags); + sink,0 ,0 ); +if (ret) +break ; +/* Link from FIMC-LITE to IS-ISP subdev */ + sink = &fmd->fimc_is->isp.subdev.entity; + ret =media_entity_create_link (source,FLITE_SD_PAD_SOURCE_ISP , + sink,0 ,0 );if (ret)break ; -/* TODO: create links to other entities */ }return ret; } +/* Create FIMC-IS links */ +static int __fimc_md_create_fimc_is_links (struct fimc_md *fmd) +{ +struct media_entity *source, *sink; +int i, ret; + + source = &fmd->fimc_is->isp.subdev.entity; + +for (i =0 ; i <FIMC_MAX_DEVS ; i++) { +if (fmd->fimc[i] ==NULL ) +continue ; + +/* Link from IS-ISP subdev to FIMC */ + sink = &fmd->fimc[i]->vid_cap.subdev.entity; + ret =media_entity_create_link (source,FIMC_ISP_SD_PAD_SRC_FIFO , + sink,FIMC_SD_PAD_SINK_FIFO ,0 ); +if (ret) +return ret; + } + +/* Link from IS-ISP subdev to is.isp capture video node */ + sink = &fmd->fimc_is->isp.video_capture.vdev.entity; + ret =media_entity_create_link (source,FIMC_ISP_SD_PAD_SRC_DMA , + sink,0 ,0 ); +return ret; +} +/** * fimc_md_create_links - create default links between registered entities *
@@ -1012,6 +1047,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)for (i =0 ; i <CSIS_MAX_ENTITIES ; i++) {if (fmd->csis[i].sd ==NULL )continue ; + source = &fmd->csis[i].sd->entity; pad =CSIS_PAD_SOURCE ; sensor = csi_sensors[i];
@@ -1026,15 +1062,24 @@ static int fimc_md_create_links(struct fimc_md *fmd)for (i =0 ; i <FIMC_MAX_DEVS ; i++) {if (!fmd->fimc[i])continue ; + source = &fmd->fimc[i]->vid_cap.subdev.entity; sink = &fmd->fimc[i]->vid_cap.vfd.entity; + ret =media_entity_create_link (source,FIMC_SD_PAD_SOURCE , sink,0 , flags);if (ret)break ; } -return __fimc_md_create_flite_source_links (fmd); + ret =__fimc_md_create_flite_source_links (fmd); +if (ret <0 ) +return ret; + +if (fmd->use_isp) + ret =__fimc_md_create_fimc_is_links (fmd); + +return ret; }/*
Signature · 1 line
1.7.9.5