diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi b/arch/arm64/boot/dts/freescale/imx8mq.dtsi index 86d20e12ff6be7503f1d474771897155cc3600f6..1793bd16658f754e5f8a66c197c60512c4df3255 100644 --- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi @@ -22,6 +22,8 @@ #size-cells = <2>; aliases { + csi0 = &mipi_csi_1; + csi1 = &mipi_csi_2; i2c0 = &i2c1; i2c1 = &i2c2; i2c2 = &i2c3; diff --git a/arch/arm64/boot/dts/freescale/librem5-evk.dtsi b/arch/arm64/boot/dts/freescale/librem5-evk.dtsi index aa577bbe0efbd06c958e8e2c736d6304e24fdc3f..4ae223f7acd1b266f4dafc5bbcceba94fe9df575 100644 --- a/arch/arm64/boot/dts/freescale/librem5-evk.dtsi +++ b/arch/arm64/boot/dts/freescale/librem5-evk.dtsi @@ -121,18 +121,6 @@ default-state = "off"; }; - csi_nrst { - label = "CSI_nRST"; - gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>; - default-state = "on"; - }; - - csi_pdwn { - label = "CSI_PDWN"; - gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; - default-state = "off"; - }; - spk_mute { label = "SPK_MUTE"; gpios = <&gpio5 3 GPIO_ACTIVE_LOW>; @@ -225,9 +213,9 @@ pinctrl_csi1: csi1grp { fsl,pins = < - MX8MQ_IOMUXC_GPIO1_IO06_GPIO1_IO6 0x11 /* CSI_nRST */ MX8MQ_IOMUXC_GPIO1_IO07_GPIO1_IO7 0x19 /* CSI_PWDN */ - MX8MQ_IOMUXC_GPIO1_IO14_CCMSRCGPCMIX_CLKO1 0x19 /* CLK01 */ + MX8MQ_IOMUXC_GPIO1_IO06_GPIO1_IO6 0x19 /* CSI_nRST */ + MX8MQ_IOMUXC_GPIO1_IO14_CCMSRCGPCMIX_CLKO1 0x59 /* CLK01 */ >; }; @@ -886,18 +874,20 @@ status = "okay"; ov5640_mipi: ov5640_mipi@3c { - compatible = "ovti,ov5640"; + compatible = "ovti,ov5640_mipi"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_csi1>; reg = <0x3c>; status = "okay"; clocks = <&clk IMX8MQ_CLK_CLKO1_DIV>; - clock-names = "xclk"; - // TODO : need to change the parent clocks if we want 24Mhz - assigned-clocks = <&clk IMX8MQ_CLK_CLKO1_DIV>; - assigned-clock-rates = <12500000>; + clock-names = "csi_mclk"; + assigned-clocks = <&clk IMX8MQ_CLK_CLKO1_SRC>, + <&clk IMX8MQ_CLK_CLKO1_DIV>; + assigned-clock-parents = <&clk IMX8MQ_SYS1_PLL_200M>; + assigned-clock-rates = <0>, <20000000>; csi_id = <0>; - pwn-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>; + pwn-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; + rst-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>; mclk = <20000000>; mclk_source = <0>; port { @@ -1148,7 +1138,7 @@ &csi1_bridge { fsl,mipi-mode; - /* fsl,two-8bit-sensor-mode; */ + fsl,two-8bit-sensor-mode; status = "okay"; port { diff --git a/arch/arm64/configs/librem5-evk_defconfig b/arch/arm64/configs/librem5-evk_defconfig index 659906958307ccea1f0dec9b4fc61842d39ff2ff..a18f18d68fd5d3926497bff7523efcc9ed76ddd9 100644 --- a/arch/arm64/configs/librem5-evk_defconfig +++ b/arch/arm64/configs/librem5-evk_defconfig @@ -136,6 +136,7 @@ CONFIG_FAILOVER=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y +CONFIG_DEBUG_DRIVER=y CONFIG_DEBUG_DEVRES=y CONFIG_CMA_SIZE_MBYTES=320 CONFIG_VEXPRESS_CONFIG=y @@ -302,7 +303,7 @@ CONFIG_I2C_CHARDEV=y CONFIG_I2C_MUX=y CONFIG_I2C_MUX_PCA954x=y CONFIG_I2C_DESIGNWARE_PLATFORM=y -CONFIG_I2C_IMX=m +CONFIG_I2C_IMX=y CONFIG_I2C_IMX_LPI2C=m CONFIG_I2C_CROS_EC_TUNNEL=y CONFIG_I2C_SLAVE=y @@ -355,14 +356,11 @@ CONFIG_MEDIA_SUPPORT=y CONFIG_MEDIA_CAMERA_SUPPORT=y CONFIG_MEDIA_CONTROLLER=y CONFIG_V4L_PLATFORM_DRIVERS=y -# CONFIG_IMX8_MIPI_CSI2 is not set CONFIG_VIDEO_MXC_CSI_CAMERA=y CONFIG_MXC_MIPI_CSI=y -CONFIG_MXC_CAMERA_OV5640_V2=m -CONFIG_MXC_CAMERA_OV5640_MIPI_V2=m +CONFIG_MXC_CAMERA_OV5640_MIPI_V2=y CONFIG_V4L_MEM2MEM_DRIVERS=y # CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set -CONFIG_VIDEO_OV5640=m CONFIG_IMX_DCSS_CORE=y CONFIG_DRM=y CONFIG_DRM_I2C_CH7006=m diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index f6e40cc9745c9815df2c34f1255f3a68fbbf8da8..c259db581607f1d27ce4c77dc5c336918de2eb7f 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -821,8 +821,8 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val) ret = i2c_transfer(client->adapter, &msg, 1); if (ret < 0) { - dev_err(&client->dev, "%s: error: reg=%x, val=%x\n", - __func__, reg, val); + dev_err(&client->dev, "%s: error: reg=0x%x, val=0x%x: %d\n", + __func__, reg, val, ret); return ret; } diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 74a87054307359ed3704516a58a7f9bc1b0fcdf4..c251a0d43db10870b1bd6f900bcb678ada0a39b7 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -139,7 +139,6 @@ config VIDEO_MX8_CAPTURE source "drivers/media/platform/imx8/Kconfig" source "drivers/media/platform/mxc/capture/Kconfig" -source "drivers/media/platform/mxc/output/Kconfig" source "drivers/media/platform/soc_camera/Kconfig" source "drivers/media/platform/exynos4-is/Kconfig" diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile index a55a265ccdb20ad5f6f96ae50cec53af31709d42..de2b9aeccc8e115573185560cfe8351992e77a76 100644 --- a/drivers/media/platform/Makefile +++ b/drivers/media/platform/Makefile @@ -96,9 +96,7 @@ ifeq ($(CONFIG_VIDEO_MXC_CAPTURE),y) error "mxc capture defined $(CONFIG_VIDEO_MXC_CAPTURE)" endif -#obj-$(CONFIG_VIDEO_MXC_CAPTURE) += mxc/capture/ -obj-y += mxc/capture/ -obj-$(CONFIG_VIDEO_MXC_OUTPUT) += mxc/output/ +obj-$(CONFIG_VIDEO_MX8_CAPTURE) += mxc/capture/ obj-$(CONFIG_VIDEO_MX8_CAPTURE) += imx8/ obj-y += meson/ diff --git a/drivers/media/platform/imx8/Kconfig b/drivers/media/platform/imx8/Kconfig index 3dcfea3f743649421ff77a56c0955d3f8ee97dfa..115ef4d200d9a2ffa8f547dff337a567233f143b 100644 --- a/drivers/media/platform/imx8/Kconfig +++ b/drivers/media/platform/imx8/Kconfig @@ -1,38 +1,9 @@ if VIDEO_MX8_CAPTURE menu "IMX8 Camera ISI/MIPI Features support" -config IMX8_MEDIA_DEVICE - tristate "IMX8 Media Device Driver" - default y - -config IMX8_CAPTURE_DRIVER - tristate "IMX8 Camera Controller" - depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API - select V4L2_MEM2MEM_DEV - select VIDEOBUF2_DMA_CONTIG - default y - -config IMX8_MIPI_CSI2 - tristate "IMX8 MIPI CSI2 Controller" - select V4L2_FWNODE - default y - config IMX8_MIPI_CSI2_YAV tristate "IMX8 MIPI CSI2 Controller Yet Another Version" select V4L2_FWNODE - default y - -config GMSL_MAX9286 - tristate "Maxim max9286 GMSL Deserializer Input support" - select SENSOR_OV10635 - depends on I2C - ---help--- - If you plan to use the max9286 GMSL Deserializer with your capture system, say Y here. - -config IMX8_JPEG - tristate "IMX8 JPEG Encoder/Decoder" - depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API - select V4L2_MEM2MEM_DEV select VIDEOBUF2_DMA_CONTIG default y diff --git a/drivers/media/platform/imx8/Makefile b/drivers/media/platform/imx8/Makefile index c98d82d88650b9f50afdfe40955616069798c52d..cc57cc26d5b4ef9a0688833e97f1354b023acc6d 100644 --- a/drivers/media/platform/imx8/Makefile +++ b/drivers/media/platform/imx8/Makefile @@ -1,9 +1 @@ -mxc-capture-objs := mxc-isi-core.o mxc-isi-cap.o mxc-isi-hw.o - -obj-$(CONFIG_IMX8_CAPTURE_DRIVER) += mxc-capture.o -obj-$(CONFIG_IMX8_MIPI_CSI2) += mxc-mipi-csi2.o obj-$(CONFIG_IMX8_MIPI_CSI2_YAV) += mxc-mipi-csi2_yav.o -max9286_gmsl-objs := max9286.o -obj-$(CONFIG_GMSL_MAX9286) += max9286_gmsl.o -obj-$(CONFIG_IMX8_MEDIA_DEVICE) += mxc-media-dev.o -obj-$(CONFIG_IMX8_JPEG) += mxc-jpeg-hw.o mxc-jpeg.o diff --git a/drivers/media/platform/imx8/max9286.c b/drivers/media/platform/imx8/max9286.c deleted file mode 100644 index 73841a8ce8ebe144d1d8ee917a8d209e213ce5e3..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/max9286.c +++ /dev/null @@ -1,2982 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "max9286.h" - -#define MAX9271_MAX_SENSOR_NUM 4 -#define CAMERA_USES_15HZ - -#define ADDR_MAX9286 0x6A -#define ADDR_MAX9271 0x40 -#define ADDR_MAX9271_ALL (ADDR_MAX9271 + 5) /* Broadcast address */ -#define ADDR_OV_SENSOR 0x30 -#define ADDR_AP_SENSOR 0x5D - -static unsigned int g_max9286_width = 1280; -static unsigned int g_max9286_height = 800; - -#define OV10635_REG_PID 0x300A -#define OV10635_REG_VER 0x300B - -struct reg_value { - unsigned short reg_addr; - unsigned char val; - unsigned int delay_ms; -}; - -enum ov10635_frame_rate { - OV10635_15_FPS, - OV10635_30_FPS, -}; - -static struct reg_value ov10635_init_data[] = { - { 0x0103, 0x01, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x300c, 0x61, 0 }, - { 0x301b, 0xff, 0 }, - { 0x301c, 0xff, 0 }, - { 0x301a, 0xff, 0 }, - { 0x3011, 0x42, 0 }, - { 0x6900, 0x0c, 0 }, - { 0x6901, 0x11, 0 }, - { 0x3503, 0x10, 0 }, - { 0x3025, 0x03, 0 }, - { 0x3003, 0x20, 0 }, - { 0x3004, 0x23, 0 }, - { 0x3005, 0x20, 0 }, - { 0x3006, 0x91, 0 }, - { 0x3600, 0x74, 0 }, - { 0x3601, 0x2b, 0 }, - { 0x3612, 0x00, 0 }, - { 0x3611, 0x67, 0 }, - { 0x3633, 0xca, 0 }, - { 0x3602, 0x2f, 0 }, - { 0x3603, 0x00, 0 }, - { 0x3630, 0x28, 0 }, - { 0x3631, 0x16, 0 }, - { 0x3714, 0x10, 0 }, - { 0x371d, 0x01, 0 }, - { 0x4300, 0x38, 0}, - { 0x3007, 0x01, 0 }, - { 0x3024, 0x01, 0 }, /* YUV */ - { 0x3020, 0x0b, 0 }, - { 0x3702, 0x10, 0 }, /* 0x20 for 96MHz */ - { 0x3703, 0x24, 0 }, /* 0x48 for 96MHz */ - { 0x3704, 0x19, 0 }, - { 0x3709, 0xa8, 0 }, - { 0x3709, 0xa8, 0 }, - { 0x370c, 0xc7, 0 }, - { 0x370d, 0x80, 0 }, - { 0x3712, 0x00, 0 }, - { 0x3713, 0x20, 0 }, - { 0x3715, 0x04, 0 }, - { 0x381d, 0x40, 0 }, - { 0x381c, 0x00, 0 }, - { 0x3822, 0x50, 0 }, - { 0x3824, 0x50, 0 }, - { 0x3815, 0x8c, 0 }, - { 0x3804, 0x05, 0 }, - { 0x3805, 0x1f, 0 }, - { 0x3800, 0x00, 0 }, - { 0x3801, 0x00, 0 }, - { 0x3806, 0x03, 0 }, - { 0x3807, 0x29, 0 }, - { 0x3802, 0x00, 0 }, - { 0x3803, 0x04, 0 }, - { 0x3808, 0x05, 0 }, - { 0x3809, 0x00, 0 }, - { 0x380a, 0x03, 0 }, - { 0x380b, 0x20, 0 }, - { 0x380c, 0x07, 0 }, - { 0x380d, 0x71, 0 }, - { 0x6e42, 0x03, 0 }, - { 0x6e43, 0x48, 0 }, - { 0x380e, 0x03, 0 }, - { 0x380f, 0x48, 0 }, - { 0x3813, 0x02, 0 }, - { 0x3811, 0x10, 0 }, - { 0x381f, 0x0c, 0 }, - { 0x3828, 0x03, 0 }, - { 0x3829, 0x10, 0 }, - { 0x382a, 0x10, 0 }, - { 0x382b, 0x10, 0 }, - { 0x3621, 0x64, 0 }, - { 0x5005, 0x08, 0 }, - { 0x56d5, 0x00, 0 }, - { 0x56d6, 0x80, 0 }, - { 0x56d7, 0x00, 0 }, - { 0x56d8, 0x00, 0 }, - { 0x56d9, 0x00, 0 }, - { 0x56da, 0x80, 0 }, - { 0x56db, 0x00, 0 }, - { 0x56dc, 0x00, 0 }, - { 0x56e8, 0x00, 0 }, - { 0x56e9, 0x7f, 0 }, - { 0x56ea, 0x00, 0 }, - { 0x56eb, 0x7f, 0 }, - { 0x5100, 0x00, 0 }, - { 0x5101, 0x80, 0 }, - { 0x5102, 0x00, 0 }, - { 0x5103, 0x80, 0 }, - { 0x5104, 0x00, 0 }, - { 0x5105, 0x80, 0 }, - { 0x5106, 0x00, 0 }, - { 0x5107, 0x80, 0 }, - { 0x5108, 0x00, 0 }, - { 0x5109, 0x00, 0 }, - { 0x510a, 0x00, 0 }, - { 0x510b, 0x00, 0 }, - { 0x510c, 0x00, 0 }, - { 0x510d, 0x00, 0 }, - { 0x510e, 0x00, 0 }, - { 0x510f, 0x00, 0 }, - { 0x5110, 0x00, 0 }, - { 0x5111, 0x80, 0 }, - { 0x5112, 0x00, 0 }, - { 0x5113, 0x80, 0 }, - { 0x5114, 0x00, 0 }, - { 0x5115, 0x80, 0 }, - { 0x5116, 0x00, 0 }, - { 0x5117, 0x80, 0 }, - { 0x5118, 0x00, 0 }, - { 0x5119, 0x00, 0 }, - { 0x511a, 0x00, 0 }, - { 0x511b, 0x00, 0 }, - { 0x511c, 0x00, 0 }, - { 0x511d, 0x00, 0 }, - { 0x511e, 0x00, 0 }, - { 0x511f, 0x00, 0 }, - { 0x56d0, 0x00, 0 }, - { 0x5006, 0x24, 0 }, - { 0x5608, 0x0d, 0 }, - { 0x52d7, 0x06, 0 }, - { 0x528d, 0x08, 0 }, - { 0x5293, 0x12, 0 }, - { 0x52d3, 0x12, 0 }, - { 0x5288, 0x06, 0 }, - { 0x5289, 0x20, 0 }, - { 0x52c8, 0x06, 0 }, - { 0x52c9, 0x20, 0 }, - { 0x52cd, 0x04, 0 }, - { 0x5381, 0x00, 0 }, - { 0x5382, 0xff, 0 }, - { 0x5589, 0x76, 0 }, - { 0x558a, 0x47, 0 }, - { 0x558b, 0xef, 0 }, - { 0x558c, 0xc9, 0 }, - { 0x558d, 0x49, 0 }, - { 0x558e, 0x30, 0 }, - { 0x558f, 0x67, 0 }, - { 0x5590, 0x3f, 0 }, - { 0x5591, 0xf0, 0 }, - { 0x5592, 0x10, 0 }, - { 0x55a2, 0x6d, 0 }, - { 0x55a3, 0x55, 0 }, - { 0x55a4, 0xc3, 0 }, - { 0x55a5, 0xb5, 0 }, - { 0x55a6, 0x43, 0 }, - { 0x55a7, 0x38, 0 }, - { 0x55a8, 0x5f, 0 }, - { 0x55a9, 0x4b, 0 }, - { 0x55aa, 0xf0, 0 }, - { 0x55ab, 0x10, 0 }, - { 0x5581, 0x52, 0 }, - { 0x5300, 0x01, 0 }, - { 0x5301, 0x00, 0 }, - { 0x5302, 0x00, 0 }, - { 0x5303, 0x0e, 0 }, - { 0x5304, 0x00, 0 }, - { 0x5305, 0x0e, 0 }, - { 0x5306, 0x00, 0 }, - { 0x5307, 0x36, 0 }, - { 0x5308, 0x00, 0 }, - { 0x5309, 0xd9, 0 }, - { 0x530a, 0x00, 0 }, - { 0x530b, 0x0f, 0 }, - { 0x530c, 0x00, 0 }, - { 0x530d, 0x2c, 0 }, - { 0x530e, 0x00, 0 }, - { 0x530f, 0x59, 0 }, - { 0x5310, 0x00, 0 }, - { 0x5311, 0x7b, 0 }, - { 0x5312, 0x00, 0 }, - { 0x5313, 0x22, 0 }, - { 0x5314, 0x00, 0 }, - { 0x5315, 0xd5, 0 }, - { 0x5316, 0x00, 0 }, - { 0x5317, 0x13, 0 }, - { 0x5318, 0x00, 0 }, - { 0x5319, 0x18, 0 }, - { 0x531a, 0x00, 0 }, - { 0x531b, 0x26, 0 }, - { 0x531c, 0x00, 0 }, - { 0x531d, 0xdc, 0 }, - { 0x531e, 0x00, 0 }, - { 0x531f, 0x02, 0 }, - { 0x5320, 0x00, 0 }, - { 0x5321, 0x24, 0 }, - { 0x5322, 0x00, 0 }, - { 0x5323, 0x56, 0 }, - { 0x5324, 0x00, 0 }, - { 0x5325, 0x85, 0 }, - { 0x5326, 0x00, 0 }, - { 0x5327, 0x20, 0 }, - { 0x5609, 0x01, 0 }, - { 0x560a, 0x40, 0 }, - { 0x560b, 0x01, 0 }, - { 0x560c, 0x40, 0 }, - { 0x560d, 0x00, 0 }, - { 0x560e, 0xfa, 0 }, - { 0x560f, 0x00, 0 }, - { 0x5610, 0xfa, 0 }, - { 0x5611, 0x02, 0 }, - { 0x5612, 0x80, 0 }, - { 0x5613, 0x02, 0 }, - { 0x5614, 0x80, 0 }, - { 0x5615, 0x01, 0 }, - { 0x5616, 0x2c, 0 }, - { 0x5617, 0x01, 0 }, - { 0x5618, 0x2c, 0 }, - { 0x563b, 0x01, 0 }, - { 0x563c, 0x01, 0 }, - { 0x563d, 0x01, 0 }, - { 0x563e, 0x01, 0 }, - { 0x563f, 0x03, 0 }, - { 0x5640, 0x03, 0 }, - { 0x5641, 0x03, 0 }, - { 0x5642, 0x05, 0 }, - { 0x5643, 0x09, 0 }, - { 0x5644, 0x05, 0 }, - { 0x5645, 0x05, 0 }, - { 0x5646, 0x05, 0 }, - { 0x5647, 0x05, 0 }, - { 0x5651, 0x00, 0 }, - { 0x5652, 0x80, 0 }, - { 0x521a, 0x01, 0 }, - { 0x521b, 0x03, 0 }, - { 0x521c, 0x06, 0 }, - { 0x521d, 0x0a, 0 }, - { 0x521e, 0x0e, 0 }, - { 0x521f, 0x12, 0 }, - { 0x5220, 0x16, 0 }, - { 0x5223, 0x02, 0 }, - { 0x5225, 0x04, 0 }, - { 0x5227, 0x08, 0 }, - { 0x5229, 0x0c, 0 }, - { 0x522b, 0x12, 0 }, - { 0x522d, 0x18, 0 }, - { 0x522f, 0x1e, 0 }, - { 0x5241, 0x04, 0 }, - { 0x5242, 0x01, 0 }, - { 0x5243, 0x03, 0 }, - { 0x5244, 0x06, 0 }, - { 0x5245, 0x0a, 0 }, - { 0x5246, 0x0e, 0 }, - { 0x5247, 0x12, 0 }, - { 0x5248, 0x16, 0 }, - { 0x524a, 0x03, 0 }, - { 0x524c, 0x04, 0 }, - { 0x524e, 0x08, 0 }, - { 0x5250, 0x0c, 0 }, - { 0x5252, 0x12, 0 }, - { 0x5254, 0x18, 0 }, - { 0x5256, 0x1e, 0 }, - { 0x4606, 0x07, 0 }, - { 0x4607, 0x71, 0 }, - { 0x460a, 0x02, 0 }, - { 0x460b, 0x70, 0 }, - { 0x460c, 0x00, 0 }, - { 0x4620, 0x0e, 0 }, - { 0x4700, 0x04, 0 }, - { 0x4701, 0x00, 0 }, - { 0x4702, 0x01, 0 }, - { 0x4004, 0x04, 0 }, - { 0x4005, 0x18, 0 }, - { 0x4001, 0x06, 0 }, - { 0x4050, 0x22, 0 }, - { 0x4051, 0x24, 0 }, - { 0x4052, 0x02, 0 }, - { 0x4057, 0x9c, 0 }, - { 0x405a, 0x00, 0 }, - { 0x4202, 0x02, 0 }, - { 0x3023, 0x10, 0 }, - { 0x0100, 0x01, 0 }, - { 0x0100, 0x01, 0 }, - { 0x6f10, 0x07, 0 }, - { 0x6f11, 0x82, 0 }, - { 0x6f12, 0x04, 0 }, - { 0x6f13, 0x00, 0 }, - { 0x6f14, 0x1f, 0 }, - { 0x6f15, 0xdd, 0 }, - { 0x6f16, 0x04, 0 }, - { 0x6f17, 0x04, 0 }, - { 0x6f18, 0x36, 0 }, - { 0x6f19, 0x66, 0 }, - { 0x6f1a, 0x04, 0 }, - { 0x6f1b, 0x08, 0 }, - { 0x6f1c, 0x0c, 0 }, - { 0x6f1d, 0xe7, 0 }, - { 0x6f1e, 0x04, 0 }, - { 0x6f1f, 0x0c, 0 }, - { 0xd000, 0x19, 0 }, - { 0xd001, 0xa0, 0 }, - { 0xd002, 0x00, 0 }, - { 0xd003, 0x01, 0 }, - { 0xd004, 0xa9, 0 }, - { 0xd005, 0xad, 0 }, - { 0xd006, 0x10, 0 }, - { 0xd007, 0x40, 0 }, - { 0xd008, 0x44, 0 }, - { 0xd009, 0x00, 0 }, - { 0xd00a, 0x68, 0 }, - { 0xd00b, 0x00, 0 }, - { 0xd00c, 0x15, 0 }, - { 0xd00d, 0x00, 0 }, - { 0xd00e, 0x00, 0 }, - { 0xd00f, 0x00, 0 }, - { 0xd010, 0x19, 0 }, - { 0xd011, 0xa0, 0 }, - { 0xd012, 0x00, 0 }, - { 0xd013, 0x01, 0 }, - { 0xd014, 0xa9, 0 }, - { 0xd015, 0xad, 0 }, - { 0xd016, 0x13, 0 }, - { 0xd017, 0xd0, 0 }, - { 0xd018, 0x44, 0 }, - { 0xd019, 0x00, 0 }, - { 0xd01a, 0x68, 0 }, - { 0xd01b, 0x00, 0 }, - { 0xd01c, 0x15, 0 }, - { 0xd01d, 0x00, 0 }, - { 0xd01e, 0x00, 0 }, - { 0xd01f, 0x00, 0 }, - { 0xd020, 0x19, 0 }, - { 0xd021, 0xa0, 0 }, - { 0xd022, 0x00, 0 }, - { 0xd023, 0x01, 0 }, - { 0xd024, 0xa9, 0 }, - { 0xd025, 0xad, 0 }, - { 0xd026, 0x14, 0 }, - { 0xd027, 0xb8, 0 }, - { 0xd028, 0x44, 0 }, - { 0xd029, 0x00, 0 }, - { 0xd02a, 0x68, 0 }, - { 0xd02b, 0x00, 0 }, - { 0xd02c, 0x15, 0 }, - { 0xd02d, 0x00, 0 }, - { 0xd02e, 0x00, 0 }, - { 0xd02f, 0x00, 0 }, - { 0xd030, 0x19, 0 }, - { 0xd031, 0xa0, 0 }, - { 0xd032, 0x00, 0 }, - { 0xd033, 0x01, 0 }, - { 0xd034, 0xa9, 0 }, - { 0xd035, 0xad, 0 }, - { 0xd036, 0x14, 0 }, - { 0xd037, 0xdc, 0 }, - { 0xd038, 0x44, 0 }, - { 0xd039, 0x00, 0 }, - { 0xd03a, 0x68, 0 }, - { 0xd03b, 0x00, 0 }, - { 0xd03c, 0x15, 0 }, - { 0xd03d, 0x00, 0 }, - { 0xd03e, 0x00, 0 }, - { 0xd03f, 0x00, 0 }, - { 0xd040, 0x9c, 0 }, - { 0xd041, 0x21, 0 }, - { 0xd042, 0xff, 0 }, - { 0xd043, 0xe4, 0 }, - { 0xd044, 0xd4, 0 }, - { 0xd045, 0x01, 0 }, - { 0xd046, 0x48, 0 }, - { 0xd047, 0x00, 0 }, - { 0xd048, 0xd4, 0 }, - { 0xd049, 0x01, 0 }, - { 0xd04a, 0x50, 0 }, - { 0xd04b, 0x04, 0 }, - { 0xd04c, 0xd4, 0 }, - { 0xd04d, 0x01, 0 }, - { 0xd04e, 0x60, 0 }, - { 0xd04f, 0x08, 0 }, - { 0xd050, 0xd4, 0 }, - { 0xd051, 0x01, 0 }, - { 0xd052, 0x70, 0 }, - { 0xd053, 0x0c, 0 }, - { 0xd054, 0xd4, 0 }, - { 0xd055, 0x01, 0 }, - { 0xd056, 0x80, 0 }, - { 0xd057, 0x10, 0 }, - { 0xd058, 0x19, 0 }, - { 0xd059, 0xc0, 0 }, - { 0xd05a, 0x00, 0 }, - { 0xd05b, 0x01, 0 }, - { 0xd05c, 0xa9, 0 }, - { 0xd05d, 0xce, 0 }, - { 0xd05e, 0x02, 0 }, - { 0xd05f, 0xa4, 0 }, - { 0xd060, 0x9c, 0 }, - { 0xd061, 0xa0, 0 }, - { 0xd062, 0x00, 0 }, - { 0xd063, 0x00, 0 }, - { 0xd064, 0x84, 0 }, - { 0xd065, 0x6e, 0 }, - { 0xd066, 0x00, 0 }, - { 0xd067, 0x00, 0 }, - { 0xd068, 0xd8, 0 }, - { 0xd069, 0x03, 0 }, - { 0xd06a, 0x28, 0 }, - { 0xd06b, 0x76, 0 }, - { 0xd06c, 0x1a, 0 }, - { 0xd06d, 0x00, 0 }, - { 0xd06e, 0x00, 0 }, - { 0xd06f, 0x01, 0 }, - { 0xd070, 0xaa, 0 }, - { 0xd071, 0x10, 0 }, - { 0xd072, 0x03, 0 }, - { 0xd073, 0xf0, 0 }, - { 0xd074, 0x18, 0 }, - { 0xd075, 0x60, 0 }, - { 0xd076, 0x00, 0 }, - { 0xd077, 0x01, 0 }, - { 0xd078, 0xa8, 0 }, - { 0xd079, 0x63, 0 }, - { 0xd07a, 0x07, 0 }, - { 0xd07b, 0x80, 0 }, - { 0xd07c, 0xe0, 0 }, - { 0xd07d, 0xa0, 0 }, - { 0xd07e, 0x00, 0 }, - { 0xd07f, 0x04, 0 }, - { 0xd080, 0x18, 0 }, - { 0xd081, 0xc0, 0 }, - { 0xd082, 0x00, 0 }, - { 0xd083, 0x00, 0 }, - { 0xd084, 0xa8, 0 }, - { 0xd085, 0xc6, 0 }, - { 0xd086, 0x00, 0 }, - { 0xd087, 0x00, 0 }, - { 0xd088, 0x8c, 0 }, - { 0xd089, 0x63, 0 }, - { 0xd08a, 0x00, 0 }, - { 0xd08b, 0x00, 0 }, - { 0xd08c, 0xd4, 0 }, - { 0xd08d, 0x01, 0 }, - { 0xd08e, 0x28, 0 }, - { 0xd08f, 0x14, 0 }, - { 0xd090, 0xd4, 0 }, - { 0xd091, 0x01, 0 }, - { 0xd092, 0x30, 0 }, - { 0xd093, 0x18, 0 }, - { 0xd094, 0x07, 0 }, - { 0xd095, 0xff, 0 }, - { 0xd096, 0xf8, 0 }, - { 0xd097, 0xfd, 0 }, - { 0xd098, 0x9c, 0 }, - { 0xd099, 0x80, 0 }, - { 0xd09a, 0x00, 0 }, - { 0xd09b, 0x03, 0 }, - { 0xd09c, 0xa5, 0 }, - { 0xd09d, 0x6b, 0 }, - { 0xd09e, 0x00, 0 }, - { 0xd09f, 0xff, 0 }, - { 0xd0a0, 0x18, 0 }, - { 0xd0a1, 0xc0, 0 }, - { 0xd0a2, 0x00, 0 }, - { 0xd0a3, 0x01, 0 }, - { 0xd0a4, 0xa8, 0 }, - { 0xd0a5, 0xc6, 0 }, - { 0xd0a6, 0x01, 0 }, - { 0xd0a7, 0x02, 0 }, - { 0xd0a8, 0xe1, 0 }, - { 0xd0a9, 0x6b, 0 }, - { 0xd0aa, 0x58, 0 }, - { 0xd0ab, 0x00, 0 }, - { 0xd0ac, 0x84, 0 }, - { 0xd0ad, 0x8e, 0 }, - { 0xd0ae, 0x00, 0 }, - { 0xd0af, 0x00, 0 }, - { 0xd0b0, 0xe1, 0 }, - { 0xd0b1, 0x6b, 0 }, - { 0xd0b2, 0x30, 0 }, - { 0xd0b3, 0x00, 0 }, - { 0xd0b4, 0x98, 0 }, - { 0xd0b5, 0xb0, 0 }, - { 0xd0b6, 0x00, 0 }, - { 0xd0b7, 0x00, 0 }, - { 0xd0b8, 0x8c, 0 }, - { 0xd0b9, 0x64, 0 }, - { 0xd0ba, 0x00, 0 }, - { 0xd0bb, 0x6e, 0 }, - { 0xd0bc, 0xe5, 0 }, - { 0xd0bd, 0xa5, 0 }, - { 0xd0be, 0x18, 0 }, - { 0xd0bf, 0x00, 0 }, - { 0xd0c0, 0x10, 0 }, - { 0xd0c1, 0x00, 0 }, - { 0xd0c2, 0x00, 0 }, - { 0xd0c3, 0x06, 0 }, - { 0xd0c4, 0x95, 0 }, - { 0xd0c5, 0x8b, 0 }, - { 0xd0c6, 0x00, 0 }, - { 0xd0c7, 0x00, 0 }, - { 0xd0c8, 0x94, 0 }, - { 0xd0c9, 0xa4, 0 }, - { 0xd0ca, 0x00, 0 }, - { 0xd0cb, 0x70, 0 }, - { 0xd0cc, 0xe5, 0 }, - { 0xd0cd, 0x65, 0 }, - { 0xd0ce, 0x60, 0 }, - { 0xd0cf, 0x00, 0 }, - { 0xd0d0, 0x0c, 0 }, - { 0xd0d1, 0x00, 0 }, - { 0xd0d2, 0x00, 0 }, - { 0xd0d3, 0x62, 0 }, - { 0xd0d4, 0x15, 0 }, - { 0xd0d5, 0x00, 0 }, - { 0xd0d6, 0x00, 0 }, - { 0xd0d7, 0x00, 0 }, - { 0xd0d8, 0x18, 0 }, - { 0xd0d9, 0x60, 0 }, - { 0xd0da, 0x80, 0 }, - { 0xd0db, 0x06, 0 }, - { 0xd0dc, 0xa8, 0 }, - { 0xd0dd, 0x83, 0 }, - { 0xd0de, 0x38, 0 }, - { 0xd0df, 0x29, 0 }, - { 0xd0e0, 0xa8, 0 }, - { 0xd0e1, 0xe3, 0 }, - { 0xd0e2, 0x40, 0 }, - { 0xd0e3, 0x08, 0}, - { 0xd0e4, 0x8c, 0 }, - { 0xd0e5, 0x84, 0}, - { 0xd0e6, 0x00, 0 }, - { 0xd0e7, 0x00, 0 }, - { 0xd0e8, 0xa8, 0}, - { 0xd0e9, 0xa3, 0}, - { 0xd0ea, 0x40, 0}, - { 0xd0eb, 0x09, 0}, - { 0xd0ec, 0xa8, 0}, - { 0xd0ed, 0xc3, 0}, - { 0xd0ee, 0x38, 0}, - { 0xd0ef, 0x2a, 0}, - { 0xd0f0, 0xd8, 0}, - { 0xd0f1, 0x07, 0}, - { 0xd0f2, 0x20, 0}, - { 0xd0f3, 0x00, 0 }, - { 0xd0f4, 0x8c, 0}, - { 0xd0f5, 0x66, 0}, - { 0xd0f6, 0x00, 0 }, - { 0xd0f7, 0x00, 0}, - { 0xd0f8, 0xd8, 0}, - { 0xd0f9, 0x05, 0}, - { 0xd0fa, 0x18, 0}, - { 0xd0fb, 0x00, 0}, - { 0xd0fc, 0x18, 0}, - { 0xd0fd, 0x60, 0}, - { 0xd0fe, 0x00, 0 }, - { 0xd0ff, 0x01, 0}, - { 0xd100, 0x98, 0}, - { 0xd101, 0x90, 0}, - { 0xd102, 0x00, 0 }, - { 0xd103, 0x00, 0 }, - { 0xd104, 0x84, 0}, - { 0xd105, 0xae, 0}, - { 0xd106, 0x00, 0}, - { 0xd107, 0x00, 0}, - { 0xd108, 0xa8, 0}, - { 0xd109, 0x63, 0}, - { 0xd10a, 0x06, 0}, - { 0xd10b, 0x4c, 0}, - { 0xd10c, 0x9c, 0}, - { 0xd10d, 0xc0, 0}, - { 0xd10e, 0x00, 0 }, - { 0xd10f, 0x00, 0 }, - { 0xd110, 0xd8, 0}, - { 0xd111, 0x03, 0}, - { 0xd112, 0x30, 0}, - { 0xd113, 0x00, 0}, - { 0xd114, 0x8c, 0}, - { 0xd115, 0x65, 0}, - { 0xd116, 0x00, 0}, - { 0xd117, 0x6e, 0}, - { 0xd118, 0xe5, 0}, - { 0xd119, 0x84, 0}, - { 0xd11a, 0x18, 0 }, - { 0xd11b, 0x00, 0 }, - { 0xd11c, 0x10, 0}, - { 0xd11d, 0x00, 0}, - { 0xd11e, 0x00, 0}, - { 0xd11f, 0x07, 0}, - { 0xd120, 0x18, 0}, - { 0xd121, 0x80, 0}, - { 0xd122, 0x80, 0}, - { 0xd123, 0x06, 0}, - { 0xd124, 0x94, 0}, - { 0xd125, 0x65, 0}, - { 0xd126, 0x00, 0}, - { 0xd127, 0x70, 0}, - { 0xd128, 0xe5, 0}, - { 0xd129, 0x43, 0}, - { 0xd12a, 0x60, 0}, - { 0xd12b, 0x00, 0 }, - { 0xd12c, 0x0c, 0}, - { 0xd12d, 0x00, 0}, - { 0xd12e, 0x00, 0 }, - { 0xd12f, 0x3e, 0}, - { 0xd130, 0xa8, 0}, - { 0xd131, 0x64, 0}, - { 0xd132, 0x38, 0}, - { 0xd133, 0x24, 0}, - { 0xd134, 0x18, 0}, - { 0xd135, 0x80, 0 }, - { 0xd136, 0x80, 0}, - { 0xd137, 0x06, 0}, - { 0xd138, 0xa8, 0 }, - { 0xd139, 0x64, 0}, - { 0xd13a, 0x38, 0 }, - { 0xd13b, 0x24, 0}, - { 0xd13c, 0x8c, 0}, - { 0xd13d, 0x63, 0}, - { 0xd13e, 0x00, 0}, - { 0xd13f, 0x00, 0}, - { 0xd140, 0xa4, 0}, - { 0xd141, 0x63, 0}, - { 0xd142, 0x00, 0}, - { 0xd143, 0x40, 0}, - { 0xd144, 0xbc, 0}, - { 0xd145, 0x23, 0}, - { 0xd146, 0x00, 0}, - { 0xd147, 0x00, 0}, - { 0xd148, 0x0c, 0}, - { 0xd149, 0x00, 0}, - { 0xd14a, 0x00, 0 }, - { 0xd14b, 0x2a, 0}, - { 0xd14c, 0xa8, 0}, - { 0xd14d, 0x64, 0}, - { 0xd14e, 0x6e, 0}, - { 0xd14f, 0x44, 0}, - { 0xd150, 0x19, 0}, - { 0xd151, 0x00, 0}, - { 0xd152, 0x80, 0}, - { 0xd153, 0x06, 0}, - { 0xd154, 0xa8, 0}, - { 0xd155, 0xe8, 0}, - { 0xd156, 0x3d, 0}, - { 0xd157, 0x05, 0}, - { 0xd158, 0x8c, 0}, - { 0xd159, 0x67, 0}, - { 0xd15a, 0x00, 0 }, - { 0xd15b, 0x00, 0}, - { 0xd15c, 0xb8, 0}, - { 0xd15d, 0x63, 0}, - { 0xd15e, 0x00, 0 }, - { 0xd15f, 0x18, 0}, - { 0xd160, 0xb8, 0}, - { 0xd161, 0x63, 0}, - { 0xd162, 0x00, 0 }, - { 0xd163, 0x98, 0}, - { 0xd164, 0xbc, 0 }, - { 0xd165, 0x03, 0 }, - { 0xd166, 0x00, 0 }, - { 0xd167, 0x00, 0 }, - { 0xd168, 0x10, 0 }, - { 0xd169, 0x00, 0 }, - { 0xd16a, 0x00, 0 }, - { 0xd16b, 0x10, 0}, - { 0xd16c, 0xa9, 0}, - { 0xd16d, 0x48, 0}, - { 0xd16e, 0x67, 0}, - { 0xd16f, 0x02, 0 }, - { 0xd170, 0xb8, 0}, - { 0xd171, 0xa3, 0}, - { 0xd172, 0x00, 0 }, - { 0xd173, 0x19, 0}, - { 0xd174, 0x8c, 0 }, - { 0xd175, 0x8a, 0}, - { 0xd176, 0x00, 0 }, - { 0xd177, 0x00, 0 }, - { 0xd178, 0xa9, 0}, - { 0xd179, 0x68, 0}, - { 0xd17a, 0x67, 0}, - { 0xd17b, 0x03, 0}, - { 0xd17c, 0xb8, 0}, - { 0xd17d, 0xc4, 0}, - { 0xd17e, 0x00, 0 }, - { 0xd17f, 0x08, 0}, - { 0xd180, 0x8c, 0}, - { 0xd181, 0x6b, 0}, - { 0xd182, 0x00, 0}, - { 0xd183, 0x00, 0}, - { 0xd184, 0xb8, 0}, - { 0xd185, 0x85, 0}, - { 0xd186, 0x00, 0 }, - { 0xd187, 0x98, 0}, - { 0xd188, 0xe0, 0}, - { 0xd189, 0x63, 0}, - { 0xd18a, 0x30, 0}, - { 0xd18b, 0x04, 0}, - { 0xd18c, 0xe0, 0}, - { 0xd18d, 0x64, 0}, - { 0xd18e, 0x18, 0}, - { 0xd18f, 0x00, 0}, - { 0xd190, 0xa4, 0}, - { 0xd191, 0x83, 0}, - { 0xd192, 0xff, 0}, - { 0xd193, 0xff, 0}, - { 0xd194, 0xb8, 0}, - { 0xd195, 0x64, 0}, - { 0xd196, 0x00, 0 }, - { 0xd197, 0x48, 0}, - { 0xd198, 0xd8, 0}, - { 0xd199, 0x0a, 0}, - { 0xd19a, 0x18, 0}, - { 0xd19b, 0x00, 0}, - { 0xd19c, 0xd8, 0}, - { 0xd19d, 0x0b, 0}, - { 0xd19e, 0x20, 0}, - { 0xd19f, 0x00, 0}, - { 0xd1a0, 0x9c, 0}, - { 0xd1a1, 0x60, 0}, - { 0xd1a2, 0x00, 0}, - { 0xd1a3, 0x00, 0}, - { 0xd1a4, 0xd8, 0}, - { 0xd1a5, 0x07, 0}, - { 0xd1a6, 0x18, 0}, - { 0xd1a7, 0x00, 0 }, - { 0xd1a8, 0xa8, 0 }, - { 0xd1a9, 0x68, 0}, - { 0xd1aa, 0x38, 0 }, - { 0xd1ab, 0x22, 0}, - { 0xd1ac, 0x9c, 0}, - { 0xd1ad, 0x80, 0}, - { 0xd1ae, 0x00, 0}, - { 0xd1af, 0x70, 0}, - { 0xd1b0, 0xa8, 0}, - { 0xd1b1, 0xe8, 0}, - { 0xd1b2, 0x38, 0}, - { 0xd1b3, 0x43, 0}, - { 0xd1b4, 0xd8, 0}, - { 0xd1b5, 0x03, 0}, - { 0xd1b6, 0x20, 0}, - { 0xd1b7, 0x00, 0 }, - { 0xd1b8, 0x9c, 0}, - { 0xd1b9, 0xa0, 0}, - { 0xd1ba, 0x00, 0}, - { 0xd1bb, 0x00, 0}, - { 0xd1bc, 0xa8, 0}, - { 0xd1bd, 0xc8, 0}, - { 0xd1be, 0x38, 0}, - { 0xd1bf, 0x42, 0}, - { 0xd1c0, 0x8c, 0 }, - { 0xd1c1, 0x66, 0}, - { 0xd1c2, 0x00, 0 }, - { 0xd1c3, 0x00, 0 }, - { 0xd1c4, 0x9c, 0}, - { 0xd1c5, 0xa5, 0}, - { 0xd1c6, 0x00, 0 }, - { 0xd1c7, 0x01, 0}, - { 0xd1c8, 0xb8, 0}, - { 0xd1c9, 0x83, 0}, - { 0xd1ca, 0x00, 0 }, - { 0xd1cb, 0x08, 0}, - { 0xd1cc, 0xa4, 0}, - { 0xd1cd, 0xa5, 0}, - { 0xd1ce, 0x00, 0}, - { 0xd1cf, 0xff, 0}, - { 0xd1d0, 0x8c, 0}, - { 0xd1d1, 0x67, 0}, - { 0xd1d2, 0x00, 0}, - { 0xd1d3, 0x00, 0}, - { 0xd1d4, 0xe0, 0}, - { 0xd1d5, 0x63, 0}, - { 0xd1d6, 0x20, 0}, - { 0xd1d7, 0x00, 0}, - { 0xd1d8, 0xa4, 0}, - { 0xd1d9, 0x63, 0 }, - { 0xd1da, 0xff, 0}, - { 0xd1db, 0xff, 0}, - { 0xd1dc, 0xbc, 0}, - { 0xd1dd, 0x43, 0}, - { 0xd1de, 0x00, 0}, - { 0xd1df, 0x07, 0}, - { 0xd1e0, 0x0c, 0}, - { 0xd1e1, 0x00, 0}, - { 0xd1e2, 0x00, 0}, - { 0xd1e3, 0x5b, 0}, - { 0xd1e4, 0xbc, 0}, - { 0xd1e5, 0x05, 0 }, - { 0xd1e6, 0x00, 0}, - { 0xd1e7, 0x02, 0}, - { 0xd1e8, 0x03, 0}, - { 0xd1e9, 0xff, 0}, - { 0xd1ea, 0xff, 0}, - { 0xd1eb, 0xf6, 0}, - { 0xd1ec, 0x9c, 0}, - { 0xd1ed, 0xa0, 0}, - { 0xd1ee, 0x00, 0}, - { 0xd1ef, 0x00, 0}, - { 0xd1f0, 0xa8, 0}, - { 0xd1f1, 0xa4, 0}, - { 0xd1f2, 0x55, 0}, - { 0xd1f3, 0x86, 0}, - { 0xd1f4, 0x8c, 0}, - { 0xd1f5, 0x63, 0}, - { 0xd1f6, 0x00, 0}, - { 0xd1f7, 0x00, 0}, - { 0xd1f8, 0xa8, 0}, - { 0xd1f9, 0xc4, 0}, - { 0xd1fa, 0x6e, 0}, - { 0xd1fb, 0x45, 0}, - { 0xd1fc, 0xa8, 0}, - { 0xd1fd, 0xe4, 0}, - { 0xd1fe, 0x55, 0}, - { 0xd1ff, 0x87, 0}, - { 0xd200, 0xd8, 0}, - { 0xd201, 0x05, 0}, - { 0xd202, 0x18, 0}, - { 0xd203, 0x00, 0}, - { 0xd204, 0x8c, 0}, - { 0xd205, 0x66, 0}, - { 0xd206, 0x00, 0}, - { 0xd207, 0x00, 0}, - { 0xd208, 0xa8, 0 }, - { 0xd209, 0xa4, 0}, - { 0xd20a, 0x6e, 0 }, - { 0xd20b, 0x46, 0}, - { 0xd20c, 0xd8, 0}, - { 0xd20d, 0x07, 0}, - { 0xd20e, 0x18, 0}, - { 0xd20f, 0x00, 0}, - { 0xd210, 0xa8, 0}, - { 0xd211, 0x84, 0 }, - { 0xd212, 0x55, 0}, - { 0xd213, 0x88, 0}, - { 0xd214, 0x8c, 0}, - { 0xd215, 0x65, 0}, - { 0xd216, 0x00, 0}, - { 0xd217, 0x00, 0}, - { 0xd218, 0xd8, 0}, - { 0xd219, 0x04, 0}, - { 0xd21a, 0x18, 0}, - { 0xd21b, 0x00, 0}, - { 0xd21c, 0x03, 0}, - { 0xd21d, 0xff, 0}, - { 0xd21e, 0xff, 0}, - { 0xd21f, 0xce, 0}, - { 0xd220, 0x19, 0}, - { 0xd221, 0x00, 0}, - { 0xd222, 0x80, 0}, - { 0xd223, 0x06, 0}, - { 0xd224, 0x8c, 0}, - { 0xd225, 0x63, 0}, - { 0xd226, 0x00, 0}, - { 0xd227, 0x00, 0 }, - { 0xd228, 0xa4, 0}, - { 0xd229, 0x63, 0}, - { 0xd22a, 0x00, 0}, - { 0xd22b, 0x40, 0}, - { 0xd22c, 0xbc, 0}, - { 0xd22d, 0x23, 0}, - { 0xd22e, 0x00, 0 }, - { 0xd22f, 0x00, 0 }, - { 0xd230, 0x13, 0}, - { 0xd231, 0xff, 0}, - { 0xd232, 0xff, 0 }, - { 0xd233, 0xc8, 0}, - { 0xd234, 0x9d, 0}, - { 0xd235, 0x00, 0}, - { 0xd236, 0x00, 0}, - { 0xd237, 0x40, 0}, - { 0xd238, 0xa8, 0}, - { 0xd239, 0x64, 0}, - { 0xd23a, 0x55, 0}, - { 0xd23b, 0x86, 0}, - { 0xd23c, 0xa8, 0 }, - { 0xd23d, 0xa4, 0}, - { 0xd23e, 0x55, 0}, - { 0xd23f, 0x87, 0}, - { 0xd240, 0xd8, 0}, - { 0xd241, 0x03, 0}, - { 0xd242, 0x40, 0}, - { 0xd243, 0x00, 0}, - { 0xd244, 0xa8, 0}, - { 0xd245, 0x64, 0}, - { 0xd246, 0x55, 0}, - { 0xd247, 0x88, 0}, - { 0xd248, 0xd8, 0}, - { 0xd249, 0x05, 0}, - { 0xd24a, 0x40, 0}, - { 0xd24b, 0x00, 0}, - { 0xd24c, 0xd8, 0}, - { 0xd24d, 0x03, 0}, - { 0xd24e, 0x40, 0}, - { 0xd24f, 0x00, 0 }, - { 0xd250, 0x03, 0}, - { 0xd251, 0xff, 0 }, - { 0xd252, 0xff, 0}, - { 0xd253, 0xc1, 0}, - { 0xd254, 0x19, 0}, - { 0xd255, 0x00, 0 }, - { 0xd256, 0x80, 0}, - { 0xd257, 0x06, 0}, - { 0xd258, 0x94, 0}, - { 0xd259, 0x84, 0}, - { 0xd25a, 0x00, 0}, - { 0xd25b, 0x72, 0}, - { 0xd25c, 0xe5, 0}, - { 0xd25d, 0xa4, 0}, - { 0xd25e, 0x60, 0}, - { 0xd25f, 0x00, 0}, - { 0xd260, 0x0c, 0}, - { 0xd261, 0x00, 0}, - { 0xd262, 0x00, 0 }, - { 0xd263, 0x3f, 0}, - { 0xd264, 0x9d, 0}, - { 0xd265, 0x60, 0}, - { 0xd266, 0x01, 0}, - { 0xd267, 0x00, 0}, - { 0xd268, 0x85, 0}, - { 0xd269, 0x4e, 0}, - { 0xd26a, 0x00, 0 }, - { 0xd26b, 0x00, 0}, - { 0xd26c, 0x98, 0}, - { 0xd26d, 0x70, 0}, - { 0xd26e, 0x00, 0 }, - { 0xd26f, 0x00, 0 }, - { 0xd270, 0x8c, 0}, - { 0xd271, 0x8a, 0}, - { 0xd272, 0x00, 0 }, - { 0xd273, 0x6f, 0}, - { 0xd274, 0xe5, 0}, - { 0xd275, 0x63, 0}, - { 0xd276, 0x20, 0}, - { 0xd277, 0x00, 0}, - { 0xd278, 0x10, 0}, - { 0xd279, 0x00, 0}, - { 0xd27a, 0x00, 0}, - { 0xd27b, 0x07, 0}, - { 0xd27c, 0x15, 0 }, - { 0xd27d, 0x00, 0 }, - { 0xd27e, 0x00, 0 }, - { 0xd27f, 0x00, 0 }, - { 0xd280, 0x8c, 0}, - { 0xd281, 0xaa, 0}, - { 0xd282, 0x00, 0}, - { 0xd283, 0x6e, 0}, - { 0xd284, 0xe0, 0}, - { 0xd285, 0x63, 0 }, - { 0xd286, 0x28, 0}, - { 0xd287, 0x02, 0}, - { 0xd288, 0xe0, 0}, - { 0xd289, 0x84, 0}, - { 0xd28a, 0x28, 0}, - { 0xd28b, 0x02, 0}, - { 0xd28c, 0x07, 0}, - { 0xd28d, 0xff, 0}, - { 0xd28e, 0xf8, 0}, - { 0xd28f, 0x66, 0}, - { 0xd290, 0xe0, 0}, - { 0xd291, 0x63, 0}, - { 0xd292, 0x5b, 0}, - { 0xd293, 0x06, 0}, - { 0xd294, 0x8c, 0}, - { 0xd295, 0x6a, 0}, - { 0xd296, 0x00, 0 }, - { 0xd297, 0x77, 0}, - { 0xd298, 0xe0, 0}, - { 0xd299, 0x63, 0}, - { 0xd29a, 0x5b, 0}, - { 0xd29b, 0x06, 0}, - { 0xd29c, 0xbd, 0}, - { 0xd29d, 0x63, 0}, - { 0xd29e, 0x00, 0 }, - { 0xd29f, 0x00, 0 }, - { 0xd2a0, 0x0c, 0}, - { 0xd2a1, 0x00, 0}, - { 0xd2a2, 0x00, 0}, - { 0xd2a3, 0x3c, 0}, - { 0xd2a4, 0x15, 0}, - { 0xd2a5, 0x00, 0}, - { 0xd2a6, 0x00, 0}, - { 0xd2a7, 0x00, 0 }, - { 0xd2a8, 0x8c, 0}, - { 0xd2a9, 0x8a, 0}, - { 0xd2aa, 0x00, 0}, - { 0xd2ab, 0x78, 0}, - { 0xd2ac, 0xb8, 0}, - { 0xd2ad, 0x63, 0}, - { 0xd2ae, 0x00, 0 }, - { 0xd2af, 0x88, 0}, - { 0xd2b0, 0xe1, 0}, - { 0xd2b1, 0x64, 0}, - { 0xd2b2, 0x5b, 0}, - { 0xd2b3, 0x06, 0}, - { 0xd2b4, 0xbd, 0}, - { 0xd2b5, 0x6b, 0}, - { 0xd2b6, 0x00, 0}, - { 0xd2b7, 0x00, 0 }, - { 0xd2b8, 0x0c, 0}, - { 0xd2b9, 0x00, 0}, - { 0xd2ba, 0x00, 0 }, - { 0xd2bb, 0x34, 0}, - { 0xd2bc, 0xd4, 0}, - { 0xd2bd, 0x01, 0}, - { 0xd2be, 0x18, 0 }, - { 0xd2bf, 0x14, 0}, - { 0xd2c0, 0xb9, 0}, - { 0xd2c1, 0x6b, 0}, - { 0xd2c2, 0x00, 0 }, - { 0xd2c3, 0x88, 0}, - { 0xd2c4, 0x85, 0}, - { 0xd2c5, 0x01, 0}, - { 0xd2c6, 0x00, 0}, - { 0xd2c7, 0x14, 0}, - { 0xd2c8, 0xbd, 0}, - { 0xd2c9, 0x68, 0}, - { 0xd2ca, 0x00, 0 }, - { 0xd2cb, 0x00, 0}, - { 0xd2cc, 0x0c, 0}, - { 0xd2cd, 0x00, 0}, - { 0xd2ce, 0x00, 0 }, - { 0xd2cf, 0x2c, 0}, - { 0xd2d0, 0xd4, 0}, - { 0xd2d1, 0x01, 0}, - { 0xd2d2, 0x58, 0}, - { 0xd2d3, 0x18, 0}, - { 0xd2d4, 0x84, 0}, - { 0xd2d5, 0x81, 0}, - { 0xd2d6, 0x00, 0 }, - { 0xd2d7, 0x14, 0}, - { 0xd2d8, 0xbd, 0}, - { 0xd2d9, 0xa4, 0}, - { 0xd2da, 0x01, 0}, - { 0xd2db, 0x00, 0}, - { 0xd2dc, 0x10, 0}, - { 0xd2dd, 0x00, 0}, - { 0xd2de, 0x00, 0}, - { 0xd2df, 0x05, 0}, - { 0xd2e0, 0x84, 0}, - { 0xd2e1, 0xc1, 0}, - { 0xd2e2, 0x00, 0}, - { 0xd2e3, 0x18, 0}, - { 0xd2e4, 0x9c, 0}, - { 0xd2e5, 0xa0, 0}, - { 0xd2e6, 0x01, 0}, - { 0xd2e7, 0x00, 0 }, - { 0xd2e8, 0xd4, 0}, - { 0xd2e9, 0x01, 0}, - { 0xd2ea, 0x28, 0}, - { 0xd2eb, 0x14, 0}, - { 0xd2ec, 0x84, 0}, - { 0xd2ed, 0xc1, 0}, - { 0xd2ee, 0x00, 0 }, - { 0xd2ef, 0x18, 0}, - { 0xd2f0, 0xbd, 0}, - { 0xd2f1, 0x66, 0}, - { 0xd2f2, 0x00, 0 }, - { 0xd2f3, 0x00, 0}, - { 0xd2f4, 0x0c, 0}, - { 0xd2f5, 0x00, 0}, - { 0xd2f6, 0x00, 0}, - { 0xd2f7, 0x20, 0}, - { 0xd2f8, 0x9d, 0}, - { 0xd2f9, 0x00, 0}, - { 0xd2fa, 0x00, 0 }, - { 0xd2fb, 0x00, 0}, - { 0xd2fc, 0x84, 0}, - { 0xd2fd, 0x61, 0}, - { 0xd2fe, 0x00, 0 }, - { 0xd2ff, 0x18, 0}, - { 0xd300, 0xbd, 0}, - { 0xd301, 0xa3, 0}, - { 0xd302, 0x01, 0}, - { 0xd303, 0x00, 0}, - { 0xd304, 0x10, 0}, - { 0xd305, 0x00, 0}, - { 0xd306, 0x00, 0}, - { 0xd307, 0x03, 0}, - { 0xd308, 0x9c, 0 }, - { 0xd309, 0x80, 0}, - { 0xd30a, 0x01, 0}, - { 0xd30b, 0x00, 0}, - { 0xd30c, 0xd4, 0}, - { 0xd30d, 0x01, 0}, - { 0xd30e, 0x20, 0}, - { 0xd30f, 0x18, 0}, - { 0xd310, 0x18, 0}, - { 0xd311, 0x60, 0}, - { 0xd312, 0x80, 0}, - { 0xd313, 0x06, 0}, - { 0xd314, 0x85, 0}, - { 0xd315, 0x01, 0}, - { 0xd316, 0x00, 0 }, - { 0xd317, 0x14, 0}, - { 0xd318, 0xa8, 0}, - { 0xd319, 0x83, 0}, - { 0xd31a, 0x38, 0}, - { 0xd31b, 0x29, 0}, - { 0xd31c, 0xa8, 0}, - { 0xd31d, 0xc3, 0}, - { 0xd31e, 0x40, 0}, - { 0xd31f, 0x08, 0}, - { 0xd320, 0x8c, 0}, - { 0xd321, 0x84, 0}, - { 0xd322, 0x00, 0}, - { 0xd323, 0x00, 0}, - { 0xd324, 0xa8, 0}, - { 0xd325, 0xa3, 0}, - { 0xd326, 0x38, 0}, - { 0xd327, 0x2a, 0}, - { 0xd328, 0xa8, 0}, - { 0xd329, 0xe3, 0}, - { 0xd32a, 0x40, 0}, - { 0xd32b, 0x09, 0}, - { 0xd32c, 0xe0, 0}, - { 0xd32d, 0x64, 0}, - { 0xd32e, 0x40, 0}, - { 0xd32f, 0x00, 0}, - { 0xd330, 0xd8, 0 }, - { 0xd331, 0x06, 0}, - { 0xd332, 0x18, 0}, - { 0xd333, 0x00, 0 }, - { 0xd334, 0x8c, 0}, - { 0xd335, 0x65, 0}, - { 0xd336, 0x00, 0}, - { 0xd337, 0x00, 0 }, - { 0xd338, 0x84, 0}, - { 0xd339, 0x81, 0}, - { 0xd33a, 0x00, 0 }, - { 0xd33b, 0x18, 0}, - { 0xd33c, 0xe3, 0}, - { 0xd33d, 0xe3, 0}, - { 0xd33e, 0x20, 0}, - { 0xd33f, 0x00, 0}, - { 0xd340, 0xd8, 0}, - { 0xd341, 0x07, 0}, - { 0xd342, 0xf8, 0}, - { 0xd343, 0x00, 0}, - { 0xd344, 0x03, 0}, - { 0xd345, 0xff, 0}, - { 0xd346, 0xff, 0}, - { 0xd347, 0x6f, 0}, - { 0xd348, 0x18, 0}, - { 0xd349, 0x60, 0}, - { 0xd34a, 0x00, 0 }, - { 0xd34b, 0x01, 0}, - { 0xd34c, 0x0f, 0}, - { 0xd34d, 0xff, 0 }, - { 0xd34e, 0xff, 0 }, - { 0xd34f, 0x9d, 0}, - { 0xd350, 0x18, 0}, - { 0xd351, 0x60, 0}, - { 0xd352, 0x80, 0}, - { 0xd353, 0x06, 0}, - { 0xd354, 0x00, 0}, - { 0xd355, 0x00, 0 }, - { 0xd356, 0x00, 0}, - { 0xd357, 0x11, 0}, - { 0xd358, 0xa8, 0}, - { 0xd359, 0x83, 0}, - { 0xd35a, 0x6e, 0}, - { 0xd35b, 0x43, 0}, - { 0xd35c, 0xe0, 0}, - { 0xd35d, 0x6c, 0}, - { 0xd35e, 0x28, 0}, - { 0xd35f, 0x02, 0}, - { 0xd360, 0xe0, 0}, - { 0xd361, 0x84, 0}, - { 0xd362, 0x28, 0}, - { 0xd363, 0x02, 0}, - { 0xd364, 0x07, 0}, - { 0xd365, 0xff, 0}, - { 0xd366, 0xf8, 0}, - { 0xd367, 0x30, 0}, - { 0xd368, 0xb8, 0}, - { 0xd369, 0x63, 0}, - { 0xd36a, 0x00, 0}, - { 0xd36b, 0x08, 0}, - { 0xd36c, 0x03, 0}, - { 0xd36d, 0xff, 0}, - { 0xd36e, 0xff, 0}, - { 0xd36f, 0xc0, 0}, - { 0xd370, 0x85, 0}, - { 0xd371, 0x4e, 0}, - { 0xd372, 0x00, 0}, - { 0xd373, 0x00, 0}, - { 0xd374, 0x03, 0}, - { 0xd375, 0xff, 0}, - { 0xd376, 0xff, 0}, - { 0xd377, 0xe7, 0}, - { 0xd378, 0xd4, 0}, - { 0xd379, 0x01, 0}, - { 0xd37a, 0x40, 0}, - { 0xd37b, 0x18, 0}, - { 0xd37c, 0x9c, 0}, - { 0xd37d, 0x60, 0}, - { 0xd37e, 0x00, 0}, - { 0xd37f, 0x00, 0}, - { 0xd380, 0x03, 0}, - { 0xd381, 0xff, 0}, - { 0xd382, 0xff, 0}, - { 0xd383, 0xdb, 0}, - { 0xd384, 0xd4, 0}, - { 0xd385, 0x01, 0}, - { 0xd386, 0x18, 0}, - { 0xd387, 0x14, 0}, - { 0xd388, 0x03, 0}, - { 0xd389, 0xff, 0}, - { 0xd38a, 0xff, 0}, - { 0xd38b, 0xce, 0}, - { 0xd38c, 0x9d, 0}, - { 0xd38d, 0x6b, 0}, - { 0xd38e, 0x00, 0}, - { 0xd38f, 0xff, 0}, - { 0xd390, 0x03, 0}, - { 0xd391, 0xff, 0}, - { 0xd392, 0xff, 0}, - { 0xd393, 0xc6, 0}, - { 0xd394, 0x9c, 0}, - { 0xd395, 0x63, 0}, - { 0xd396, 0x00, 0}, - { 0xd397, 0xff, 0}, - { 0xd398, 0xa8, 0}, - { 0xd399, 0xe3, 0}, - { 0xd39a, 0x38, 0}, - { 0xd39b, 0x0f, 0}, - { 0xd39c, 0x8c, 0}, - { 0xd39d, 0x84, 0}, - { 0xd39e, 0x00, 0}, - { 0xd39f, 0x00, 0}, - { 0xd3a0, 0xa8, 0}, - { 0xd3a1, 0xa3, 0}, - { 0xd3a2, 0x38, 0}, - { 0xd3a3, 0x0e, 0}, - { 0xd3a4, 0xa8, 0}, - { 0xd3a5, 0xc3, 0}, - { 0xd3a6, 0x6e, 0}, - { 0xd3a7, 0x42, 0}, - { 0xd3a8, 0xd8, 0}, - { 0xd3a9, 0x07, 0}, - { 0xd3aa, 0x20, 0}, - { 0xd3ab, 0x00, 0}, - { 0xd3ac, 0x8c, 0}, - { 0xd3ad, 0x66, 0}, - { 0xd3ae, 0x00, 0}, - { 0xd3af, 0x00, 0}, - { 0xd3b0, 0xd8, 0}, - { 0xd3b1, 0x05, 0}, - { 0xd3b2, 0x18, 0}, - { 0xd3b3, 0x00, 0}, - { 0xd3b4, 0x85, 0}, - { 0xd3b5, 0x21, 0}, - { 0xd3b6, 0x00, 0}, - { 0xd3b7, 0x00, 0}, - { 0xd3b8, 0x85, 0}, - { 0xd3b9, 0x41, 0}, - { 0xd3ba, 0x00, 0}, - { 0xd3bb, 0x04, 0}, - { 0xd3bc, 0x85, 0}, - { 0xd3bd, 0x81, 0}, - { 0xd3be, 0x00, 0}, - { 0xd3bf, 0x08, 0}, - { 0xd3c0, 0x85, 0}, - { 0xd3c1, 0xc1, 0}, - { 0xd3c2, 0x00, 0}, - { 0xd3c3, 0x0c, 0}, - { 0xd3c4, 0x86, 0}, - { 0xd3c5, 0x01, 0}, - { 0xd3c6, 0x00, 0}, - { 0xd3c7, 0x10, 0}, - { 0xd3c8, 0x44, 0}, - { 0xd3c9, 0x00, 0}, - { 0xd3ca, 0x48, 0}, - { 0xd3cb, 0x00, 0}, - { 0xd3cc, 0x9c, 0}, - { 0xd3cd, 0x21, 0}, - { 0xd3ce, 0x00, 0}, - { 0xd3cf, 0x1c, 0}, - { 0xd3d0, 0x9c, 0}, - { 0xd3d1, 0x21, 0}, - { 0xd3d2, 0xff, 0}, - { 0xd3d3, 0xfc, 0}, - { 0xd3d4, 0xd4, 0}, - { 0xd3d5, 0x01, 0}, - { 0xd3d6, 0x48, 0}, - { 0xd3d7, 0x00, 0}, - { 0xd3d8, 0x18, 0}, - { 0xd3d9, 0x60, 0}, - { 0xd3da, 0x00, 0}, - { 0xd3db, 0x01, 0}, - { 0xd3dc, 0xa8, 0}, - { 0xd3dd, 0x63, 0}, - { 0xd3de, 0x07, 0}, - { 0xd3df, 0x80, 0}, - { 0xd3e0, 0x8c, 0}, - { 0xd3e1, 0x63, 0}, - { 0xd3e2, 0x00, 0}, - { 0xd3e3, 0x68, 0}, - { 0xd3e4, 0xbc, 0}, - { 0xd3e5, 0x03, 0}, - { 0xd3e6, 0x00, 0}, - { 0xd3e7, 0x00, 0}, - { 0xd3e8, 0x10, 0}, - { 0xd3e9, 0x00, 0}, - { 0xd3ea, 0x00, 0}, - { 0xd3eb, 0x0c, 0}, - { 0xd3ec, 0x15, 0}, - { 0xd3ed, 0x00, 0}, - { 0xd3ee, 0x00, 0}, - { 0xd3ef, 0x00, 0}, - { 0xd3f0, 0x07, 0}, - { 0xd3f1, 0xff, 0}, - { 0xd3f2, 0xd9, 0}, - { 0xd3f3, 0x98, 0}, - { 0xd3f4, 0x15, 0}, - { 0xd3f5, 0x00, 0}, - { 0xd3f6, 0x00, 0}, - { 0xd3f7, 0x00, 0}, - { 0xd3f8, 0x18, 0}, - { 0xd3f9, 0x60, 0}, - { 0xd3fa, 0x80, 0}, - { 0xd3fb, 0x06, 0}, - { 0xd3fc, 0xa8, 0}, - { 0xd3fd, 0x63, 0}, - { 0xd3fe, 0xc4, 0}, - { 0xd3ff, 0xb8, 0}, - { 0xd400, 0x8c, 0}, - { 0xd401, 0x63, 0}, - { 0xd402, 0x00, 0}, - { 0xd403, 0x00, 0}, - { 0xd404, 0xbc, 0}, - { 0xd405, 0x23, 0}, - { 0xd406, 0x00, 0}, - { 0xd407, 0x01, 0}, - { 0xd408, 0x10, 0}, - { 0xd409, 0x00, 0}, - { 0xd40a, 0x00, 0}, - { 0xd40b, 0x25, 0}, - { 0xd40c, 0x9d, 0}, - { 0xd40d, 0x00, 0}, - { 0xd40e, 0x00, 0}, - { 0xd40f, 0x00, 0}, - { 0xd410, 0x00, 0}, - { 0xd411, 0x00, 0}, - { 0xd412, 0x00, 0}, - { 0xd413, 0x0b, 0}, - { 0xd414, 0xb8, 0}, - { 0xd415, 0xe8, 0}, - { 0xd416, 0x00, 0}, - { 0xd417, 0x02, 0}, - { 0xd418, 0x07, 0}, - { 0xd419, 0xff, 0}, - { 0xd41a, 0xd6, 0}, - { 0xd41b, 0x24, 0}, - { 0xd41c, 0x15, 0}, - { 0xd41d, 0x00, 0}, - { 0xd41e, 0x00, 0}, - { 0xd41f, 0x00, 0}, - { 0xd420, 0x18, 0}, - { 0xd421, 0x60, 0}, - { 0xd422, 0x80, 0}, - { 0xd423, 0x06, 0}, - { 0xd424, 0xa8, 0}, - { 0xd425, 0x63, 0}, - { 0xd426, 0xc4, 0}, - { 0xd427, 0xb8, 0}, - { 0xd428, 0x8c, 0}, - { 0xd429, 0x63, 0}, - { 0xd42a, 0x00, 0}, - { 0xd42b, 0x00, 0}, - { 0xd42c, 0xbc, 0}, - { 0xd42d, 0x23, 0}, - { 0xd42e, 0x00, 0}, - { 0xd42f, 0x01, 0}, - { 0xd430, 0x10, 0}, - { 0xd431, 0x00, 0}, - { 0xd432, 0x00, 0}, - { 0xd433, 0x1b, 0}, - { 0xd434, 0x9d, 0}, - { 0xd435, 0x00, 0}, - { 0xd436, 0x00, 0}, - { 0xd437, 0x00, 0}, - { 0xd438, 0xb8, 0}, - { 0xd439, 0xe8, 0}, - { 0xd43a, 0x00, 0}, - { 0xd43b, 0x02, 0}, - { 0xd43c, 0x9c, 0}, - { 0xd43d, 0xc0, 0}, - { 0xd43e, 0x00, 0}, - { 0xd43f, 0x00, 0}, - { 0xd440, 0x18, 0}, - { 0xd441, 0xa0, 0}, - { 0xd442, 0x80, 0}, - { 0xd443, 0x06, 0}, - { 0xd444, 0xe0, 0}, - { 0xd445, 0x67, 0}, - { 0xd446, 0x30, 0}, - { 0xd447, 0x00, 0}, - { 0xd448, 0xa8, 0}, - { 0xd449, 0xa5, 0}, - { 0xd44a, 0xce, 0}, - { 0xd44b, 0xb0, 0}, - { 0xd44c, 0x19, 0}, - { 0xd44d, 0x60, 0}, - { 0xd44e, 0x00, 0}, - { 0xd44f, 0x01, 0}, - { 0xd450, 0xa9, 0}, - { 0xd451, 0x6b, 0}, - { 0xd452, 0x06, 0}, - { 0xd453, 0x14, 0}, - { 0xd454, 0xe0, 0}, - { 0xd455, 0x83, 0}, - { 0xd456, 0x28, 0}, - { 0xd457, 0x00, 0}, - { 0xd458, 0x9c, 0}, - { 0xd459, 0xc6, 0}, - { 0xd45a, 0x00, 0}, - { 0xd45b, 0x01, 0}, - { 0xd45c, 0xe0, 0}, - { 0xd45d, 0x63, 0}, - { 0xd45e, 0x18, 0}, - { 0xd45f, 0x00, 0}, - { 0xd460, 0x8c, 0}, - { 0xd461, 0x84, 0}, - { 0xd462, 0x00, 0}, - { 0xd463, 0x00, 0}, - { 0xd464, 0xe0, 0}, - { 0xd465, 0xa3, 0}, - { 0xd466, 0x58, 0}, - { 0xd467, 0x00, 0}, - { 0xd468, 0xa4, 0}, - { 0xd469, 0xc6, 0}, - { 0xd46a, 0x00, 0}, - { 0xd46b, 0xff, 0}, - { 0xd46c, 0xb8, 0}, - { 0xd46d, 0x64, 0}, - { 0xd46e, 0x00, 0}, - { 0xd46f, 0x18, 0}, - { 0xd470, 0xbc, 0}, - { 0xd471, 0x46, 0}, - { 0xd472, 0x00, 0}, - { 0xd473, 0x03, 0}, - { 0xd474, 0x94, 0}, - { 0xd475, 0x85, 0}, - { 0xd476, 0x00, 0}, - { 0xd477, 0x00, 0}, - { 0xd478, 0xb8, 0}, - { 0xd479, 0x63, 0}, - { 0xd47a, 0x00, 0}, - { 0xd47b, 0x98, 0}, - { 0xd47c, 0xe0, 0}, - { 0xd47d, 0x64, 0}, - { 0xd47e, 0x18, 0}, - { 0xd47f, 0x00, 0}, - { 0xd480, 0x0f, 0}, - { 0xd481, 0xff, 0}, - { 0xd482, 0xff, 0}, - { 0xd483, 0xf0, 0}, - { 0xd484, 0xdc, 0}, - { 0xd485, 0x05, 0}, - { 0xd486, 0x18, 0}, - { 0xd487, 0x00, 0}, - { 0xd488, 0x9c, 0}, - { 0xd489, 0x68, 0}, - { 0xd48a, 0x00, 0}, - { 0xd48b, 0x01, 0}, - { 0xd48c, 0xa5, 0}, - { 0xd48d, 0x03, 0}, - { 0xd48e, 0x00, 0}, - { 0xd48f, 0xff, 0}, - { 0xd490, 0xbc, 0}, - { 0xd491, 0x48, 0}, - { 0xd492, 0x00, 0}, - { 0xd493, 0x01, 0}, - { 0xd494, 0x0f, 0}, - { 0xd495, 0xff, 0}, - { 0xd496, 0xff, 0}, - { 0xd497, 0xea, 0}, - { 0xd498, 0xb8, 0}, - { 0xd499, 0xe8, 0}, - { 0xd49a, 0x00, 0}, - { 0xd49b, 0x02, 0}, - { 0xd49c, 0x18, 0}, - { 0xd49d, 0x60, 0}, - { 0xd49e, 0x00, 0}, - { 0xd49f, 0x01, 0}, - { 0xd4a0, 0xa8, 0}, - { 0xd4a1, 0x63, 0}, - { 0xd4a2, 0x06, 0}, - { 0xd4a3, 0x14, 0}, - { 0xd4a4, 0x07, 0}, - { 0xd4a5, 0xff, 0}, - { 0xd4a6, 0xe4, 0}, - { 0xd4a7, 0x05, 0}, - { 0xd4a8, 0x9c, 0}, - { 0xd4a9, 0x83, 0}, - { 0xd4aa, 0x00, 0}, - { 0xd4ab, 0x10, 0}, - { 0xd4ac, 0x85, 0}, - { 0xd4ad, 0x21, 0}, - { 0xd4ae, 0x00, 0}, - { 0xd4af, 0x00, 0}, - { 0xd4b0, 0x44, 0}, - { 0xd4b1, 0x00, 0}, - { 0xd4b2, 0x48, 0}, - { 0xd4b3, 0x00, 0}, - { 0xd4b4, 0x9c, 0}, - { 0xd4b5, 0x21, 0}, - { 0xd4b6, 0x00, 0}, - { 0xd4b7, 0x04, 0}, - { 0xd4b8, 0x18, 0}, - { 0xd4b9, 0x60, 0}, - { 0xd4ba, 0x00, 0}, - { 0xd4bb, 0x01, 0}, - { 0xd4bc, 0x9c, 0}, - { 0xd4bd, 0x80, 0}, - { 0xd4be, 0xff, 0}, - { 0xd4bf, 0xff, 0}, - { 0xd4c0, 0xa8, 0}, - { 0xd4c1, 0x63, 0}, - { 0xd4c2, 0x09, 0}, - { 0xd4c3, 0xef, 0}, - { 0xd4c4, 0xd8, 0}, - { 0xd4c5, 0x03, 0}, - { 0xd4c6, 0x20, 0}, - { 0xd4c7, 0x00, 0}, - { 0xd4c8, 0x18, 0}, - { 0xd4c9, 0x60, 0}, - { 0xd4ca, 0x80, 0}, - { 0xd4cb, 0x06, 0}, - { 0xd4cc, 0xa8, 0}, - { 0xd4cd, 0x63, 0}, - { 0xd4ce, 0xc9, 0}, - { 0xd4cf, 0xef, 0}, - { 0xd4d0, 0xd8, 0}, - { 0xd4d1, 0x03, 0}, - { 0xd4d2, 0x20, 0}, - { 0xd4d3, 0x00, 0}, - { 0xd4d4, 0x44, 0}, - { 0xd4d5, 0x00, 0}, - { 0xd4d6, 0x48, 0}, - { 0xd4d7, 0x00, 0}, - { 0xd4d8, 0x15, 0}, - { 0xd4d9, 0x00, 0}, - { 0xd4da, 0x00, 0}, - { 0xd4db, 0x00, 0}, - { 0xd4dc, 0x18, 0}, - { 0xd4dd, 0x80, 0}, - { 0xd4de, 0x00, 0}, - { 0xd4df, 0x01, 0}, - { 0xd4e0, 0xa8, 0}, - { 0xd4e1, 0x84, 0}, - { 0xd4e2, 0x0a, 0}, - { 0xd4e3, 0x12, 0}, - { 0xd4e4, 0x8c, 0}, - { 0xd4e5, 0x64, 0}, - { 0xd4e6, 0x00, 0}, - { 0xd4e7, 0x00, 0}, - { 0xd4e8, 0xbc, 0}, - { 0xd4e9, 0x03, 0}, - { 0xd4ea, 0x00, 0}, - { 0xd4eb, 0x00, 0}, - { 0xd4ec, 0x13, 0}, - { 0xd4ed, 0xff, 0}, - { 0xd4ee, 0xff, 0}, - { 0xd4ef, 0xfe, 0}, - { 0xd4f0, 0x15, 0}, - { 0xd4f1, 0x00, 0}, - { 0xd4f2, 0x00, 0}, - { 0xd4f3, 0x00, 0}, - { 0xd4f4, 0x44, 0}, - { 0xd4f5, 0x00, 0}, - { 0xd4f6, 0x48, 0}, - { 0xd4f7, 0x00, 0}, - { 0xd4f8, 0x15, 0}, - { 0xd4f9, 0x00, 0}, - { 0xd4fa, 0x00, 0}, - { 0xd4fb, 0x00, 0}, - { 0xd4fc, 0x00, 0}, - { 0xd4fd, 0x00, 0}, - { 0xd4fe, 0x00, 0}, - { 0xd4ff, 0x00, 0}, - { 0xd500, 0x00, 0}, - { 0xd501, 0x00, 0}, - { 0xd502, 0x00, 0}, - { 0xd503, 0x00, 0}, - { 0x6f0e, 0x33, 0 }, - { 0x6f0f, 0x33, 0 }, - { 0x460e, 0x08, 0 }, - { 0x460f, 0x01, 0 }, - { 0x4610, 0x00, 0 }, - { 0x4611, 0x01, 0 }, - { 0x4612, 0x00, 0 }, - { 0x4613, 0x01, 0 }, - { 0x4605, 0x08, 0}, - { 0x4608, 0x00, 0 }, - { 0x4609, 0x08, 0 }, - { 0x6804, 0x00, 0 }, - { 0x6805, 0x06, 0 }, - { 0x6806, 0x00, 0 }, - { 0x5120, 0x00, 0 }, - { 0x3510, 0x00, 0 }, - { 0x3504, 0x00, 0 }, - { 0x6800, 0x00, 0 }, - { 0x6f0d, 0x0f, 0 }, - { 0x5000, 0xff, 0 }, - { 0x5001, 0xbf, 0 }, - { 0x5002, 0x7e, 0 }, - { 0x5003, 0x0c, 0}, - { 0x503d, 0x00, 0 }, - { 0xc450, 0x01, 0 }, - { 0xc452, 0x04, 0 }, - { 0xc453, 0x00, 0 }, - { 0xc454, 0x00, 0 }, - { 0xc455, 0x00, 0 }, - { 0xc456, 0x00, 0 }, - { 0xc457, 0x00, 0 }, - { 0xc458, 0x00, 0 }, - { 0xc459, 0x00, 0 }, - { 0xc45b, 0x00, 0 }, - { 0xc45c, 0x00, 0 }, - { 0xc45d, 0x00, 0 }, - { 0xc45e, 0x00, 0 }, - { 0xc45f, 0x00, 0 }, - { 0xc460, 0x00, 0 }, - { 0xc461, 0x01, 0 }, - { 0xc462, 0x01, 0 }, - { 0xc464, 0x88, 0 }, - { 0xc465, 0x00, 0 }, - { 0xc466, 0x8a, 0 }, - { 0xc467, 0x00, 0 }, - { 0xc468, 0x86, 0 }, - { 0xc469, 0x00, 0 }, - { 0xc46a, 0x40, 0 }, - { 0xc46b, 0x50, 0 }, - { 0xc46c, 0x30, 0 }, - { 0xc46d, 0x28, 0 }, - { 0xc46e, 0x60, 0 }, - { 0xc46f, 0x40, 0 }, - { 0xc47c, 0x01, 0 }, - { 0xc47d, 0x38, 0 }, - { 0xc47e, 0x00, 0 }, - { 0xc47f, 0x00, 0 }, - { 0xc480, 0x00, 0 }, - { 0xc481, 0xff, 0 }, - { 0xc482, 0x00, 0 }, - { 0xc483, 0x40, 0 }, - { 0xc484, 0x00, 0 }, - { 0xc485, 0x18, 0 }, - { 0xc486, 0x00, 0 }, - { 0xc487, 0x18, 0 }, - { 0xc488, 0x34, 0 }, - { 0xc489, 0x00, 0 }, - { 0xc48a, 0x34, 0 }, - { 0xc48b, 0x00, 0 }, - { 0xc48c, 0x00, 0 }, - { 0xc48d, 0x04, 0 }, - { 0xc48e, 0x00, 0 }, - { 0xc48f, 0x04, 0 }, - { 0xc490, 0x07, 0 }, - { 0xc492, 0x20, 0 }, - { 0xc493, 0x08, 0 }, - { 0xc498, 0x02, 0 }, - { 0xc499, 0x00, 0 }, - { 0xc49a, 0x02, 0 }, - { 0xc49b, 0x00, 0 }, - { 0xc49c, 0x02, 0 }, - { 0xc49d, 0x00, 0 }, - { 0xc49e, 0x02, 0 }, - { 0xc49f, 0x60, 0 }, - { 0xc4a0, 0x03, 0 }, - { 0xc4a1, 0x00, 0 }, - { 0xc4a2, 0x04, 0 }, - { 0xc4a3, 0x00, 0 }, - { 0xc4a4, 0x00, 0 }, - { 0xc4a5, 0x10, 0 }, - { 0xc4a6, 0x00, 0 }, - { 0xc4a7, 0x40, 0 }, - { 0xc4a8, 0x00, 0 }, - { 0xc4a9, 0x80, 0 }, - { 0xc4aa, 0x0d, 0 }, - { 0xc4ab, 0x00, 0 }, - { 0xc4ac, 0x0f, 0 }, - { 0xc4ad, 0xc0, 0 }, - { 0xc4b4, 0x01, 0 }, - { 0xc4b5, 0x01, 0 }, - { 0xc4b6, 0x00, 0 }, - { 0xc4b7, 0x01, 0 }, - { 0xc4b8, 0x00, 0 }, - { 0xc4b9, 0x01, 0 }, - { 0xc4ba, 0x01, 0 }, - { 0xc4bb, 0x00, 0 }, - { 0xc4bc, 0x01, 0 }, - { 0xc4bd, 0x60, 0 }, - { 0xc4be, 0x02, 0 }, - { 0xc4bf, 0x33, 0 }, - { 0xc4c8, 0x03, 0 }, - { 0xc4c9, 0xd0, 0 }, - { 0xc4ca, 0x0e, 0 }, - { 0xc4cb, 0x00, 0 }, - { 0xc4cc, 0x10, 0 }, - { 0xc4cd, 0x18, 0 }, - { 0xc4ce, 0x10, 0 }, - { 0xc4cf, 0x18, 0 }, - { 0xc4d0, 0x04, 0 }, - { 0xc4d1, 0x80, 0 }, - { 0xc4e0, 0x04, 0 }, - { 0xc4e1, 0x02, 0 }, - { 0xc4e2, 0x01, 0 }, - { 0xc4e4, 0x10, 0 }, - { 0xc4e5, 0x20, 0 }, - { 0xc4e6, 0x30, 0 }, - { 0xc4e7, 0x40, 0 }, - { 0xc4e8, 0x50, 0 }, - { 0xc4e9, 0x60, 0 }, - { 0xc4ea, 0x70, 0 }, - { 0xc4eb, 0x80, 0 }, - { 0xc4ec, 0x90, 0 }, - { 0xc4ed, 0xa0, 0 }, - { 0xc4ee, 0xb0, 0 }, - { 0xc4ef, 0xc0, 0 }, - { 0xc4f0, 0xd0, 0 }, - { 0xc4f1, 0xe0, 0 }, - { 0xc4f2, 0xf0, 0 }, - { 0xc4f3, 0x80, 0 }, - { 0xc4f4, 0x00, 0 }, - { 0xc4f5, 0x20, 0 }, - { 0xc4f6, 0x02, 0 }, - { 0xc4f7, 0x00, 0 }, - { 0xc4f8, 0x04, 0 }, - { 0xc4f9, 0x0b, 0 }, - { 0xc4fa, 0x00, 0 }, - { 0xc4fb, 0x00, 0}, - { 0xc4fc, 0x01, 0 }, - { 0xc4fd, 0x00, 0 }, - { 0xc4fe, 0x04, 0 }, - { 0xc4ff, 0x02, 0 }, - { 0xc500, 0x48, 0 }, - { 0xc501, 0x74, 0 }, - { 0xc502, 0x58, 0 }, - { 0xc503, 0x80, 0 }, - { 0xc504, 0x05, 0 }, - { 0xc505, 0x80, 0 }, - { 0xc506, 0x03, 0 }, - { 0xc507, 0x80, 0 }, - { 0xc508, 0x01, 0 }, - { 0xc509, 0xc0, 0 }, - { 0xc50a, 0x01, 0 }, - { 0xc50b, 0xa0, 0 }, - { 0xc50c, 0x01, 0 }, - { 0xc50d, 0x2c, 0 }, - { 0xc50e, 0x01, 0 }, - { 0xc50f, 0x0a, 0 }, - { 0xc510, 0x00, 0 }, - { 0xc511, 0x01, 0 }, - { 0xc512, 0x01, 0 }, - { 0xc513, 0x80, 0 }, - { 0xc514, 0x04, 0 }, - { 0xc515, 0x00, 0 }, - { 0xc518, 0x03, 0 }, - { 0xc519, 0x48, 0 }, - { 0xc51a, 0x07, 0 }, - { 0xc51b, 0x70, 0 }, - { 0xc2e0, 0x00, 0 }, - { 0xc2e1, 0x51, 0 }, - { 0xc2e2, 0x00, 0 }, - { 0xc2e3, 0xd6, 0 }, - { 0xc2e4, 0x01, 0 }, - { 0xc2e5, 0x5e, 0 }, - { 0xc2e9, 0x01, 0 }, - { 0xc2ea, 0x7a, 0 }, - { 0xc2eb, 0x90, 0 }, - { 0xc2ed, 0x00, 0 }, - { 0xc2ee, 0x7a, 0 }, - { 0xc2ef, 0x64, 0 }, - { 0xc308, 0x00, 0 }, - { 0xc309, 0x00, 0 }, - { 0xc30a, 0x00, 0 }, - { 0xc30c, 0x00, 0 }, - { 0xc30d, 0x01, 0 }, - { 0xc30e, 0x00, 0 }, - { 0xc30f, 0x00, 0 }, - { 0xc310, 0x01, 0 }, - { 0xc311, 0x60, 0 }, - { 0xc312, 0xff, 0 }, - { 0xc313, 0x08, 0 }, - { 0xc314, 0x01, 0 }, - { 0xc315, 0x7f, 0 }, - { 0xc316, 0xff, 0 }, - { 0xc317, 0x0b, 0 }, - { 0xc318, 0x00, 0 }, - { 0xc319, 0x0c, 0 }, - { 0xc31a, 0x00, 0 }, - { 0xc31b, 0xe0, 0 }, - { 0xc31c, 0x00, 0 }, - { 0xc31d, 0x14, 0 }, - { 0xc31e, 0x00, 0 }, - { 0xc31f, 0xc5, 0 }, - { 0xc320, 0xff, 0 }, - { 0xc321, 0x4b, 0 }, - { 0xc322, 0xff, 0 }, - { 0xc323, 0xf0, 0 }, - { 0xc324, 0xff, 0 }, - { 0xc325, 0xe8, 0 }, - { 0xc326, 0x00, 0 }, - { 0xc327, 0x46, 0 }, - { 0xc328, 0xff, 0 }, - { 0xc329, 0xd2, 0 }, - { 0xc32a, 0xff, 0 }, - { 0xc32b, 0xe4, 0 }, - { 0xc32c, 0xff, 0 }, - { 0xc32d, 0xbb, 0 }, - { 0xc32e, 0x00, 0 }, - { 0xc32f, 0x61, 0 }, - { 0xc330, 0xff, 0 }, - { 0xc331, 0xf9, 0 }, - { 0xc332, 0x00, 0 }, - { 0xc333, 0xd9, 0 }, - { 0xc334, 0x00, 0 }, - { 0xc335, 0x2e, 0 }, - { 0xc336, 0x00, 0 }, - { 0xc337, 0xb1, 0 }, - { 0xc338, 0xff, 0 }, - { 0xc339, 0x64, 0 }, - { 0xc33a, 0xff, 0 }, - { 0xc33b, 0xeb, 0 }, - { 0xc33c, 0xff, 0 }, - { 0xc33d, 0xe8, 0 }, - { 0xc33e, 0x00, 0 }, - { 0xc33f, 0x48, 0 }, - { 0xc340, 0xff, 0 }, - { 0xc341, 0xd0, 0 }, - { 0xc342, 0xff, 0 }, - { 0xc343, 0xed, 0 }, - { 0xc344, 0xff, 0 }, - { 0xc345, 0xad, 0 }, - { 0xc346, 0x00, 0 }, - { 0xc347, 0x66, 0 }, - { 0xc348, 0x01, 0 }, - { 0xc349, 0x00, 0 }, - { 0x6700, 0x04, 0 }, - { 0x6701, 0x7b, 0 }, - { 0x6702, 0xfd, 0 }, - { 0x6703, 0xf9, 0 }, - { 0x6704, 0x3d, 0 }, - { 0x6705, 0x71, 0 }, - { 0x6706, 0x78, 0 }, - { 0x6708, 0x05, 0 }, - { 0x6f06, 0x6f, 0 }, - { 0x6f07, 0x00, 0 }, - { 0x6f0a, 0x6f, 0 }, - { 0x6f0b, 0x00, 0 }, - { 0x6f00, 0x03, 0 }, - { 0xc34c, 0x01, 0 }, - { 0xc34d, 0x00, 0 }, - { 0xc34e, 0x46, 0 }, - { 0xc34f, 0x55, 0 }, - { 0xc350, 0x00, 0 }, - { 0xc351, 0x40, 0 }, - { 0xc352, 0x00, 0 }, - { 0xc353, 0xff, 0 }, - { 0xc354, 0x04, 0 }, - { 0xc355, 0x08, 0 }, - { 0xc356, 0x01, 0 }, - { 0xc357, 0xef, 0 }, - { 0xc358, 0x30, 0 }, - { 0xc359, 0x01, 0 }, - { 0xc35a, 0x64, 0 }, - { 0xc35b, 0x46, 0 }, - { 0xc35c, 0x00, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x3042, 0xf0, 0 }, - { 0x301b, 0xf0, 0 }, - { 0x301c, 0xf0, 0 }, - { 0x301a, 0xf0, 0 }, - - { 0xceb0, 0x00, 0 }, - { 0xceb1, 0x00, 0 }, - { 0xceb2, 0x00, 0 }, - { 0xceb3, 0x00, 0 }, - { 0xceb4, 0x00, 0 }, - { 0xceb5, 0x00, 0 }, - { 0xceb6, 0x00, 0 }, - { 0xceb7, 0x00, 0 }, - { 0xc4bc, 0x01, 0 }, - { 0xc4bd, 0x60, 0 }, - - { 0x301b, 0xf1, 0 }, //PLL - { 0x3003, 0x18, 0 }, - { 0x3004, 0x11, 0 }, - { 0x3005, 0x12, 0 }, - { 0x3006, 0x11, 0 }, - { 0x3024, 0x00, 0 }, - { 0x3621, 0x63, 0 }, - { 0x3702, 0x20, 0 }, - { 0x3703, 0x48, 0 }, - { 0x3704, 0x32, 0 }, - { 0x3800, 0x00, 0 }, - { 0x3801, 0x00, 0 }, - { 0x3802, 0x00, 0 }, - { 0x3803, 0x04, 0 }, - { 0x3804, 0x00, 0 }, - { 0x3805, 0xFF, 0 }, - { 0x3806, 0x03, 0 }, - { 0x3807, 0x29, 0 }, - { 0x3808, 0x05, 0 }, - { 0x3809, 0x00, 0 }, - { 0x380a, 0x03, 0 }, - { 0x380b, 0x20, 0 }, - { 0x380c, 0x07, 0 }, - { 0x380d, 0x70, 0 }, - { 0x6e42, 0x03, 0 }, - { 0x6e43, 0x48, 0 }, - { 0x3810, 0x00, 0 }, - { 0x3811, 0x10, 0 }, - { 0x3812, 0x00, 0 }, - { 0x3813, 0x02, 0 }, - { 0x381c, 0x00, 0 }, - { 0x381e, 0x00, 0 }, - { 0x381f, 0x0C, 0 }, - { 0x4001, 0x06, 0 }, - { 0x4004, 0x04, 0 }, - { 0x4050, 0x22, 0 }, - { 0x4051, 0x24, 0 }, - { 0x4605, 0x0C, 0 }, - { 0x4606, 0x0B, 0 }, - { 0x4607, 0x28, 0 }, - { 0xc488, 0x34, 0 }, - { 0xc489, 0x00, 0 }, - { 0xc48a, 0x34, 0 }, - { 0xc48b, 0x00, 0 }, - { 0xc4cc, 0x10, 0 }, - { 0xc4cd, 0x18, 0 }, - { 0xc4ce, 0x10, 0 }, - { 0xc4cf, 0x18, 0 }, - { 0xc510, 0x00, 0 }, - { 0xc511, 0x01, 0 }, - { 0xc512, 0x01, 0 }, - { 0xc513, 0x88, 0 }, - { 0x5005, 0x08, 0 }, - { 0x3007, 0x01, 0 }, - { 0xc518, 0x03, 0 }, - { 0xc519, 0x48, 0 }, - { 0xc51a, 0x07, 0 }, - { 0xc51b, 0x70, 0 }, - { 0x5608, 0x0D, 0 }, - { 0x3815, 0x8C, 0 }, - { 0x301b, 0xf0, 0 }, - - { 0x4709, 0x10, 0 },/* dvp swap */ - { 0x4300, 0x3a, 0 },/* YUV order UYVY */ - { 0x3832, 0x01, 0 },/* fsin */ - { 0x3833, 0x1A, 0 }, - { 0x3834, 0x03, 0 }, - { 0x3835, 0x48, 0 }, - { 0x302E, 0x01, 0 }, -}; - -static inline struct sensor_data *subdev_to_sensor_data(struct v4l2_subdev *sd) -{ - return container_of(sd, struct sensor_data, subdev); -} - -static inline int ov10635_read_reg(struct sensor_data *max9286_data, int index, - unsigned short reg, unsigned char *val) -{ - unsigned char u8_buf[2] = { 0 }; - unsigned int buf_len = 2; - int retry, timeout = 10; - unsigned char u8_val = 0; - - u8_buf[0] = (reg >> 8) & 0xFF; - u8_buf[1] = reg & 0xFF; - - max9286_data->i2c_client->addr = ADDR_OV_SENSOR + index; - - for (retry = 0; retry < timeout; retry++) { - if (i2c_master_send(max9286_data->i2c_client, u8_buf, buf_len) < 0) { - dev_dbg(&max9286_data->i2c_client->dev, - "%s:read reg error on send: reg=0x%x, retry = %d.\n", __func__, reg, retry); - msleep(5); - continue; - } - if (i2c_master_recv(max9286_data->i2c_client, &u8_val, 1) != 1) { - dev_dbg(&max9286_data->i2c_client->dev, - "%s:read reg error on recv: reg=0x%x, retry = %d.\n", __func__, reg, retry); - msleep(5); - continue; - } - break; - } - - if (retry >= timeout) { - dev_info(&max9286_data->i2c_client->dev, - "%s:read reg error: reg=0x%x.\n", __func__, reg); - return -1; - } - - *val = u8_val; - - return u8_val; -} - -static inline int ov10635_write_reg(struct sensor_data *max9286_data, int index, - unsigned short reg, unsigned char val) -{ - unsigned char u8_buf[3] = { 0 }; - unsigned int buf_len = 3; - int retry, timeout = 10; - - u8_buf[0] = (reg >> 8) & 0xFF; - u8_buf[1] = reg & 0xFF; - u8_buf[2] = val; - - max9286_data->i2c_client->addr = ADDR_OV_SENSOR + index; - for (retry = 0; retry < timeout; retry++) { - if (i2c_master_send(max9286_data->i2c_client, u8_buf, buf_len) < 0) { - dev_dbg(&max9286_data->i2c_client->dev, - "%s:write reg error: reg=0x%x, val=0x%x, retry = %d.\n", __func__, reg, val, retry); - msleep(5); - continue; - } - break; - } - - if (retry >= timeout) { - dev_info(&max9286_data->i2c_client->dev, - "%s:write reg error: reg=0x%x, val=0x%x.\n", __func__, reg, val); - return -1; - } - - return 0; -} - -static int ov10635_check_device(struct sensor_data *max9286_data, int index) -{ - unsigned char reg = 0; - - ov10635_read_reg(max9286_data, index, OV10635_REG_PID, ®); - if (reg != 0xA6) { - dev_err(&max9286_data->i2c_client->dev, - "%s: OV10635 hasn't been found, reg[0x%x] = 0x%x., index=%d\n", - __func__, OV10635_REG_PID, reg, index); - return -1; - } - ov10635_read_reg(max9286_data, index, OV10635_REG_VER, ®); - if (reg != 0x35) { - dev_err(&max9286_data->i2c_client->dev, - "%s: OV10635 hasn't been found, reg[0x%x] = 0x%x.\n", __func__, OV10635_REG_VER, reg); - return -1; - } - dev_info(&max9286_data->i2c_client->dev, "%s: OV10635 index=%d was found.\n", __func__, index); - - return 0; -} - -static int ov10635_initialize(struct sensor_data *max9286_data, int index) -{ - int i, array_size; - int retval; - - dev_info(&max9286_data->i2c_client->dev, "%s: index = %d.\n", __func__, index); - array_size = ARRAY_SIZE(ov10635_init_data); - for (i = 0; i < array_size; i++) { - retval = ov10635_write_reg(max9286_data, index, - ov10635_init_data[i].reg_addr, ov10635_init_data[i].val); - if (retval < 0) - break; - if (ov10635_init_data[i].delay_ms != 0) - msleep(ov10635_init_data[i].delay_ms); - } - - return 0; -} - -static inline int max9271_read_reg(struct sensor_data *max9286_data, int index, u8 reg) -{ - int val; - int retry, timeout = 10; - - max9286_data->i2c_client->addr = ADDR_MAX9271 + index; - for (retry = 0; retry < timeout; retry++) { - val = i2c_smbus_read_byte_data(max9286_data->i2c_client, reg); - if (val < 0) - msleep(5); - else - break; - } - - if (retry >= timeout) { - dev_info(&max9286_data->i2c_client->dev, - "%s:read reg error: reg=%2x\n", __func__, reg); - return -1; - } - - return val; -} - -static int max9271_write_reg(struct sensor_data *max9286_data, int index, u8 reg, u8 val) -{ - s32 ret; - int retry, timeout = 10; - - max9286_data->i2c_client->addr = ADDR_MAX9271 + index; - for (retry = 0; retry < timeout; retry++) { - ret = i2c_smbus_write_byte_data(max9286_data->i2c_client, reg, val); - if (val < 0) - msleep(5); - else - break; - } - dev_dbg(&max9286_data->i2c_client->dev, - "%s: addr %02x reg %02x val %02x\n", - __func__, max9286_data->i2c_client->addr, reg, val); - - if (retry >= timeout) { - dev_info(&max9286_data->i2c_client->dev, - "%s:write reg error:reg=%2x,val=%2x\n", __func__, - reg, val); - return -1; - } - - return 0; -} - -/*! Read one register from a MAX9286 i2c slave device. - * - * @param *reg register in the device we wish to access. - * - * @return 0 if success, an error code otherwise. - */ -static inline int max9286_read_reg(struct sensor_data *max9286_data, u8 reg) -{ - int val; - - max9286_data->i2c_client->addr = ADDR_MAX9286; - val = i2c_smbus_read_byte_data(max9286_data->i2c_client, reg); - if (val < 0) { - dev_info(&max9286_data->i2c_client->dev, - "%s:read reg error: reg=%2x\n", __func__, reg); - return -1; - } - return val; -} - -/*! Write one register of a MAX9286 i2c slave device. - * - * @param *reg register in the device we wish to access. - * - * @return 0 if success, an error code otherwise. - */ -static int max9286_write_reg(struct sensor_data *max9286_data, u8 reg, u8 val) -{ - s32 ret; - - max9286_data->i2c_client->addr = ADDR_MAX9286; - ret = i2c_smbus_write_byte_data(max9286_data->i2c_client, reg, val); - - dev_dbg(&max9286_data->i2c_client->dev, - "%s: addr %02x reg %02x val %02x\n", - __func__, max9286_data->i2c_client->addr, reg, val); - - if (ret < 0) { - dev_info(&max9286_data->i2c_client->dev, - "%s:write reg error:reg=%2x,val=%2x\n", __func__, - reg, val); - return -1; - } - return 0; -} - -#ifdef debug -static void max9271_dump_registers(struct sensor_data *max9286_data, int index) -{ - unsigned char i; - printk("max9271_dump_registers: index = %d.\r\n", index); - for (i = 0; i < 0x20; i++) - printk("MAX9271 Reg 0x%02x = 0x%x.\r\n", i, max9271_read_reg(max9286_data, index, i)); -} - -static void max9286_dump_registers(struct sensor_data *max9286_data) -{ - unsigned char i; - printk("Dump MAX9286 registers:\r\n"); - for (i = 0; i < 0x72; i++) - printk("MAX9286 Reg 0x%02x = 0x%x.\r\n", i, max9286_read_reg(max9286_data, i)); -} -#else -static void max9271_dump_registers(struct sensor_data *max9286_data, int index) -{ -} -#endif - -static int max9286_hardware_preinit(struct sensor_data *max9286_data) -{ - u8 reg; - - dev_info(&max9286_data->i2c_client->dev, "In %s()\n", __func__); - - /* Disable CSI Output */ - max9286_write_reg(max9286_data, 0x15, 0x03); - - /* Enable PRBS test */ - max9286_write_reg(max9286_data, 0x0E, 0x5F); - msleep(10); - - /* Enable Custom Reverse Channel & First Pulse Length STEP 1 */ - max9286_write_reg(max9286_data, 0x3F, 0x4F); - msleep(2); /* STEP 2 */ - - /* Reverse Channel Amplitude to mid level and transition time */ - max9286_write_reg(max9286_data, 0x3B, 0x1E); /* STEP 3 */ - msleep(2); /* STEP 4 */ - - /* Enable MAX9271 Configuration Link */ - max9271_write_reg(max9286_data, 0, 0x04, 0x43); /* STEP 5 */ - msleep(2); /* STEP 6 */ - - /* Increase serializer reverse channel input thresholds */ - max9271_write_reg(max9286_data, 0, 0x08, 0x01); /* STEP 7 */ - msleep(2); /* STEP 8 */ - - /* Reverse Channel Amplitude level */ - max9286_write_reg(max9286_data, 0x3B, 0x19); /* STEP 9 */ - msleep(5); /* STEP 10 */ - - /* Set YUV422 8 bits mode, Double Data Rate, 4 data lane */ - max9286_write_reg(max9286_data, 0x12, 0xF3); /* STEP 12 */ - - max9286_write_reg(max9286_data, 0x01, 0x02); /* STEP 13 */ - /* Enable All Link 0-3 */ - max9286_write_reg(max9286_data, 0x00, 0xef); /* STEP 14 */ - - /* Frame Sync */ - /* Automatic Mode */ - max9286_write_reg(max9286_data, 0x01, 0x02);/* STEP 13 */ - msleep(200); - /* Detect link */ - max9286_data->sensor_num = 0; - reg = max9286_read_reg(max9286_data, 0x49); - max9286_data->sensor_is_there = ((reg >> 4) & 0xF) | (reg & 0xF); - if (max9286_data->sensor_is_there & (0x1 << 0)) - max9286_data->sensor_num += 1; - if (max9286_data->sensor_is_there & (0x1 << 1)) - max9286_data->sensor_num += 1; - if (max9286_data->sensor_is_there & (0x1 << 2)) - max9286_data->sensor_num += 1; - if (max9286_data->sensor_is_there & (0x1 << 3)) - max9286_data->sensor_num += 1; - pr_info("max9286_mipi: reg = 0x%02x.\n", reg); - pr_info("max9286_mipi: sensor number = %d.\n", max9286_data->sensor_num); - - if (max9286_data->sensor_num == 0) { - pr_err("%s: no camera connected.\n", __func__); - return -1; - } - return 0; - -} - -static void max9286_camera_reorder(struct sensor_data *max9286_data) -{ - u8 reg; - - reg = 0xE4; - if (max9286_data->sensor_num == 1) { - switch (max9286_data->sensor_is_there) { - case 0x8: - reg = 0x27; - break; - case 0x4: - reg = 0xC6; - break; - case 0x2: - reg = 0xE1; - break; - case 0x1: - default: - reg = 0xE4; - break; - } - } else if (max9286_data->sensor_num == 2) { - switch (max9286_data->sensor_is_there) { - case 0xC: - reg = 0x4E; - break; - case 0xA: - reg = 0x72; - break; - case 0x9: - reg = 0x78; - break; - case 0x6: - reg = 0xD2; - break; - case 0x5: - reg = 0xD8; - break; - case 0x3: - default: - reg = 0xE4; - break; - } - } else if (max9286_data->sensor_num == 3) { - switch (max9286_data->sensor_is_there) { - case 0xE: - reg = 0x93; - break; - case 0xD: - reg = 0x9C; - break; - case 0xB: - reg = 0xB4; - break; - case 0x7: - default: - reg = 0xE4; - break; - } - } - max9286_write_reg(max9286_data, 0x0B, reg); -} - -static int max9286_hardware_init(struct sensor_data *max9286_data) -{ - int retval = 0; - int i; - u8 reg, sensor_addr = 0; - - dev_info(&max9286_data->i2c_client->dev, "In %s()\n", __func__); - - /* Disable PRBS test */ - max9286_write_reg(max9286_data, 0x0E, 0x50); - - /* reorder camera */ - max9286_camera_reorder(max9286_data); - - /* Enable all links */ - reg = 0xE0 | max9286_data->sensor_is_there; - max9286_write_reg(max9286_data, 0x00, reg); - - /* Set up links */ - sensor_addr = ADDR_OV_SENSOR; - max9271_write_reg(max9286_data, 0, 0x07, 0x84); - /* STEP 15-46 */ - reg = 0; - for (i = 1; i <= MAX9271_MAX_SENSOR_NUM; i++) { - if (((0x1 << (i - 1)) & max9286_data->sensor_is_there) == 0) - continue; - - /* Enable Link control channel */ - reg |= (0x11 << (i - 1)); - max9286_write_reg(max9286_data, 0x0A, reg);/* STEP 15 */ - - /* Set MAX9271 new address for link 0 */ - max9271_write_reg(max9286_data, 0, 0x00, (ADDR_MAX9271 + i) << 1); - msleep(2); - - max9271_write_reg(max9286_data, i, 0x01, ADDR_MAX9286 << 1); - max9271_write_reg(max9286_data, i, 0x09, (sensor_addr + i) << 1); - max9271_write_reg(max9286_data, i, 0x0A, sensor_addr << 1); - max9271_write_reg(max9286_data, i, 0x0B, ADDR_MAX9271_ALL << 1); - max9271_write_reg(max9286_data, i, 0x0C, (ADDR_MAX9271 + i) << 1); - - msleep(1); - pr_info("max9286_mipi: initialized sensor = 0x%02x.\n", i); - max9271_dump_registers(max9286_data, i); - } - max9286_write_reg(max9286_data, 0x0A, reg); - max9286_write_reg(max9286_data, 0x0A, reg); - - /* Disable Local Auto I2C ACK */ - max9286_write_reg(max9286_data, 0x34, 0x36); /* STEP 48 */ - - /* Initialize Camera Sensor */ - /* STEP 49 */ - if (max9286_data->sensor_is_there & (0x1 << 0)) { - retval = ov10635_check_device(max9286_data, 1); - if (retval < 0) - return retval; - ov10635_initialize(max9286_data, 0); - } - - if (max9286_data->sensor_is_there & (0x1 << 1)) { - retval = ov10635_check_device(max9286_data, 2); - if (retval < 0) - return retval; - ov10635_initialize(max9286_data, 1); - } - - if (max9286_data->sensor_is_there & (0x1 << 2)) { - ov10635_check_device(max9286_data, 3); - if (retval < 0) - return retval; - ov10635_initialize(max9286_data, 2); - } - - if (max9286_data->sensor_is_there & (0x1 << 3)) { - retval = ov10635_check_device(max9286_data, 4); - if (retval < 0) - return retval; - ov10635_initialize(max9286_data, 3); - } - - /* Enable Local Auto I2C ACK */ - max9286_write_reg(max9286_data, 0x34, 0xB6); /* STEP 50 */ - - /* MAX9271: Enable Serial Links and Disable Configuration Link */ - max9271_write_reg(max9286_data, ADDR_MAX9271_ALL - ADDR_MAX9271, 0x04, 0x83); /* STEP 51 */ - /* Wait for more than 2 frame time */ - msleep(1000); /* STEP 52 */ - - /* Enable CSI output, set virtual channel according to the link number */ - max9286_write_reg(max9286_data, 0x15, 0x9B); /* STEP 52 */ - msleep(10); - return retval; -} - -static int max9286_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) -{ - struct v4l2_captureparm *cparm = &a->parm.capture; - struct sensor_data *max9286_data = subdev_to_sensor_data(sd); - int ret = 0; - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: - memset(a, 0, sizeof(*a)); - a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cparm->capability = max9286_data->streamcap.capability; - cparm->timeperframe = max9286_data->streamcap.timeperframe; - cparm->capturemode = max9286_data->streamcap.capturemode; - ret = 0; - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - ret = -EINVAL; - break; - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure - * - * Configures the sensor to use the input parameters, if possible. If - * not possible, reverts to the old parameters and returns the - * appropriate error code. - */ -static int max9286_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) -{ - struct sensor_data *max9286_data = subdev_to_sensor_data(sd); - struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; - enum ov10635_frame_rate frame_rate; - u32 tgt_fps; - int ret = 0; - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: - /* Check that the new frame rate is allowed. */ - if ((timeperframe->numerator == 0) || - (timeperframe->denominator == 0)) { - timeperframe->denominator = DEFAULT_FPS; - timeperframe->numerator = 1; - } - - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps > MAX_FPS) { - timeperframe->denominator = MAX_FPS; - timeperframe->numerator = 1; - } else if (tgt_fps < MIN_FPS) { - timeperframe->denominator = MIN_FPS; - timeperframe->numerator = 1; - } - - /* Actual frame rate we use */ - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps == 15) - frame_rate = OV10635_15_FPS; - else if (tgt_fps == 30) - frame_rate = OV10635_30_FPS; - else { - pr_err(" The camera frame rate is not supported!\n"); - return -EINVAL; - } - - /* TODO Reserved to extension */ - - max9286_data->streamcap.timeperframe = *timeperframe; - max9286_data->streamcap.capturemode = a->parm.capture.capturemode; - - - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - pr_debug(" type is not "\ - "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", - a->type); - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -static int max9286_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) -{ - struct sensor_data *max9286_data = subdev_to_sensor_data(sd); - - code->code = max9286_data->format.code; - return 0; -} - -/*! - * max9286_enum_framesizes - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMESIZES ioctl - * @s: pointer to standard V4L2 device structure - * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int max9286_enum_framesizes(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) -{ - struct sensor_data *max9286_data = subdev_to_sensor_data(sd); - - if (fse->index > 1) - return -EINVAL; - - fse->max_width = max9286_data->format.width; - fse->min_width = fse->max_width; - - fse->max_height = max9286_data->format.height; - fse->min_height = fse->max_height; - return 0; -} -static int max9286_enum_frame_interval(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_interval_enum *fie) -{ - if (fie->index < 0 || fie->index > 8) - return -EINVAL; - - if (fie->width == 0 || fie->height == 0 || - fie->code == 0) { - pr_warning("Please assign pixel format, width and height.\n"); - return -EINVAL; - } - - fie->interval.numerator = 1; - - /* TODO Reserved to extension */ - - fie->interval.denominator = 30; - return 0; -} - -static int max9286_get_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) -{ - struct sensor_data *max9286_data = subdev_to_sensor_data(sd); - struct v4l2_mbus_framefmt *mf = &fmt->format; - - if (fmt->pad) - return -EINVAL; - - mf->code = max9286_data->format.code; - mf->width = max9286_data->format.width; - mf->height = max9286_data->format.height; - mf->colorspace = max9286_data->format.colorspace; - mf->field = max9286_data->format.field; - - return 0; -} - -static int max9286_set_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) -{ - return 0; -} - -static int max9286_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, - struct v4l2_mbus_frame_desc *fd) -{ - return 0; -} - -static int max9286_set_frame_desc(struct v4l2_subdev *sd, - unsigned int pad, - struct v4l2_mbus_frame_desc *fd) -{ - return 0; -} - -static int max9286_set_power(struct v4l2_subdev *sd, int on) -{ - return 0; -} - -static int max9286_s_stream(struct v4l2_subdev *sd, int enable) -{ - struct sensor_data *max9286_data = subdev_to_sensor_data(sd); - - dev_dbg(sd->dev, "%s\n", __func__); - if (enable) { - if (!max9286_data->running) { - /* Enable CSI output, set virtual channel according to the link number */ - max9286_write_reg(max9286_data, 0x15, 0x9B); - } - max9286_data->running++; - - } else { - - if (max9286_data->running) { - /* Disable CSI Output */ - max9286_write_reg(max9286_data, 0x15, 0x03); - } - max9286_data->running--; - } - - return 0; -} - -static int max9286_link_setup(struct media_entity *entity, - const struct media_pad *local, - const struct media_pad *remote, u32 flags) -{ - return 0; -} - -static const struct v4l2_subdev_pad_ops max9286_pad_ops = { - .enum_mbus_code = max9286_enum_mbus_code, - .enum_frame_size = max9286_enum_framesizes, - .enum_frame_interval = max9286_enum_frame_interval, - .get_fmt = max9286_get_fmt, - .set_fmt = max9286_set_fmt, - .get_frame_desc = max9286_get_frame_desc, - .set_frame_desc = max9286_set_frame_desc, -}; - -static const struct v4l2_subdev_core_ops max9286_core_ops = { - .s_power = max9286_set_power, -}; - -static const struct v4l2_subdev_video_ops max9286_video_ops = { - .s_parm = max9286_s_parm, - .g_parm = max9286_g_parm, - .s_stream = max9286_s_stream, -}; - -static const struct v4l2_subdev_ops max9286_subdev_ops = { - .core = &max9286_core_ops, - .pad = &max9286_pad_ops, - .video = &max9286_video_ops, -}; - -static const struct media_entity_operations max9286_sd_media_ops = { - .link_setup = max9286_link_setup, -}; - -/*! - * max9286 I2C probe function - * - * @param adapter struct i2c_adapter * - * @return Error code indicating success or failure - */ -static int max9286_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct device *dev = &client->dev; - struct sensor_data *max9286_data; - struct v4l2_subdev *sd; - int retval; - - max9286_data = devm_kzalloc(dev, sizeof(*max9286_data), GFP_KERNEL); - if (!max9286_data) - return -ENOMEM; - - /* Set initial values for the sensor struct. */ - max9286_data->sensor_clk = devm_clk_get(dev, "capture_mclk"); - if (IS_ERR(max9286_data->sensor_clk)) { - /* assuming clock enabled by default */ - max9286_data->sensor_clk = NULL; - dev_err(dev, "clock-frequency missing or invalid\n"); - return PTR_ERR(max9286_data->sensor_clk); - } - - retval = of_property_read_u32(dev->of_node, "mclk", - &(max9286_data->mclk)); - if (retval) { - dev_err(dev, "mclk missing or invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "mclk_source", - (u32 *)&(max9286_data->mclk_source)); - if (retval) { - dev_err(dev, "mclk_source missing or invalid\n"); - return retval; - } - - /* request power down pin */ - max9286_data->pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); - if (!gpio_is_valid(max9286_data->pwn_gpio)) { - dev_err(dev, "no sensor pwdn pin available\n"); - return -ENODEV; - } - retval = devm_gpio_request_one(dev, max9286_data->pwn_gpio, GPIOF_OUT_INIT_HIGH, - "max9286_pwd"); - if (retval < 0) - return retval; - - clk_prepare_enable(max9286_data->sensor_clk); - - max9286_data->i2c_client = client; - max9286_data->format.code = MEDIA_BUS_FMT_YUYV8_1X16; - max9286_data->format.width = g_max9286_width; - max9286_data->format.height = g_max9286_height; - max9286_data->format.colorspace = V4L2_COLORSPACE_JPEG; - /***************************************** - * Pass mipi phy clock rate Mbps - * fcsi2 = PCLk * WIDTH * CHANNELS / LANES - * fsci2 = 72MPCLK * 8 bit * 4 channels / 4 lanes - ****************************************/ - max9286_data->format.reserved[0] = 72 * 8; - max9286_data->format.field = V4L2_FIELD_NONE; - max9286_data->streamcap.capturemode = 0; - max9286_data->streamcap.timeperframe.denominator = 30; - max9286_data->streamcap.timeperframe.numerator = 1; - max9286_data->is_mipi = 1; - - retval = max9286_read_reg(max9286_data, 0x1e); - if (retval != 0x40) { - pr_warning("max9286 is not found, chip id reg 0x1e = 0x%x.\n", retval); - clk_disable_unprepare(max9286_data->sensor_clk); - devm_gpio_free(dev, max9286_data->pwn_gpio); - return -ENODEV; - } - - max9286_hardware_preinit(max9286_data); - - if (max9286_data->sensor_num == 0) { - pr_warning("cameras are not found,\n"); - clk_disable_unprepare(max9286_data->sensor_clk); - devm_gpio_free(dev, max9286_data->pwn_gpio); - return -ENODEV; - } - - max9286_data->streamcap.capability = V4L2_CAP_TIMEPERFRAME; - max9286_data->streamcap.timeperframe.denominator = 30; - max9286_data->streamcap.timeperframe.numerator = 1; - max9286_data->v_channel = 0; - max9286_data->cap_mode.clip_top = 0; - max9286_data->cap_mode.clip_left = 0; - - max9286_data->cap_mode.clip_height = 800; - max9286_data->cap_mode.clip_width = 1280; - - max9286_data->cap_mode.hlen = max9286_data->cap_mode.clip_width; - - max9286_data->cap_mode.hfp = 0; - max9286_data->cap_mode.hbp = 0; - max9286_data->cap_mode.hsync = 625; - max9286_data->cap_mode.vlen = 800; - max9286_data->cap_mode.vfp = 0; - max9286_data->cap_mode.vbp = 0; - max9286_data->cap_mode.vsync = 40; - max9286_data->cap_mode.vlen1 = 0; - max9286_data->cap_mode.vfp1 = 0; - max9286_data->cap_mode.vbp1 = 0; - max9286_data->cap_mode.vsync1 = 0; - max9286_data->cap_mode.pixelclock = 27000000; - - sd = &max9286_data->subdev; - v4l2_i2c_subdev_init(sd, client, &max9286_subdev_ops); - sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - - sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - max9286_data->pads[MIPI_CSI2_SENS_VC0_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - max9286_data->pads[MIPI_CSI2_SENS_VC1_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - max9286_data->pads[MIPI_CSI2_SENS_VC2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - max9286_data->pads[MIPI_CSI2_SENS_VC3_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - retval = media_entity_pads_init(&sd->entity, MIPI_CSI2_SENS_VCX_PADS_NUM, - max9286_data->pads); - if (retval < 0) - return retval; - - max9286_data->subdev.entity.ops = &max9286_sd_media_ops; - retval = v4l2_async_register_subdev(&max9286_data->subdev); - if (retval < 0) { - dev_err(&client->dev, - "%s--Async register failed, ret=%d\n", __func__, retval); - media_entity_cleanup(&sd->entity); - } - - retval = max9286_hardware_init(max9286_data); - if (retval < 0) { - dev_err(&client->dev, "camera init failed\n"); - clk_disable_unprepare(max9286_data->sensor_clk); - media_entity_cleanup(&sd->entity); - v4l2_async_unregister_subdev(sd); - return retval; - } - - max9286_data->running = 0; - - /* Disable CSI Output */ - max9286_write_reg(max9286_data, 0x15, 0x03); - - dev_info(&max9286_data->i2c_client->dev, - "max9286_mipi is found, name %s\n", sd->name); - return retval; -} - -/*! - * max9286 I2C detach function - * - * @param client struct i2c_client * - * @return Error code indicating success or failure - */ -static int max9286_remove(struct i2c_client *client) -{ - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct sensor_data *max9286_data = subdev_to_sensor_data(sd); - - clk_disable_unprepare(max9286_data->sensor_clk); - media_entity_cleanup(&sd->entity); - v4l2_async_unregister_subdev(sd); - - return 0; -} -static const struct i2c_device_id max9286_id[] = { - {}, -}; - -MODULE_DEVICE_TABLE(i2c, max9286_id); - -static const struct of_device_id max9286_of_match[] = { - { .compatible = "maxim,max9286_mipi" }, - { /* sentinel */ } -}; - -static struct i2c_driver max9286_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "max9286_mipi", - .of_match_table = of_match_ptr(max9286_of_match), - }, - .probe = max9286_probe, - .remove = max9286_remove, - .id_table = max9286_id, -}; - -module_i2c_driver(max9286_i2c_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("MAX9286 GSML Deserializer Driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("CSI"); diff --git a/drivers/media/platform/imx8/max9286.h b/drivers/media/platform/imx8/max9286.h deleted file mode 100644 index 8688b869e45a4a1e5a6d703652dbcd1c461acd7d..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/max9286.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later. - */ - -#ifndef __MAX9286_H__ -#define __MAX9286_H__ - -#define MIPI_CSI2_SENS_VC0_PAD_SOURCE 0 -#define MIPI_CSI2_SENS_VC1_PAD_SOURCE 1 -#define MIPI_CSI2_SENS_VC2_PAD_SOURCE 2 -#define MIPI_CSI2_SENS_VC3_PAD_SOURCE 3 -#define MIPI_CSI2_SENS_VCX_PADS_NUM 4 - -#define MAX_FPS 30 -#define MIN_FPS 15 -#define DEFAULT_FPS 30 - -/*! - * Maintains the information on the current state of the sesor. - */ -struct imxdpu_videomode { - char name[64]; /* may not be needed */ - - uint32_t pixelclock; /* Hz */ - - /* htotal (pixels) = hlen + hfp + hsync + hbp */ - uint32_t hlen; - uint32_t hfp; - uint32_t hbp; - uint32_t hsync; - - /* field0 - vtotal (lines) = vlen + vfp + vsync + vbp */ - uint32_t vlen; - uint32_t vfp; - uint32_t vbp; - uint32_t vsync; - - /* field1 */ - uint32_t vlen1; - uint32_t vfp1; - uint32_t vbp1; - uint32_t vsync1; - - uint32_t flags; - - uint32_t format; - uint32_t dest_format; /*buffer format for capture*/ - - int16_t clip_top; - int16_t clip_left; - uint16_t clip_width; - uint16_t clip_height; - -}; -struct sensor_data { - struct v4l2_subdev subdev; - struct media_pad pads[MIPI_CSI2_SENS_VCX_PADS_NUM]; - struct i2c_client *i2c_client; - struct v4l2_mbus_framefmt format; - struct v4l2_captureparm streamcap; - char running; - - /* control settings */ - int brightness; - int hue; - int contrast; - int saturation; - int red; - int green; - int blue; - int ae_mode; - - u32 mclk; - u8 mclk_source; - struct clk *sensor_clk; - int v_channel; - bool is_mipi; - struct imxdpu_videomode cap_mode; - - unsigned int sensor_num; /* sensor num connect max9271 */ - unsigned char sensor_is_there; /* Bit 0~3 for 4 cameras, 0b1= is there; 0b0 = is not there */ - int pwn_gpio; -}; -#endif diff --git a/drivers/media/platform/imx8/mxc-isi-cap.c b/drivers/media/platform/imx8/mxc-isi-cap.c deleted file mode 100644 index 1667da1865c0db91589817f32c197ff27da3ea84..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-isi-cap.c +++ /dev/null @@ -1,1534 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "mxc-isi-core.h" -#include "mxc-isi-hw.h" -#include "mxc-media-dev.h" -#include "max9286.h" - -struct mxc_isi_fmt mxc_isi_out_formats[] = { - { - .name = "RGB565", - .fourcc = V4L2_PIX_FMT_RGB565, - .depth = { 16 }, - .color = MXC_ISI_OUT_FMT_RGB565, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_RGB565_1X16, - }, { - .name = "RGB24", - .fourcc = V4L2_PIX_FMT_RGB24, - .depth = { 32 }, - .color = MXC_ISI_OUT_FMT_XRGB32, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, - }, { - .name = "RGB32", - .fourcc = V4L2_PIX_FMT_RGB32, - .depth = { 32 }, - .color = MXC_ISI_OUT_FMT_XRGB32, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, - }, { - .name = "BGR24", - .fourcc = V4L2_PIX_FMT_BGR24, - .depth = { 32 }, - .color = MXC_ISI_OUT_FMT_XBGR32, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_BGR888_1X24, - }, { - .name = "ARGB32", - .fourcc = V4L2_PIX_FMT_ARGB32, - .depth = { 32 }, - .color = MXC_ISI_OUT_FMT_ARGB32, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_ARGB8888_1X32, - }, { - .name = "YUYV-16", - .fourcc = V4L2_PIX_FMT_YUYV, - .depth = { 16 }, - .color = MXC_ISI_OUT_FMT_YUV422_1P8P, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_YUYV8_1X16, - }, { - .name = "YUV32 (X-Y-U-V)", - .fourcc = V4L2_PIX_FMT_YUV32, - .depth = { 32 }, - .color = MXC_ISI_OUT_FMT_YUV444_1P8, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_AYUV8_1X32, - }, -}; - -struct mxc_isi_fmt mxc_isi_src_formats[] = { - /* Pixel link input format */ - { - .name = "RGB32", - .fourcc = V4L2_PIX_FMT_RGB32, - .depth = { 32 }, - .memplanes = 1, - .colplanes = 1, - }, { - .name = "YUV32 (X-Y-U-V)", - .fourcc = V4L2_PIX_FMT_YUV32, - .depth = { 32 }, - .memplanes = 1, - .colplanes = 1, - } -}; - -struct mxc_isi_fmt mxc_isi_m2m_in_formats[] = { - { - .name = "RGB565", - .fourcc = V4L2_PIX_FMT_RGB565, - .depth = { 16 }, - .color = MXC_ISI_M2M_IN_FMT_RGB565, - .memplanes = 1, - .colplanes = 1, - }, { - .name = "YUV 4:2:2 packed, YCbYCr", - .fourcc = V4L2_PIX_FMT_YUYV, - .depth = { 16 }, - .color = MXC_ISI_M2M_IN_FMT_YUV422_1P8P, - .memplanes = 1, - .colplanes = 1, - .mbus_code = MEDIA_BUS_FMT_YUYV8_1X16, - }, -}; - -struct mxc_isi_fmt *mxc_isi_get_format(unsigned int index) -{ - return &mxc_isi_out_formats[index]; -} - -/** - * mxc_isi_find_format - lookup mxc_isi color format by fourcc or media bus format - */ -struct mxc_isi_fmt *mxc_isi_find_format(const u32 *pixelformat, - const u32 *mbus_code, int index) -{ - struct mxc_isi_fmt *fmt, *def_fmt = NULL; - unsigned int i; - int id = 0; - - if (index >= (int)ARRAY_SIZE(mxc_isi_out_formats)) - return NULL; - - for (i = 0; i < ARRAY_SIZE(mxc_isi_out_formats); i++) { - fmt = &mxc_isi_out_formats[i]; - if (pixelformat && fmt->fourcc == *pixelformat) - return fmt; - if (mbus_code && fmt->mbus_code == *mbus_code) - return fmt; - if (index == id) - def_fmt = fmt; - id++; - } - return def_fmt; -} - -struct mxc_isi_fmt *mxc_isi_get_src_fmt(struct v4l2_subdev_format *sd_fmt) -{ - u32 index; - - /* two fmt RGB32 and YUV444 from pixellink */ - if (sd_fmt->format.code == MEDIA_BUS_FMT_YUYV8_1X16) - index = 1; - else - index = 0; - return &mxc_isi_src_formats[index]; -} - -/* - * mxc_isi_pipeline_enable() - Enable streaming on a pipeline - * - */ -static int mxc_isi_pipeline_enable(struct mxc_isi_dev *mxc_isi, bool enable) -{ - struct media_entity *entity = &mxc_isi->isi_cap.vdev.entity; - struct media_device *mdev = entity->graph_obj.mdev; - struct media_graph graph; - struct v4l2_subdev *subdev; - int ret = 0; - - mutex_lock(&mdev->graph_mutex); - - ret = media_graph_walk_init(&graph, entity->graph_obj.mdev); - if (ret) { - mutex_unlock(&mdev->graph_mutex); - return ret; - } - media_graph_walk_start(&graph, entity); - - while ((entity = media_graph_walk_next(&graph))) { - if (entity == NULL) { - dev_dbg(&mxc_isi->pdev->dev, - "%s ,entity is NULL\n", __func__); - continue; - } - - if (!is_media_entity_v4l2_subdev(entity)) { - dev_dbg(&mxc_isi->pdev->dev, - "%s ,entity is no v4l2, %s\n", __func__, entity->name); - continue; - } - - subdev = media_entity_to_v4l2_subdev(entity); - if (subdev == NULL) { - dev_dbg(&mxc_isi->pdev->dev, - "%s ,%s,subdev is NULL\n", __func__, entity->name); - continue; - } - - ret = v4l2_subdev_call(subdev, video, s_stream, enable); - if (ret < 0 && ret != -ENOIOCTLCMD) { - dev_err(&mxc_isi->pdev->dev, - "%s ,subdev %s s_stream failed\n", __func__, subdev->name); - break; - } - } - mutex_unlock(&mdev->graph_mutex); - media_graph_walk_cleanup(&graph); - - return ret; -} - -static int mxc_isi_update_buf_paddr(struct mxc_isi_buffer *buf, int memplanes) -{ - struct frame_addr *paddr = &buf->paddr; - struct vb2_buffer *vb2 = &buf->v4l2_buf.vb2_buf; - int ret = 0; - - /* support one plane now */ - paddr->cb = 0; - paddr->cr = 0; - - switch (memplanes) { - case 3: - paddr->cr = vb2_dma_contig_plane_dma_addr(vb2, 2); - case 2: - paddr->cb = vb2_dma_contig_plane_dma_addr(vb2, 1); - case 1: - paddr->y = vb2_dma_contig_plane_dma_addr(vb2, 0); - break; - default: - return -EINVAL; - } - - return ret; -} - -void mxc_isi_frame_write_done(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_buffer *buf; - struct vb2_buffer *vb2; - - /* Retrun if no pending buffer */ - if (!list_empty(&mxc_isi->isi_cap.out_active)) { - - buf = list_first_entry(&mxc_isi->isi_cap.out_active, - struct mxc_isi_buffer, list); - - list_del(&buf->list); - buf->v4l2_buf.vb2_buf.timestamp = ktime_get_ns(); - buf->v4l2_buf.sequence = mxc_isi->isi_cap.frame_count++; - vb2_buffer_done(&buf->v4l2_buf.vb2_buf, VB2_BUF_STATE_DONE); - } - - if (!list_empty(&mxc_isi->isi_cap.out_pending)) { - - /* ISI channel output buffer */ - buf = list_first_entry(&mxc_isi->isi_cap.out_pending, - struct mxc_isi_buffer, list); - list_del(&buf->list); - - buf->v4l2_buf.sequence = mxc_isi->isi_cap.frame_count; - mxc_isi_channel_set_outbuf(mxc_isi, buf); - vb2 = &buf->v4l2_buf.vb2_buf; - vb2->state = VB2_BUF_STATE_ACTIVE; - list_add_tail(&buf->list, &mxc_isi->isi_cap.out_active); - } -} - -static int cap_vb2_queue_setup(struct vb2_queue *q, - unsigned int *num_buffers, unsigned int *num_planes, - unsigned int sizes[], struct device *alloc_devs[]) -{ - struct mxc_isi_dev *mxc_isi = q->drv_priv; - struct mxc_isi_frame *dst_f = &mxc_isi->isi_cap.dst_f; - struct mxc_isi_fmt *fmt = dst_f->fmt; - unsigned long wh; - int i; - - alloc_devs[0] = &mxc_isi->pdev->dev; - wh = dst_f->width * dst_f->height; - - if (fmt == NULL) - return -EINVAL; - - *num_planes = fmt->memplanes; - - for (i = 0; i < fmt->memplanes; i++) { - unsigned int size = (wh * fmt->depth[i]) / 8; - sizes[i] = max_t(u32, size, dst_f->sizeimage[i]); - } - dev_dbg(&mxc_isi->pdev->dev, "%s, buf_n=%d, size=%d\n", - __func__, *num_buffers, sizes[0]); - - return 0; -} - -static int cap_vb2_buffer_prepare(struct vb2_buffer *vb2) -{ - struct vb2_queue *q = vb2->vb2_queue; - struct mxc_isi_dev *mxc_isi = q->drv_priv; - struct mxc_isi_frame *dst_f = &mxc_isi->isi_cap.dst_f; - int i; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - if (mxc_isi->isi_cap.dst_f.fmt == NULL) - return -EINVAL; - - for (i = 0; i < dst_f->fmt->memplanes; i++) { - unsigned long size = dst_f->sizeimage[i]; - - if (vb2_plane_size(vb2, i) < size) { - v4l2_err(&mxc_isi->isi_cap.vdev, - "User buffer too small (%ld < %ld)\n", - vb2_plane_size(vb2, i), size); - return -EINVAL; - } -#if 0 //debug only - if (vb2_plane_vaddr(vb2, i)) - memset((void *)vb2_plane_vaddr(vb2, i), 0xaa, - vb2_get_plane_payload(vb2, i)); -#endif - vb2_set_plane_payload(vb2, i, size); - } - - return 0; -} - -static void cap_vb2_buffer_queue(struct vb2_buffer *vb2) -{ - struct vb2_v4l2_buffer *v4l2_buf = to_vb2_v4l2_buffer(vb2); - struct mxc_isi_buffer *buf - = container_of(v4l2_buf, struct mxc_isi_buffer, v4l2_buf); - struct mxc_isi_dev *mxc_isi = vb2_get_drv_priv(vb2->vb2_queue); - unsigned long flags; - - spin_lock_irqsave(&mxc_isi->slock, flags); - - mxc_isi_update_buf_paddr(buf, mxc_isi->isi_cap.dst_f.fmt->mdataplanes); - list_add_tail(&buf->list, &mxc_isi->isi_cap.out_pending); - - spin_unlock_irqrestore(&mxc_isi->slock, flags); -} - - -static int cap_vb2_start_streaming(struct vb2_queue *q, unsigned int count) -{ - struct mxc_isi_dev *mxc_isi = q->drv_priv; - struct mxc_isi_buffer *buf; - struct vb2_buffer *vb2; - unsigned long flags; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - spin_lock_irqsave(&mxc_isi->slock, flags); - - mxc_isi->isi_cap.frame_count = 0; - - /* ISI channel output buffer 1 */ - buf = list_first_entry(&mxc_isi->isi_cap.out_pending, - struct mxc_isi_buffer, list); - buf->v4l2_buf.sequence = 0; - mxc_isi_channel_set_outbuf(mxc_isi, buf); - vb2 = &buf->v4l2_buf.vb2_buf; - vb2->state = VB2_BUF_STATE_ACTIVE; - list_move_tail(mxc_isi->isi_cap.out_pending.next, &mxc_isi->isi_cap.out_active); - - /* ISI channel output buffer 2 */ - buf = list_first_entry(&mxc_isi->isi_cap.out_pending, - struct mxc_isi_buffer, list); - buf->v4l2_buf.sequence = 1; - mxc_isi_channel_set_outbuf(mxc_isi, buf); - vb2 = &buf->v4l2_buf.vb2_buf; - vb2->state = VB2_BUF_STATE_ACTIVE; - list_move_tail(mxc_isi->isi_cap.out_pending.next, &mxc_isi->isi_cap.out_active); - spin_unlock_irqrestore(&mxc_isi->slock, flags); - - return 0; -} - - -static void cap_vb2_stop_streaming(struct vb2_queue *q) -{ - struct mxc_isi_dev *mxc_isi = q->drv_priv; - struct mxc_isi_buffer *buf, *tmp; - unsigned long flags; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - mxc_isi_channel_disable(mxc_isi); - - spin_lock_irqsave(&mxc_isi->slock, flags); - - while (!list_empty(&mxc_isi->isi_cap.out_active)) { - buf = list_entry(mxc_isi->isi_cap.out_active.next, struct mxc_isi_buffer, list); - - list_del(&buf->list); - vb2_buffer_done(&buf->v4l2_buf.vb2_buf, VB2_BUF_STATE_ERROR); - } - - while (!list_empty(&mxc_isi->isi_cap.out_pending)) { - buf = list_entry(mxc_isi->isi_cap.out_pending.next, struct mxc_isi_buffer, list); - - list_del(&buf->list); - vb2_buffer_done(&buf->v4l2_buf.vb2_buf, VB2_BUF_STATE_ERROR); - } - - list_for_each_entry_safe(buf, tmp, - &mxc_isi->isi_cap.out_active, list) { - list_del(&buf->list); - vb2_buffer_done(&buf->v4l2_buf.vb2_buf, VB2_BUF_STATE_ERROR); - } - - list_for_each_entry_safe(buf, tmp, - &mxc_isi->isi_cap.out_pending, list) { - list_del(&buf->list); - vb2_buffer_done(&buf->v4l2_buf.vb2_buf, VB2_BUF_STATE_ERROR); - } - - INIT_LIST_HEAD(&mxc_isi->isi_cap.out_active); - INIT_LIST_HEAD(&mxc_isi->isi_cap.out_pending); - - spin_unlock_irqrestore(&mxc_isi->slock, flags); -} - -static struct vb2_ops mxc_cap_vb2_qops = { - .queue_setup = cap_vb2_queue_setup, - .buf_prepare = cap_vb2_buffer_prepare, - .buf_queue = cap_vb2_buffer_queue, - .wait_prepare = vb2_ops_wait_prepare, - .wait_finish = vb2_ops_wait_finish, - .start_streaming = cap_vb2_start_streaming, - .stop_streaming = cap_vb2_stop_streaming, -}; - -/* - * V4L2 controls handling - */ -#define ctrl_to_mxc_isi(__ctrl) \ - container_of((__ctrl)->handler, struct mxc_isi_dev, ctrls.handler) - -static int mxc_isi_s_ctrl(struct v4l2_ctrl *ctrl) -{ - struct mxc_isi_dev *mxc_isi = ctrl_to_mxc_isi(ctrl); - unsigned long flags; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) - return 0; - - spin_lock_irqsave(&mxc_isi->slock, flags); - - switch (ctrl->id) { - case V4L2_CID_HFLIP: - mxc_isi->hflip = ctrl->val; - break; - - case V4L2_CID_VFLIP: - mxc_isi->vflip = ctrl->val; - break; - - case V4L2_CID_ALPHA_COMPONENT: - mxc_isi->alpha = ctrl->val; - break; - } - - spin_unlock_irqrestore(&mxc_isi->slock, flags); - - return 0; -} - -static const struct v4l2_ctrl_ops mxc_isi_ctrl_ops = { - .s_ctrl = mxc_isi_s_ctrl, -}; - -int mxc_isi_ctrls_create(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_ctrls *ctrls = &mxc_isi->ctrls; - struct v4l2_ctrl_handler *handler = &ctrls->handler; - - if (mxc_isi->ctrls.ready) - return 0; - - v4l2_ctrl_handler_init(handler, 4); - - ctrls->hflip = v4l2_ctrl_new_std(handler, &mxc_isi_ctrl_ops, - V4L2_CID_HFLIP, 0, 1, 1, 0); - ctrls->vflip = v4l2_ctrl_new_std(handler, &mxc_isi_ctrl_ops, - V4L2_CID_VFLIP, 0, 1, 1, 0); - - ctrls->alpha = v4l2_ctrl_new_std(handler, &mxc_isi_ctrl_ops, - V4L2_CID_ALPHA_COMPONENT, 0, 0xff, 1, 0); - - if (!handler->error) - ctrls->ready = true; - - return handler->error; -} - -void mxc_isi_ctrls_delete(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_ctrls *ctrls = &mxc_isi->ctrls; - - if (ctrls->ready) { - v4l2_ctrl_handler_free(&ctrls->handler); - ctrls->ready = false; - ctrls->alpha = NULL; - } -} - -static int mxc_isi_capture_open(struct file *file) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct device *dev = &mxc_isi->pdev->dev; - int ret = -EBUSY; - - dev_dbg(&mxc_isi->pdev->dev, "%s, ISI%d\n", __func__, mxc_isi->id); - - pm_runtime_get_sync(dev); - - mutex_lock(&mxc_isi->lock); - ret = v4l2_fh_open(file); - mutex_unlock(&mxc_isi->lock); - - mxc_isi_channel_init(mxc_isi); - return 0; -} - -static int mxc_isi_capture_release(struct file *file) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct device *dev = &mxc_isi->pdev->dev; - int ret; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - mutex_lock(&mxc_isi->lock); - ret = _vb2_fop_release(file, NULL); - mutex_unlock(&mxc_isi->lock); - mxc_isi_channel_deinit(mxc_isi); - - pm_runtime_put_sync(dev); - - return ret; -} - -static const struct v4l2_file_operations mxc_isi_capture_fops = { - .owner = THIS_MODULE, - .open = mxc_isi_capture_open, - .release = mxc_isi_capture_release, - .poll = vb2_fop_poll, - .unlocked_ioctl = video_ioctl2, - .mmap = vb2_fop_mmap, -}; - -/* - * Format and crop negotiation helpers - */ - -/* - * The video node ioctl operations - */ -static int mxc_isi_cap_querycap(struct file *file, void *priv, - struct v4l2_capability *cap) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - - strlcpy(cap->driver, MXC_ISI_DRIVER_NAME, sizeof(cap->driver)); - strlcpy(cap->card, MXC_ISI_DRIVER_NAME, sizeof(cap->card)); - snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s.%d", - dev_name(&mxc_isi->pdev->dev), mxc_isi->id); - - cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE_MPLANE; - cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; - - return 0; -} - -static int mxc_isi_cap_enum_fmt_mplane(struct file *file, void *priv, - struct v4l2_fmtdesc *f) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct mxc_isi_fmt *fmt; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - if (f->index >= (int)ARRAY_SIZE(mxc_isi_out_formats)) - return -EINVAL; - - fmt = &mxc_isi_out_formats[f->index]; - if (!fmt) - return -EINVAL; - - strncpy(f->description, fmt->name, sizeof(f->description) - 1); - - f->pixelformat = fmt->fourcc; - - return 0; -} - -static int mxc_isi_cap_g_fmt_mplane(struct file *file, void *fh, - struct v4l2_format *f) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; - struct mxc_isi_frame *dst_f = &mxc_isi->isi_cap.dst_f; - int i; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - pix->width = dst_f->o_width; - pix->height = dst_f->o_height; - pix->field = V4L2_FIELD_NONE; - pix->pixelformat = dst_f->fmt->fourcc; - pix->colorspace = V4L2_COLORSPACE_JPEG; - pix->num_planes = dst_f->fmt->memplanes; - - for (i = 0; i < pix->num_planes; ++i) { - pix->plane_fmt[i].bytesperline = dst_f->bytesperline[i]; - pix->plane_fmt[i].sizeimage = dst_f->sizeimage[i]; - } - return 0; -} - - -static int mxc_isi_cap_try_fmt_mplane(struct file *file, void *fh, - struct v4l2_format *f) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; - struct mxc_isi_fmt *fmt; - int i; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - for (i = 0; i < ARRAY_SIZE(mxc_isi_out_formats); i++) { - fmt = &mxc_isi_out_formats[i]; - if (fmt->fourcc == pix->pixelformat) - break; - } - if (i >= ARRAY_SIZE(mxc_isi_out_formats)) { - v4l2_err(mxc_isi->v4l2_dev, "%s, format is not support!\n", __func__); - return -EINVAL; - } - - if (pix->width <= 0 || pix->height <= 0) { - v4l2_err(mxc_isi->v4l2_dev, "%s, width %d, height %d is not valid\n", - __func__, pix->width, pix->height); - return -EINVAL; - } - - return 0; -} - - -static struct media_pad *mxc_isi_get_remote_source_pad(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_cap_dev *isi_cap = &mxc_isi->isi_cap; - struct v4l2_subdev *subdev = &isi_cap->sd; - struct media_pad *sink_pad, *source_pad; - int i; - - while (1) { - source_pad = NULL; - for (i = 0; i < subdev->entity.num_pads; i++) { - sink_pad = &subdev->entity.pads[i]; - - if (sink_pad->flags & MEDIA_PAD_FL_SINK) { - source_pad = media_entity_remote_pad(sink_pad); - if (source_pad) - break; - } - } - /* return first pad point in the loop */ - return source_pad; - } - - if (i == subdev->entity.num_pads) - v4l2_err(mxc_isi->v4l2_dev, "%s, No remote pad found!\n", __func__); - - return NULL; -} - -/* Update input frame size and formate */ -static int mxc_isi_source_fmt_init(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_frame *src_f = &mxc_isi->isi_cap.src_f; - struct v4l2_subdev_format src_fmt; - struct media_pad *source_pad; - struct v4l2_subdev *src_sd; - int ret; - - /* Get remote source pad */ - source_pad = mxc_isi_get_remote_source_pad(mxc_isi); - if (source_pad == NULL) { - v4l2_err(mxc_isi->v4l2_dev, "%s, No remote pad found!\n", __func__); - return -EINVAL; - } - - /* Get remote source pad subdev */ - src_sd = media_entity_to_v4l2_subdev(source_pad->entity); - if (src_sd == NULL) { - v4l2_err(mxc_isi->v4l2_dev, "%s, No remote subdev found!\n", __func__); - return -EINVAL; - } - - src_fmt.pad = source_pad->index; - src_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; - ret = v4l2_subdev_call(src_sd, pad, get_fmt, NULL, &src_fmt); - if (ret < 0 && ret != -ENOIOCTLCMD) { - v4l2_err(mxc_isi->v4l2_dev, "%s, get remote fmt faile!\n", __func__); - return -EINVAL; - } - - /* Pixel link master will transfer format to RGB32 or YUV32 */ - src_f->fmt = mxc_isi_get_src_fmt(&src_fmt); - - set_frame_bounds(src_f, src_fmt.format.width, src_fmt.format.height); - - return 0; -} - -static int mxc_isi_cap_s_fmt_mplane(struct file *file, void *priv, - struct v4l2_format *f) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; - struct mxc_isi_frame *dst_f = &mxc_isi->isi_cap.dst_f; - struct mxc_isi_fmt *fmt; - int bpl; - int i; - - /* Step1: Check format with output support format list. - * Step2: Update output frame information. - * Step3: Checkout the format whether is supported by remote subdev - * Step3.1: If Yes, call remote subdev set_fmt. - * Step3.2: If NO, call remote subdev get_fmt. - * Step4: Update input frame information. - * Step5: Update mxc isi channel configuration. - * */ - - dev_dbg(&mxc_isi->pdev->dev, "%s, fmt=0x%X\n", __func__, pix->pixelformat); - if (vb2_is_busy(&mxc_isi->isi_cap.vb2_q)) { - return -EBUSY; - } - - /* Check out put format */ - for (i = 0; i < ARRAY_SIZE(mxc_isi_out_formats); i++) { - fmt = &mxc_isi_out_formats[i]; - if (pix && fmt->fourcc == pix->pixelformat) - break; - } - - if (i >= ARRAY_SIZE(mxc_isi_out_formats)) { - dev_dbg(&mxc_isi->pdev->dev, "%s, format is not support!\n", __func__); - return -EINVAL; - } - - /* update out put frame size and formate */ - if (pix->height <= 0 || pix->width <= 0) - return -EINVAL; - - dst_f->fmt = fmt; - dst_f->height = pix->height; - dst_f->width = pix->width; - - pix->num_planes = fmt->memplanes; - - for (i = 0; i < pix->num_planes; i++) { - bpl = pix->plane_fmt[i].bytesperline; - if ((bpl == 0) || (bpl / (fmt->depth[i] >> 3)) < pix->width) - pix->plane_fmt[i].bytesperline = - (pix->width * fmt->depth[i]) >> 3; - if (pix->plane_fmt[i].sizeimage == 0) - pix->plane_fmt[i].sizeimage = (pix->width * pix->height * - fmt->depth[i] >> 3); - } - - if (pix->num_planes > 1) { - for (i = 0; i < pix->num_planes; i++) { - dst_f->bytesperline[i] = pix->plane_fmt[i].bytesperline; - dst_f->sizeimage[i] = pix->plane_fmt[i].sizeimage; - } - } else { - dst_f->bytesperline[0] = dst_f->width * dst_f->fmt->depth[0] / 8; - dst_f->sizeimage[0] = dst_f->height * dst_f->bytesperline[0]; - } - - set_frame_bounds(dst_f, pix->width, pix->height); - - mxc_isi_source_fmt_init(mxc_isi); - - /* configure mxc isi channel */ - mxc_isi_channel_config(mxc_isi); - - return 0; -} - -static int mxc_isi_cap_streamon(struct file *file, void *priv, - enum v4l2_buf_type type) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - int ret; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - mxc_isi_pipeline_enable(mxc_isi, 1); - - ret = vb2_ioctl_streamon(file, priv, type); - - mxc_isi_channel_enable(mxc_isi); - - return ret; -} - -static int mxc_isi_cap_streamoff(struct file *file, void *priv, - enum v4l2_buf_type type) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - int ret; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - mxc_isi_pipeline_enable(mxc_isi, 0); - - ret = vb2_ioctl_streamoff(file, priv, type); - mxc_isi_channel_disable(mxc_isi); - - return ret; -} - -static int mxc_isi_cap_g_selection(struct file *file, void *fh, - struct v4l2_selection *s) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct mxc_isi_frame *f = &mxc_isi->isi_cap.src_f; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - - if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) - return -EINVAL; - - switch (s->target) { - case V4L2_SEL_TGT_COMPOSE_DEFAULT: - case V4L2_SEL_TGT_COMPOSE_BOUNDS: - f = &mxc_isi->isi_cap.dst_f; - case V4L2_SEL_TGT_CROP_BOUNDS: - case V4L2_SEL_TGT_CROP_DEFAULT: - s->r.left = 0; - s->r.top = 0; - s->r.width = f->o_width; - s->r.height = f->o_height; - return 0; - - case V4L2_SEL_TGT_COMPOSE: - f = &mxc_isi->isi_cap.dst_f; - case V4L2_SEL_TGT_CROP: - s->r.left = f->h_off; - s->r.top = f->v_off; - s->r.width = f->width; - s->r.height = f->height; - return 0; - } - - return -EINVAL; -} - -static int enclosed_rectangle(struct v4l2_rect *a, struct v4l2_rect *b) -{ - if (a->left < b->left || a->top < b->top) - return 0; - - if (a->left + a->width > b->left + b->width) - return 0; - - if (a->top + a->height > b->top + b->height) - return 0; - - return 1; -} -static int mxc_isi_cap_s_selection(struct file *file, void *fh, - struct v4l2_selection *s) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct mxc_isi_frame *f; - struct v4l2_rect rect = s->r; - unsigned long flags; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) - return -EINVAL; - - if (s->target == V4L2_SEL_TGT_COMPOSE) - f = &mxc_isi->isi_cap.dst_f; - else if (s->target == V4L2_SEL_TGT_CROP) - f = &mxc_isi->isi_cap.src_f; - else - return -EINVAL; - - if (s->flags & V4L2_SEL_FLAG_LE && - !enclosed_rectangle(&rect, &s->r)) - return -ERANGE; - - if (s->flags & V4L2_SEL_FLAG_GE && - !enclosed_rectangle(&s->r, &rect)) - return -ERANGE; - - s->r = rect; - spin_lock_irqsave(&mxc_isi->slock, flags); - set_frame_crop(f, s->r.left, s->r.top, s->r.width, - s->r.height); - spin_unlock_irqrestore(&mxc_isi->slock, flags); - - return 0; -} - -static struct v4l2_subdev *mxc_isi_get_subdev_by_name(struct v4l2_device *v4l2, - const char *name) -{ - struct v4l2_subdev *sd; - bool found = false; - - list_for_each_entry(sd, &v4l2->subdevs, list) { - if (strstr(sd->name, name) != NULL) { - found = true; - break; - } - } - - return (found) ? sd : NULL; -} - -static int mxc_isi_cap_g_chip_ident(struct file *file, void *fb, - struct v4l2_dbg_chip_ident *chip) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_device *v4l2_dev = mxc_isi->isi_cap.sd.v4l2_dev; - struct video_device *vdev = video_devdata(file); - struct sensor_data *max9286; - struct v4l2_subdev *sd; - - sd = mxc_isi_get_subdev_by_name(v4l2_dev, "max9286_mipi"); - if (sd == NULL) { - v4l2_err(&mxc_isi->isi_cap.sd, "Can't find sub device\n"); - return -ENODEV; - } - - max9286 = container_of(sd, struct sensor_data, subdev); - if (max9286->sensor_is_there & (0x1 << vdev->num)) - sprintf(chip->match.name, "max9286_mipi%d\n", vdev->num); - else - return -ENODEV; - - return 0; -} - -static int mxc_isi_cap_g_parm(struct file *file, void *fh, - struct v4l2_streamparm *a) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_device *v4l2_dev = mxc_isi->isi_cap.sd.v4l2_dev; - struct v4l2_subdev *sd; - - sd = mxc_isi_get_subdev_by_name(v4l2_dev, "max9286_mipi"); - if (sd == NULL) { - v4l2_err(&mxc_isi->isi_cap.sd, "Can't find subdev\n"); - return -ENODEV; - } - return v4l2_subdev_call(sd, video, g_parm, a); -} - -static int mxc_isi_cap_s_parm(struct file *file, void *fh, - struct v4l2_streamparm *a) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_device *v4l2_dev = mxc_isi->isi_cap.sd.v4l2_dev; - struct v4l2_subdev *sd; - - sd = mxc_isi_get_subdev_by_name(v4l2_dev, "max9286_mipi"); - if (sd == NULL) { - v4l2_err(&mxc_isi->isi_cap.sd, "Can't find subdev\n"); - return -ENODEV; - } - return v4l2_subdev_call(sd, video, s_parm, a); -} - -static int mxc_isi_cap_enum_framesizes(struct file *file, void *priv, - struct v4l2_frmsizeenum *fsize) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_device *v4l2_dev = mxc_isi->isi_cap.sd.v4l2_dev; - struct v4l2_subdev *sd; - struct mxc_isi_fmt *fmt; - struct v4l2_subdev_frame_size_enum fse = { - .index = fsize->index, - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - }; - int ret; - - fmt = mxc_isi_find_format(&fsize->pixel_format, NULL, 0); - if (!fmt || fmt->fourcc != fsize->pixel_format) - return -EINVAL; - fse.code = fmt->mbus_code; - - sd = mxc_isi_get_subdev_by_name(v4l2_dev, "max9286_mipi"); - if (sd == NULL) { - v4l2_err(&mxc_isi->isi_cap.sd, "Can't find subdev\n"); - return -ENODEV; - } - - ret = v4l2_subdev_call(sd, pad, enum_frame_size, NULL, &fse); - if (ret) - return ret; - - if (fse.min_width == fse.max_width && - fse.min_height == fse.max_height) { - fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; - fsize->discrete.width = fse.min_width; - fsize->discrete.height = fse.min_height; - return 0; - } - - fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; - fsize->stepwise.min_width = fse.min_width; - fsize->stepwise.max_width = fse.max_width; - fsize->stepwise.min_height = fse.min_height; - fsize->stepwise.max_height = fse.max_height; - fsize->stepwise.step_width = 1; - fsize->stepwise.step_height = 1; - - return 0; -} - -static int mxc_isi_cap_enum_frameintervals(struct file *file, void *fh, - struct v4l2_frmivalenum *interval) -{ - struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_device *v4l2_dev = mxc_isi->isi_cap.sd.v4l2_dev; - struct v4l2_subdev *sd; - struct mxc_isi_fmt *fmt; - struct v4l2_subdev_frame_interval_enum fie = { - .index = interval->index, - .width = interval->width, - .height = interval->height, - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - }; - int ret; - - fmt = mxc_isi_find_format(&interval->pixel_format, NULL, 0); - if (!fmt || fmt->fourcc != interval->pixel_format) - return -EINVAL; - fie.code = fmt->mbus_code; - - sd = mxc_isi_get_subdev_by_name(v4l2_dev, "max9286_mipi"); - if (sd == NULL) { - v4l2_err(&mxc_isi->isi_cap.sd, "Can't find subdev\n"); - return -ENODEV; - } - - ret = v4l2_subdev_call(sd, pad, enum_frame_interval, NULL, &fie); - if (ret) - return ret; - - interval->type = V4L2_FRMIVAL_TYPE_DISCRETE; - interval->discrete = fie.interval; - - return 0; -} - -static const struct v4l2_ioctl_ops mxc_isi_capture_ioctl_ops = { - .vidioc_querycap = mxc_isi_cap_querycap, - - .vidioc_enum_fmt_vid_cap_mplane = mxc_isi_cap_enum_fmt_mplane, - .vidioc_try_fmt_vid_cap_mplane = mxc_isi_cap_try_fmt_mplane, - .vidioc_s_fmt_vid_cap_mplane = mxc_isi_cap_s_fmt_mplane, - .vidioc_g_fmt_vid_cap_mplane = mxc_isi_cap_g_fmt_mplane, - - .vidioc_reqbufs = vb2_ioctl_reqbufs, - .vidioc_querybuf = vb2_ioctl_querybuf, - .vidioc_qbuf = vb2_ioctl_qbuf, - .vidioc_dqbuf = vb2_ioctl_dqbuf, - .vidioc_expbuf = vb2_ioctl_expbuf, - .vidioc_prepare_buf = vb2_ioctl_prepare_buf, - .vidioc_create_bufs = vb2_ioctl_create_bufs, - - .vidioc_streamon = mxc_isi_cap_streamon, - .vidioc_streamoff = mxc_isi_cap_streamoff, - - .vidioc_g_selection = mxc_isi_cap_g_selection, - .vidioc_s_selection = mxc_isi_cap_s_selection, - .vidioc_g_chip_ident = mxc_isi_cap_g_chip_ident, - - .vidioc_g_parm = mxc_isi_cap_g_parm, - .vidioc_s_parm = mxc_isi_cap_s_parm, - - .vidioc_enum_framesizes = mxc_isi_cap_enum_framesizes, - .vidioc_enum_frameintervals = mxc_isi_cap_enum_frameintervals, -}; - -/* Capture subdev media entity operations */ -static int mxc_isi_link_setup(struct media_entity *entity, - const struct media_pad *local, - const struct media_pad *remote, u32 flags) -{ - struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); - struct mxc_isi_dev *mxc_isi = v4l2_get_subdevdata(sd); - - if (WARN_ON(mxc_isi == NULL)) - return 0; - - if (!(flags & MEDIA_LNK_FL_ENABLED)) { - return 0; - } - /* TODO */ - /* Add ISI source and sink pad link configuration */ - if (local->flags & MEDIA_PAD_FL_SOURCE) { - switch (local->index) { - case MXC_ISI_SD_PAD_SOURCE_DC0: - case MXC_ISI_SD_PAD_SOURCE_DC1: - break; - case MXC_ISI_SD_PAD_SOURCE_MEM: - default: - return 0; - } - } else if (local->flags & MEDIA_PAD_FL_SINK) { - switch (local->index) { - case MXC_ISI_SD_PAD_SINK_MIPI0_VC0: - case MXC_ISI_SD_PAD_SINK_MIPI0_VC1: - case MXC_ISI_SD_PAD_SINK_MIPI0_VC2: - case MXC_ISI_SD_PAD_SINK_MIPI0_VC3: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC0: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC1: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC2: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC3: - case MXC_ISI_SD_PAD_SINK_HDMI: - case MXC_ISI_SD_PAD_SINK_DC0: - case MXC_ISI_SD_PAD_SINK_DC1: - case MXC_ISI_SD_PAD_SINK_MEM: - break; - } - } - - return 0; -} - -static const struct media_entity_operations mxc_isi_sd_media_ops = { - .link_setup = mxc_isi_link_setup, -}; - -static int mxc_isi_subdev_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) -{ - return 0; -} - -static int mxc_isi_subdev_get_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) -{ - struct mxc_isi_dev *mxc_isi = v4l2_get_subdevdata(sd); - struct mxc_isi_frame *f; - struct v4l2_mbus_framefmt *mf; - - mutex_lock(&mxc_isi->lock); - - switch (fmt->pad) { - case MXC_ISI_SD_PAD_SOURCE_MEM: - case MXC_ISI_SD_PAD_SOURCE_DC0: - case MXC_ISI_SD_PAD_SOURCE_DC1: - f = &mxc_isi->isi_cap.dst_f; - break; - case MXC_ISI_SD_PAD_SINK_MIPI0_VC0: - case MXC_ISI_SD_PAD_SINK_MIPI0_VC1: - case MXC_ISI_SD_PAD_SINK_MIPI0_VC2: - case MXC_ISI_SD_PAD_SINK_MIPI0_VC3: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC0: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC1: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC2: - case MXC_ISI_SD_PAD_SINK_MIPI1_VC3: - case MXC_ISI_SD_PAD_SINK_HDMI: - case MXC_ISI_SD_PAD_SINK_DC0: - case MXC_ISI_SD_PAD_SINK_DC1: - case MXC_ISI_SD_PAD_SINK_MEM: - f = &mxc_isi->isi_cap.src_f; - break; - default: - mutex_unlock(&mxc_isi->lock); - v4l2_err(mxc_isi->v4l2_dev, "%s, Pad is not support now!\n", __func__); - return -1; - } - - if (!WARN_ON(f->fmt == NULL)) - mf->code = f->fmt->mbus_code; - - /* Source/Sink pads crop rectangle size */ - mf->width = f->width; - mf->height = f->height; - - mutex_unlock(&mxc_isi->lock); - mf->colorspace = V4L2_COLORSPACE_JPEG; - - return 0; -} - -static int mxc_isi_subdev_set_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) -{ - struct mxc_isi_dev *mxc_isi = v4l2_get_subdevdata(sd); - struct v4l2_mbus_framefmt *mf = &fmt->format; - struct mxc_isi_frame *dst_f = &mxc_isi->isi_cap.dst_f; - struct mxc_isi_fmt *out_fmt; - int i; - - if (fmt->pad < MXC_ISI_SD_PAD_SOURCE_MEM && - vb2_is_busy(&mxc_isi->isi_cap.vb2_q)) - return -EBUSY; - - for (i = 0; i < ARRAY_SIZE(mxc_isi_out_formats); i++) { - out_fmt = &mxc_isi_out_formats[i]; - if (mf->code == out_fmt->mbus_code) - break; - } - if (i >= ARRAY_SIZE(mxc_isi_out_formats)) { - v4l2_err(mxc_isi->v4l2_dev, "%s, format is not support!\n", __func__); - return -EINVAL; - } - - mutex_lock(&mxc_isi->lock); - /* update out put frame size and formate */ - dst_f->fmt = &mxc_isi_out_formats[i]; - set_frame_bounds(dst_f, mf->width, mf->height); - mutex_unlock(&mxc_isi->lock); - - dev_dbg(&mxc_isi->pdev->dev, "pad%d: code: 0x%x, %dx%d", - fmt->pad, mf->code, mf->width, mf->height); - - return 0; -} - -static int mxc_isi_subdev_get_selection(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_selection *sel) -{ - struct mxc_isi_dev *mxc_isi = v4l2_get_subdevdata(sd); - struct mxc_isi_frame *f = &mxc_isi->isi_cap.src_f; - struct v4l2_rect *r = &sel->r; - struct v4l2_rect *try_sel; - - mutex_lock(&mxc_isi->lock); - - switch (sel->target) { - case V4L2_SEL_TGT_COMPOSE_BOUNDS: - f = &mxc_isi->isi_cap.dst_f; - case V4L2_SEL_TGT_CROP_BOUNDS: - r->width = f->o_width; - r->height = f->o_height; - r->left = 0; - r->top = 0; - mutex_unlock(&mxc_isi->lock); - return 0; - - case V4L2_SEL_TGT_CROP: - try_sel = v4l2_subdev_get_try_crop(sd, cfg, sel->pad); - break; - case V4L2_SEL_TGT_COMPOSE: - try_sel = v4l2_subdev_get_try_compose(sd, cfg, sel->pad); - f = &mxc_isi->isi_cap.dst_f; - break; - default: - mutex_unlock(&mxc_isi->lock); - return -EINVAL; - } - - if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { - sel->r = *try_sel; - } else { - r->left = f->h_off; - r->top = f->v_off; - r->width = f->width; - r->height = f->height; - } - - dev_dbg(&mxc_isi->pdev->dev, "%s, target %#x: l:%d, t:%d, %dx%d, f_w: %d, f_h: %d", - __func__, sel->pad, r->left, r->top, r->width, r->height, - f->c_width, f->c_height); - - mutex_unlock(&mxc_isi->lock); - return 0; -} - -static int mxc_isi_subdev_set_selection(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_selection *sel) -{ - struct mxc_isi_dev *mxc_isi = v4l2_get_subdevdata(sd); - struct mxc_isi_frame *f = &mxc_isi->isi_cap.src_f; - struct v4l2_rect *r = &sel->r; - struct v4l2_rect *try_sel; - unsigned long flags; - - mutex_lock(&mxc_isi->lock); - - switch (sel->target) { - case V4L2_SEL_TGT_CROP: - try_sel = v4l2_subdev_get_try_crop(sd, cfg, sel->pad); - break; - case V4L2_SEL_TGT_COMPOSE: - try_sel = v4l2_subdev_get_try_compose(sd, cfg, sel->pad); - f = &mxc_isi->isi_cap.dst_f; - break; - default: - mutex_unlock(&mxc_isi->lock); - return -EINVAL; - } - - if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { - *try_sel = sel->r; - } else { - spin_lock_irqsave(&mxc_isi->slock, flags); - set_frame_crop(f, r->left, r->top, r->width, r->height); - spin_unlock_irqrestore(&mxc_isi->slock, flags); - } - - dev_dbg(&mxc_isi->pdev->dev, "%s, target %#x: (%d,%d)/%dx%d", __func__, - sel->target, r->left, r->top, r->width, r->height); - - mutex_unlock(&mxc_isi->lock); - - return 0; -} - -static struct v4l2_subdev_pad_ops mxc_isi_subdev_pad_ops = { - .enum_mbus_code = mxc_isi_subdev_enum_mbus_code, - .get_selection = mxc_isi_subdev_get_selection, - .set_selection = mxc_isi_subdev_set_selection, - .get_fmt = mxc_isi_subdev_get_fmt, - .set_fmt = mxc_isi_subdev_set_fmt, -}; - -static struct v4l2_subdev_ops mxc_isi_subdev_ops = { - .pad = &mxc_isi_subdev_pad_ops, -}; - -static int mxc_isi_register_cap_device(struct mxc_isi_dev *mxc_isi, - struct v4l2_device *v4l2_dev) -{ - struct video_device *vdev = &mxc_isi->isi_cap.vdev; - struct vb2_queue *q = &mxc_isi->isi_cap.vb2_q; - struct mxc_isi_cap_dev *isi_cap = &mxc_isi->isi_cap; - int ret = -ENOMEM; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - memset(vdev, 0, sizeof(*vdev)); - snprintf(vdev->name, sizeof(vdev->name), "mxc_isi.%d.capture", mxc_isi->id); - - vdev->fops = &mxc_isi_capture_fops; - vdev->ioctl_ops = &mxc_isi_capture_ioctl_ops; - vdev->v4l2_dev = v4l2_dev; - vdev->minor = -1; - vdev->release = video_device_release_empty; - vdev->queue = q; - vdev->lock = &mxc_isi->lock; - - video_set_drvdata(vdev, mxc_isi); - - INIT_LIST_HEAD(&mxc_isi->isi_cap.out_pending); - INIT_LIST_HEAD(&mxc_isi->isi_cap.out_active); - - memset(q, 0, sizeof(*q)); - q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; - q->drv_priv = mxc_isi; - q->ops = &mxc_cap_vb2_qops; - q->mem_ops = &vb2_dma_contig_memops; - q->buf_struct_size = sizeof(struct mxc_isi_buffer); - q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->lock = &mxc_isi->lock; - - ret = vb2_queue_init(q); - if (ret) - goto err_free_ctx; - - /* Default configuration */ - isi_cap->dst_f.width = 1280; - isi_cap->dst_f.height = 800; - isi_cap->dst_f.fmt = &mxc_isi_out_formats[0];; - isi_cap->src_f.fmt = isi_cap->dst_f.fmt; - - isi_cap->cap_pad.flags = MEDIA_PAD_FL_SINK; - vdev->entity.function = MEDIA_ENT_F_PROC_VIDEO_SCALER; - ret = media_entity_pads_init(&vdev->entity, 1, &isi_cap->cap_pad); - if (ret) - goto err_free_ctx; - - ret = mxc_isi_ctrls_create(mxc_isi); - if (ret) - goto err_me_cleanup; - - ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); - if (ret) - goto err_ctrl_free; - - vdev->ctrl_handler = &mxc_isi->ctrls.handler; - v4l2_info(v4l2_dev, "Registered %s as /dev/%s\n", - vdev->name, video_device_node_name(vdev)); - - return 0; - -err_ctrl_free: - mxc_isi_ctrls_delete(mxc_isi); -err_me_cleanup: - media_entity_cleanup(&vdev->entity); -err_free_ctx: - return ret; -} - -static int mxc_isi_capture_subdev_registered(struct v4l2_subdev *sd) -{ - struct mxc_isi_dev *mxc_isi = v4l2_get_subdevdata(sd); - int ret; - - if (mxc_isi == NULL) - return -ENXIO; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); -#if 0 - if (mxc_isi->id == 0) { - /* ISI channel 0 support source input image from memory */ - ret = mxc_isi_register_m2m_device(mxc_isi, sd->v4l2_dev); - if (ret < 0) - return ret; - } -#endif - - ret = mxc_isi_register_cap_device(mxc_isi, sd->v4l2_dev); - if (ret < 0) - return ret; - - return ret; -} - -static void mxc_isi_capture_subdev_unregistered(struct v4l2_subdev *sd) -{ - struct mxc_isi_dev *mxc_isi = v4l2_get_subdevdata(sd); - struct video_device *vdev; - - if (mxc_isi == NULL) - return; - - dev_dbg(&mxc_isi->pdev->dev, "%s\n", __func__); - mutex_lock(&mxc_isi->lock); - - vdev = &mxc_isi->isi_cap.vdev; - if (video_is_registered(vdev)) { - video_unregister_device(vdev); - mxc_isi_ctrls_delete(mxc_isi); - media_entity_cleanup(&vdev->entity); - } - - mutex_unlock(&mxc_isi->lock); -} - -static const struct v4l2_subdev_internal_ops mxc_isi_capture_sd_internal_ops = { - .registered = mxc_isi_capture_subdev_registered, - .unregistered = mxc_isi_capture_subdev_unregistered, -}; - -int mxc_isi_initialize_capture_subdev(struct mxc_isi_dev *mxc_isi) -{ - struct v4l2_subdev *sd = &mxc_isi->isi_cap.sd; - int ret; - - v4l2_subdev_init(sd, &mxc_isi_subdev_ops); - sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - snprintf(sd->name, sizeof(sd->name), "mxc_isi.%d", mxc_isi->id); - - sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER; - - /* ISI Sink pads */ - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI0_VC0].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI0_VC1].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI0_VC2].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI0_VC3].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI1_VC0].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI1_VC1].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI1_VC2].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MIPI1_VC3].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_DC0].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_DC1].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_HDMI].flags = MEDIA_PAD_FL_SINK; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SINK_MEM].flags = MEDIA_PAD_FL_SINK; - - /* ISI source pads */ - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SOURCE_MEM].flags = MEDIA_PAD_FL_SOURCE; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SOURCE_DC0].flags = MEDIA_PAD_FL_SOURCE; - mxc_isi->isi_cap.sd_pads[MXC_ISI_SD_PAD_SOURCE_DC1].flags = MEDIA_PAD_FL_SOURCE; - - ret = media_entity_pads_init(&sd->entity, MXC_ISI_SD_PADS_NUM, - mxc_isi->isi_cap.sd_pads); - if (ret) - return ret; - - sd->entity.ops = &mxc_isi_sd_media_ops; - sd->internal_ops = &mxc_isi_capture_sd_internal_ops; - v4l2_set_subdevdata(sd, mxc_isi); - - return 0; -} - -void mxc_isi_unregister_capture_subdev(struct mxc_isi_dev *mxc_isi) -{ - struct v4l2_subdev *sd = &mxc_isi->isi_cap.sd; - - v4l2_device_unregister_subdev(sd); - media_entity_cleanup(&sd->entity); - v4l2_set_subdevdata(sd, NULL); -} diff --git a/drivers/media/platform/imx8/mxc-isi-core.c b/drivers/media/platform/imx8/mxc-isi-core.c deleted file mode 100644 index 29a1999edfe5bb60c8e547bbc3f5874a208562e3..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-isi-core.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include "mxc-media-dev.h" - -static irqreturn_t mxc_isi_irq_handler(int irq, void *priv) -{ - struct mxc_isi_dev *mxc_isi = priv; - struct device *dev = &mxc_isi->pdev->dev; - u32 status; - - spin_lock(&mxc_isi->slock); - - status = mxc_isi_get_irq_status(mxc_isi); - mxc_isi_clean_irq_status(mxc_isi, status); - - if (status & CHNL_STS_FRM_STRD_MASK) - mxc_isi_frame_write_done(mxc_isi); - - if (status & (CHNL_STS_AXI_WR_ERR_Y_MASK | - CHNL_STS_AXI_WR_ERR_U_MASK | - CHNL_STS_AXI_WR_ERR_V_MASK)) - dev_dbg(dev, "%s, IRQ AXI Error stat=0x%X\n", __func__, status); - if (status & (CHNL_STS_OFLW_PANIC_Y_BUF_MASK | - CHNL_STS_OFLW_PANIC_U_BUF_MASK | - CHNL_STS_OFLW_PANIC_V_BUF_MASK)) - dev_dbg(dev, "%s, IRQ Panic OFLW Error stat=0x%X\n", __func__, status); - if (status & (CHNL_STS_OFLW_Y_BUF_MASK | - CHNL_STS_OFLW_U_BUF_MASK | - CHNL_STS_OFLW_V_BUF_MASK)) - dev_dbg(dev, "%s, IRQ OFLW Error stat=0x%X\n", __func__, status); - if (status & (CHNL_STS_EXCS_OFLW_Y_BUF_MASK | - CHNL_STS_EXCS_OFLW_U_BUF_MASK | - CHNL_STS_EXCS_OFLW_V_BUF_MASK)) - dev_dbg(dev, "%s, IRQ EXCS OFLW Error stat=0x%X\n", __func__, status); - - spin_unlock(&mxc_isi->slock); - return IRQ_HANDLED; -} - -/** - * mxc_isi_adjust_mplane_format - adjust bytesperline or sizeimage - */ -void mxc_isi_adjust_mplane_format(struct mxc_isi_fmt *fmt, u32 width, u32 height, - struct v4l2_pix_format_mplane *pix) -{ - u32 bytesperline = 0; - int i; - - pix->colorspace = V4L2_COLORSPACE_JPEG; - pix->field = V4L2_FIELD_NONE; - pix->num_planes = fmt->memplanes; - pix->pixelformat = fmt->fourcc; - pix->height = height; - pix->width = width; - - for (i = 0; i < pix->num_planes; ++i) { - struct v4l2_plane_pix_format *plane_fmt = &pix->plane_fmt[i]; - u32 bpl = plane_fmt->bytesperline; - - if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width)) - bpl = pix->width; /* Planar */ - - if (fmt->colplanes == 1 && /* Packed */ - (bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width)) - bpl = (pix->width * fmt->depth[0]) / 8; - - if (i == 0) - bytesperline = bpl; - else if (i == 1 && fmt->memplanes == 3) - bytesperline /= 2; - - plane_fmt->bytesperline = bytesperline; - plane_fmt->sizeimage = max((pix->width * pix->height * - fmt->depth[i]) / 8, plane_fmt->sizeimage); - } -} - -static int mxc_isi_parse_dt(struct mxc_isi_dev *mxc_isi) -{ - struct device *dev = &mxc_isi->pdev->dev; - struct device_node *node = dev->of_node; - int ret = 0; - - mxc_isi->id = of_alias_get_id(node, "isi"); - - ret = of_property_read_u32_array(node, "interface", - mxc_isi->interface, 3); - if (ret < 0) - return ret; - - dev_dbg(dev, "%s, isi_%d,interface(%d, %d, %d)\n", __func__, mxc_isi->id, - mxc_isi->interface[0], mxc_isi->interface[1], mxc_isi->interface[2]); - return 0; -} - -static int mxc_isi_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct mxc_isi_dev *mxc_isi; - struct resource *res; - int ret = 0; - - mxc_isi = devm_kzalloc(dev, sizeof(*mxc_isi), GFP_KERNEL); - if (!mxc_isi) - return -ENOMEM; - - mxc_isi->pdev = pdev; - - ret = mxc_isi_parse_dt(mxc_isi); - if (ret < 0) - return ret; - - if (mxc_isi->id >= MXC_ISI_MAX_DEVS || mxc_isi->id < 0) { - dev_err(dev, "Invalid driver data or device id (%d)\n", - mxc_isi->id); - return -EINVAL; - } - - init_waitqueue_head(&mxc_isi->irq_queue); - spin_lock_init(&mxc_isi->slock); - mutex_init(&mxc_isi->lock); - - mxc_isi->clk = devm_clk_get(dev, NULL); - if (IS_ERR(mxc_isi->clk)) { - dev_err(dev, "failed to get isi clk\n"); - return PTR_ERR(mxc_isi->clk); - } - ret = clk_prepare(mxc_isi->clk); - if (ret < 0) { - dev_err(dev, "%s, prepare clk error\n", __func__); - return -EINVAL; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - mxc_isi->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(mxc_isi->regs)) { - dev_err(dev, "Failed to get ISI register map\n"); - return PTR_ERR(mxc_isi->regs); - } - - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (res == NULL) { - dev_err(dev, "Failed to get IRQ resource\n"); - return -ENXIO; - } - - ret = devm_request_irq(dev, res->start, mxc_isi_irq_handler, - 0, dev_name(dev), mxc_isi); - if (ret < 0) { - dev_err(dev, "failed to install irq (%d)\n", ret); - return -EINVAL; - } - - ret = mxc_isi_initialize_capture_subdev(mxc_isi); - if (ret < 0) { - dev_err(dev, "failed to init cap subdev (%d)\n", ret); - return -EINVAL; - } - - platform_set_drvdata(pdev, mxc_isi); - - ret = clk_enable(mxc_isi->clk); - if (ret < 0) { - dev_err(dev, "%s, enable clk error\n", __func__); - goto err_sclk; - } - - mxc_isi->flags = MXC_ISI_PM_POWERED; - - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - pm_runtime_get_sync(dev); - pm_runtime_put_sync(dev); - - dev_dbg(dev, "mxc_isi.%d registered successfully\n", mxc_isi->id); - - return 0; - -err_sclk: - mxc_isi_unregister_capture_subdev(mxc_isi); - return ret; -} - -static int mxc_isi_remove(struct platform_device *pdev) -{ - struct mxc_isi_dev *mxc_isi = platform_get_drvdata(pdev); - struct device *dev = &pdev->dev; - - mxc_isi_unregister_capture_subdev(mxc_isi); - - clk_disable_unprepare(mxc_isi->clk); - pm_runtime_disable(dev); - - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int mxc_isi_pm_suspend(struct device *dev) -{ - struct mxc_isi_dev *mxc_isi = dev_get_drvdata(dev); - - if ((mxc_isi->flags & MXC_ISI_PM_SUSPENDED) || - (mxc_isi->flags & MXC_ISI_RUNTIME_SUSPEND)) - return 0; - - clk_disable_unprepare(mxc_isi->clk); - mxc_isi->flags |= MXC_ISI_PM_SUSPENDED; - mxc_isi->flags &= ~MXC_ISI_PM_POWERED; - - return 0; -} - -static int mxc_isi_pm_resume(struct device *dev) -{ - struct mxc_isi_dev *mxc_isi = dev_get_drvdata(dev); - int ret; - - if (mxc_isi->flags & MXC_ISI_PM_POWERED) - return 0; - - mxc_isi->flags |= MXC_ISI_PM_POWERED; - mxc_isi->flags &= ~MXC_ISI_PM_SUSPENDED; - - ret = clk_prepare_enable(mxc_isi->clk); - return (ret) ? -EAGAIN : 0; -} -#endif - -static int mxc_isi_runtime_suspend(struct device *dev) -{ - struct mxc_isi_dev *mxc_isi = dev_get_drvdata(dev); - - if (mxc_isi->flags & MXC_ISI_RUNTIME_SUSPEND) - return 0; - - if (mxc_isi->flags & MXC_ISI_PM_POWERED) { - clk_disable_unprepare(mxc_isi->clk); - mxc_isi->flags |= MXC_ISI_RUNTIME_SUSPEND; - mxc_isi->flags &= ~MXC_ISI_PM_POWERED; - } - return 0; -} - -static int mxc_isi_runtime_resume(struct device *dev) -{ - struct mxc_isi_dev *mxc_isi = dev_get_drvdata(dev); - - if (mxc_isi->flags & MXC_ISI_PM_POWERED) - return 0; - - if (mxc_isi->flags & MXC_ISI_RUNTIME_SUSPEND) { - clk_prepare_enable(mxc_isi->clk); - mxc_isi->flags |= MXC_ISI_PM_POWERED; - mxc_isi->flags &= ~MXC_ISI_RUNTIME_SUSPEND; - } - - return 0; -} - -static const struct dev_pm_ops mxc_isi_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(mxc_isi_pm_suspend, mxc_isi_pm_resume) - SET_RUNTIME_PM_OPS(mxc_isi_runtime_suspend, mxc_isi_runtime_resume, NULL) -}; - -static const struct of_device_id mxc_isi_of_match[] = { - {.compatible = "fsl,imx8-isi",}, - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(of, mxc_isi_of_match); - -static struct platform_driver mxc_isi_driver = { - .probe = mxc_isi_probe, - .remove = mxc_isi_remove, - .driver = { - .of_match_table = mxc_isi_of_match, - .name = MXC_ISI_DRIVER_NAME, - .pm = &mxc_isi_pm_ops, - } -}; - -module_platform_driver(mxc_isi_driver); diff --git a/drivers/media/platform/imx8/mxc-isi-core.h b/drivers/media/platform/imx8/mxc-isi-core.h deleted file mode 100644 index 0c6b11df5279c999a1b1f8c42313aa8d19527919..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-isi-core.h +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#ifndef MXC_ISI_CORE_H_ -#define MXC_ISI_CORE_H_ - -#include -#include -#include -#include -#include - -#define MXC_ISI_DRIVER_NAME "mxc-isi" -#define MXC_ISI_MAX_DEVS 8 - -#define ISI_OF_NODE_NAME "isi" - -#define MXC_ISI_SD_PAD_SINK_MIPI0_VC0 0 -#define MXC_ISI_SD_PAD_SINK_MIPI0_VC1 1 -#define MXC_ISI_SD_PAD_SINK_MIPI0_VC2 2 -#define MXC_ISI_SD_PAD_SINK_MIPI0_VC3 3 -#define MXC_ISI_SD_PAD_SINK_MIPI1_VC0 4 -#define MXC_ISI_SD_PAD_SINK_MIPI1_VC1 5 -#define MXC_ISI_SD_PAD_SINK_MIPI1_VC2 6 -#define MXC_ISI_SD_PAD_SINK_MIPI1_VC3 7 -#if 0 -#define MXC_ISI_SD_PAD_SINK_MIPI_CSI0 0 -#define MXC_ISI_SD_PAD_SINK_MIPI_CSI1 1 -#endif -#define MXC_ISI_SD_PAD_SINK_DC0 8 -#define MXC_ISI_SD_PAD_SINK_DC1 9 -#define MXC_ISI_SD_PAD_SINK_HDMI 10 -#define MXC_ISI_SD_PAD_SINK_MEM 11 -#define MXC_ISI_SD_PAD_SOURCE_MEM 12 -#define MXC_ISI_SD_PAD_SOURCE_DC0 13 -#define MXC_ISI_SD_PAD_SOURCE_DC1 14 -#define MXC_ISI_SD_PADS_NUM 15 - -#define MXC_MAX_PLANES 3 - -enum isi_input_interface { - ISI_INPUT_INTERFACE_DC0 = 0, - ISI_INPUT_INTERFACE_DC1, - ISI_INPUT_INTERFACE_MIPI0_CSI2, - ISI_INPUT_INTERFACE_MIPI1_CSI2, - ISI_INPUT_INTERFACE_HDMI, - ISI_INPUT_INTERFACE_MEM, - ISI_INPUT_INTERFACE_MAX, -}; - -enum isi_input_sub_interface { - ISI_INPUT_SUB_INTERFACE_VC0 = 0, - ISI_INPUT_SUB_INTERFACE_VC1, - ISI_INPUT_SUB_INTERFACE_VC2, - ISI_INPUT_SUB_INTERFACE_VC3, -}; - -enum isi_output_interface { - ISI_OUTPUT_INTERFACE_DC0 = 0, - ISI_OUTPUT_INTERFACE_DC1, - ISI_OUTPUT_INTERFACE_MEM, - ISI_OUTPUT_INTERFACE_MAX, -}; - -enum { - IN_PORT, - SUB_IN_PORT, - OUT_PORT, - MAX_PORTS, -}; - -enum mxc_isi_out_fmt { - MXC_ISI_OUT_FMT_RGBA32 = 0x0, - MXC_ISI_OUT_FMT_ABGR32, - MXC_ISI_OUT_FMT_ARGB32, - MXC_ISI_OUT_FMT_RGBX32, - MXC_ISI_OUT_FMT_XBGR32, - MXC_ISI_OUT_FMT_XRGB32, - MXC_ISI_OUT_FMT_RGB32P, - MXC_ISI_OUT_FMT_BGR32P, - MXC_ISI_OUT_FMT_A2BGR10, - MXC_ISI_OUT_FMT_A2RGB10, - MXC_ISI_OUT_FMT_RGB565, - MXC_ISI_OUT_FMT_RAW8, - MXC_ISI_OUT_FMT_RAW10, - MXC_ISI_OUT_FMT_RAW10P, - MXC_ISI_OUT_FMT_RAW12, - MXC_ISI_OUT_FMT_RAW16, - MXC_ISI_OUT_FMT_YUV444_1P8P, - MXC_ISI_OUT_FMT_YUV444_2P8P, - MXC_ISI_OUT_FMT_YUV444_3P8P, - MXC_ISI_OUT_FMT_YUV444_1P8, - MXC_ISI_OUT_FMT_YUV444_1P10, - MXC_ISI_OUT_FMT_YUV444_2P10, - MXC_ISI_OUT_FMT_YUV444_3P10, - MXC_ISI_OUT_FMT_YUV444_1P10P = 0x18, - MXC_ISI_OUT_FMT_YUV444_2P10P, - MXC_ISI_OUT_FMT_YUV444_3P10P, - MXC_ISI_OUT_FMT_YUV444_1P12 = 0x1C, - MXC_ISI_OUT_FMT_YUV444_2P12, - MXC_ISI_OUT_FMT_YUV444_3P12, - MXC_ISI_OUT_FMT_YUV422_1P8P = 0x20, - MXC_ISI_OUT_FMT_YUV422_2P8P, - MXC_ISI_OUT_FMT_YUV422_3P8P, - MXC_ISI_OUT_FMT_YUV422_1P10 = 0x24, - MXC_ISI_OUT_FMT_YUV422_2P10, - MXC_ISI_OUT_FMT_YUV422_3P10, - MXC_ISI_OUT_FMT_YUV422_1P10P = 0x28, - MXC_ISI_OUT_FMT_YUV422_2P10P, - MXC_ISI_OUT_FMT_YUV422_3P10P, - MXC_ISI_OUT_FMT_YUV422_1P12 = 0x2C, - MXC_ISI_OUT_FMT_YUV422_2P12, - MXC_ISI_OUT_FMT_YUV422_3P12, - MXC_ISI_OUT_FMT_YUV420_2P8P = 0x31, - MXC_ISI_OUT_FMT_YUV420_3P8P, - MXC_ISI_OUT_FMT_YUV420_2P10 = 0x35, - MXC_ISI_OUT_FMT_YUV420_3P10, - MXC_ISI_OUT_FMT_YUV420_2P10P = 0x39, - MXC_ISI_OUT_FMT_YUV420_3P10P, - MXC_ISI_OUT_FMT_YUV420_2P12 = 0x3D, - MXC_ISI_OUT_FMT_YUV420_3P12, -}; - -enum mxc_isi_in_fmt { - MXC_ISI_IN_FMT_BGR8P = 0x0, -}; - -enum mxc_isi_m2m_in_fmt { - MXC_ISI_M2M_IN_FMT_BGR8P = 0x0, - MXC_ISI_M2M_IN_FMT_RGB8P, - MXC_ISI_M2M_IN_FMT_XRGB8, - MXC_ISI_M2M_IN_FMT_RGBX8, - MXC_ISI_M2M_IN_FMT_XBGR8, - MXC_ISI_M2M_IN_FMT_RGB565, - MXC_ISI_M2M_IN_FMT_A2BGR10, - MXC_ISI_M2M_IN_FMT_A2RGB10, - MXC_ISI_M2M_IN_FMT_YUV444_1P8P, - MXC_ISI_M2M_IN_FMT_YUV444_1P10, - MXC_ISI_M2M_IN_FMT_YUV444_1P10P, - MXC_ISI_M2M_IN_FMT_YUV444_1P12, - MXC_ISI_M2M_IN_FMT_YUV444_1P8, - MXC_ISI_M2M_IN_FMT_YUV422_1P8P, - MXC_ISI_M2M_IN_FMT_YUV422_1P10, - MXC_ISI_M2M_IN_FMT_YUV422_1P10P, -}; - -enum mxc_isi_power_state { - MXC_ISI_PM_SUSPENDED = 0x01, - MXC_ISI_PM_POWERED = 0x02, - MXC_ISI_RUNTIME_SUSPEND = 0x04, -}; - -struct mxc_isi_fmt { - char *name; - u32 mbus_code; - u32 fourcc; - u32 color; - u16 memplanes; - u16 colplanes; - u8 colorspace; - u8 depth[MXC_MAX_PLANES]; - u16 mdataplanes; - u16 flags; -}; - -struct mxc_isi_ctrls { - struct v4l2_ctrl_handler handler; - struct v4l2_ctrl *hflip; - struct v4l2_ctrl *vflip; - struct v4l2_ctrl *alpha; - bool ready; -}; - -/** - * struct addr - physical address set for DMA - * @y: luminance plane physical address - * @cb: Cb plane physical address - * @cr: Cr plane physical address - */ -struct frame_addr { - u32 y; - u32 cb; - u32 cr; -}; - -/** - * struct mxc_isi_frame - source/target frame properties - * o_width: original image width from sensor - * o_height: original image height from sensor - * c_width: crop image width set by g_selection - * c_height: crop image height set by g_selection - * h_off: crop horizontal pixel offset - * v_off: crop vertical pixel offset - * width: out image pixel width - * height: out image pixel weight - * bytesperline: bytesperline value for each plane - * paddr: image frame buffer physical addresses - * fmt: color format pointer - */ -struct mxc_isi_frame { - u32 o_width; - u32 o_height; - u32 c_width; - u32 c_height; - u32 h_off; - u32 v_off; - u32 width; - u32 height; - unsigned int sizeimage[MXC_MAX_PLANES]; - unsigned int bytesperline[MXC_MAX_PLANES]; - struct mxc_isi_fmt *fmt; -}; - -struct mxc_isi_roi_alpha { - u8 alpha; - struct v4l2_rect rect; -}; - -struct mxc_isi_buffer { - struct vb2_v4l2_buffer v4l2_buf; - struct list_head list; - struct frame_addr paddr; -}; - -struct mxc_isi_m2m_dev { - struct video_device vdev; - struct v4l2_m2m_dev *m2m_dev; - struct v4l2_fh fh; - - struct mxc_isi_frame src_f; - struct mxc_isi_frame dst_f; -}; - -struct mxc_isi_cap_dev { - struct v4l2_subdev sd; - struct video_device vdev; - struct v4l2_fh fh; - struct media_pad cap_pad; - struct media_pad sd_pads[MXC_ISI_SD_PADS_NUM]; - struct vb2_queue vb2_q; - struct list_head out_pending; - struct list_head out_active; - - struct mxc_isi_frame src_f; - struct mxc_isi_frame dst_f; - u32 frame_count; - - u32 buf_index; - -}; - -struct mxc_isi_dev { - spinlock_t slock; - struct mutex lock; - wait_queue_head_t irq_queue; - - int id; - void __iomem *regs; - unsigned long state; - - struct platform_device *pdev; - struct v4l2_device *v4l2_dev; - struct mxc_isi_m2m_dev m2m; - struct mxc_isi_cap_dev isi_cap; - struct clk *clk; - - u32 interface[MAX_PORTS]; - u32 flags; - - /* scale factor */ - u32 xfactor; - u32 yfactor; - u32 pre_dec_x; - u32 pre_dec_y; - - unsigned int hflip:1; - unsigned int vflip:1; - - unsigned int cscen:1; - unsigned int scale:1; - unsigned int alphaen:1; - unsigned int crop:1; - unsigned int deinterlace:1; - - struct mxc_isi_ctrls ctrls; - u8 alpha; /* goable alpha */ - struct mxc_isi_roi_alpha alpha_roi[5]; /* ROI alpha */ -}; - -static inline void set_frame_bounds(struct mxc_isi_frame *f, u32 width, u32 height) -{ - f->o_width = width; - f->o_height = height; - f->c_width = width; - f->c_height = height; - f->width = width; - f->height = height; -} - -static inline void set_frame_out(struct mxc_isi_frame *f, u32 width, u32 height) -{ - f->c_width = width; - f->c_height = height; - f->width = width; - f->height = height; -} - -static inline void set_frame_crop(struct mxc_isi_frame *f, - u32 left, u32 top, u32 width, u32 height) -{ - f->h_off = left; - f->v_off = top; - f->c_width = width; - f->c_height = height; -} - -#endif diff --git a/drivers/media/platform/imx8/mxc-isi-hw.c b/drivers/media/platform/imx8/mxc-isi-hw.c deleted file mode 100644 index 0f06362414051b5114ceed7aa4ea8f14c8427125..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-isi-hw.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include "mxc-isi-hw.h" - -#define ISI_DOWNSCALE_THRESHOLD 0x4000 - -#ifdef debug -static void dump_isi_regs(struct mxc_isi_dev *mxc_isi) -{ - printk("ISI CHNLC register dump, isi%d\n", mxc_isi->id); - printk("CHNL_CTRL 0x0h = 0x%x\n", readl(mxc_isi->regs + 0x0)); - printk("CHNL_IMG_CTRL 0x4h = 0x%x\n", readl(mxc_isi->regs + 0x4)); - printk("CHNL_OUT_BUF_CTRL 0x8h = 0x%x\n", readl(mxc_isi->regs + 0x8)); - printk("CHNL_IMG_CFG 0xCh = 0x%x\n", readl(mxc_isi->regs + 0xC)); - printk("CHNL_IER 0x10h = 0x%x\n", readl(mxc_isi->regs + 0x10)); - printk("CHNL_STS 0x14h = 0x%x\n", readl(mxc_isi->regs + 0x14)); - printk("CHNL_SCALE_FACTOR 0x18h = 0x%x\n", readl(mxc_isi->regs + 0x18)); - printk("CHNL_SCALE_OFFSET 0x1Ch = 0x%x\n", readl(mxc_isi->regs + 0x1C)); - printk("CHNL_CROP_ULC 0x20h = 0x%x\n", readl(mxc_isi->regs + 0x20)); - printk("CHNL_CROP_LRC 0x24h = 0x%x\n", readl(mxc_isi->regs + 0x24)); - printk("CHNL_CSC_COEFF0 0x28h = 0x%x\n", readl(mxc_isi->regs + 0x28)); - printk("CHNL_CSC_COEFF1 0x2Ch = 0x%x\n", readl(mxc_isi->regs + 0x2C)); - printk("CHNL_CSC_COEFF2 0x30h = 0x%x\n", readl(mxc_isi->regs + 0x30)); - printk("CHNL_CSC_COEFF3 0x34h = 0x%x\n", readl(mxc_isi->regs + 0x34)); - printk("CHNL_CSC_COEFF4 0x38h = 0x%x\n", readl(mxc_isi->regs + 0x38)); - printk("CHNL_CSC_COEFF5 0x3Ch = 0x%x\n", readl(mxc_isi->regs + 0x3C)); - printk("CHNL_ROI_0_ALPHA 0x40h = 0x%x\n", readl(mxc_isi->regs + 0x40)); - printk("CHNL_ROI_0_ULC 0x44h = 0x%x\n", readl(mxc_isi->regs + 0x44)); - printk("CHNL_ROI_0_LRC 0x48h = 0x%x\n", readl(mxc_isi->regs + 0x48)); - printk("CHNL_ROI_1_ALPHA 0x4Ch = 0x%x\n", readl(mxc_isi->regs + 0x4C)); - printk("CHNL_ROI_1_ULC 0x50h = 0x%x\n", readl(mxc_isi->regs + 0x50)); - printk("CHNL_ROI_1_LRC 0x54h = 0x%x\n", readl(mxc_isi->regs + 0x54)); - printk("CHNL_ROI_2_ALPHA 0x58h = 0x%x\n", readl(mxc_isi->regs + 0x58)); - printk("CHNL_ROI_2_ULC 0x5Ch = 0x%x\n", readl(mxc_isi->regs + 0x5C)); - printk("CHNL_ROI_2_LRC 0x60h = 0x%x\n", readl(mxc_isi->regs + 0x60)); - printk("CHNL_ROI_3_ALPHA 0x64h = 0x%x\n", readl(mxc_isi->regs + 0x64)); - printk("CHNL_ROI_3_ULC 0x68h = 0x%x\n", readl(mxc_isi->regs + 0x68)); - printk("CHNL_ROI_3_LRC 0x6Ch = 0x%x\n", readl(mxc_isi->regs + 0x6C)); - printk("CHNL_OUT_BUF1_ADDR_Y 0x70h = 0x%x\n", readl(mxc_isi->regs + 0x70)); - printk("CHNL_OUT_BUF1_ADDR_U 0x74h = 0x%x\n", readl(mxc_isi->regs + 0x74)); - printk("CHNL_OUT_BUF1_ADDR_V 0x78h = 0x%x\n", readl(mxc_isi->regs + 0x78)); - printk("CHNL_OUT_BUF_PITCH 0x7Ch = 0x%x\n", readl(mxc_isi->regs + 0x7C)); - printk("CHNL_IN_BUF_ADDR 0x80h = 0x%x\n", readl(mxc_isi->regs + 0x80)); - printk("CHNL_IN_BUF_PITCH 0x84h = 0x%x\n", readl(mxc_isi->regs + 0x84)); - printk("CHNL_MEM_RD_CTRL 0x88h = 0x%x\n", readl(mxc_isi->regs + 0x88)); - printk("CHNL_OUT_BUF2_ADDR_Y 0x8Ch = 0x%x\n", readl(mxc_isi->regs + 0x8C)); - printk("CHNL_OUT_BUF2_ADDR_U 0x90h = 0x%x\n", readl(mxc_isi->regs + 0x90)); - printk("CHNL_OUT_BUF2_ADDR_V 0x94h = 0x%x\n", readl(mxc_isi->regs + 0x94)); -} -#else -static void dump_isi_regs(struct mxc_isi_dev *mxc_isi) -{ -} -#endif - -static const u32 coeffs[2][6] = { - /* A2,A1, B1, A3, B3, B2, C2, C1, D1, C3, D3, D2 */ - /* YUV2RGB */ - { 0x0000012A, 0x012A0198, 0x0730079C, 0x0204012A, 0x01F00000, 0x01800180 }, - /* RGB->YUV */ - { 0x0096004D, 0x05DA001D, 0x007005B6, 0x057C009E, 0x000005E6, 0x00000000 }, -}; - -static void printk_pixelformat(char *prefix, int val) -{ - printk("%s %c%c%c%c\n", prefix ? prefix : "pixelformat", - val & 0xff, (val >> 8) & 0xff, (val >> 16) & 0xff, (val >> 24) & 0xff); -} - -static bool is_rgb(u32 pix_fmt) -{ - if ((pix_fmt == V4L2_PIX_FMT_RGB565) || - (pix_fmt == V4L2_PIX_FMT_RGB24) || - (pix_fmt == V4L2_PIX_FMT_RGB32) || - (pix_fmt == V4L2_PIX_FMT_BGR24) || - (pix_fmt == V4L2_PIX_FMT_ARGB32)) { - return true; - } else { - return false; - } -} - -static bool is_yuv(u32 pix_fmt) -{ - if ((pix_fmt == V4L2_PIX_FMT_YUYV) || - (pix_fmt == V4L2_PIX_FMT_YUV32)) { - return true; - } else { - return false; - } -} - -void mxc_isi_channel_set_outbuf(struct mxc_isi_dev *mxc_isi, struct mxc_isi_buffer *buf) -{ - struct vb2_buffer *vb2_buf = &buf->v4l2_buf.vb2_buf; - struct frame_addr *paddr = &buf->paddr; - u32 framecount = buf->v4l2_buf.sequence; - int val = 0; - - paddr->y = vb2_dma_contig_plane_dma_addr(vb2_buf, 0); - - if (vb2_buf->num_planes == 2) - paddr->cb = vb2_dma_contig_plane_dma_addr(vb2_buf, 1); - if (vb2_buf->num_planes == 3) { - paddr->cb = vb2_dma_contig_plane_dma_addr(vb2_buf, 1); - paddr->cr = vb2_dma_contig_plane_dma_addr(vb2_buf, 2); - } - - val = readl(mxc_isi->regs + CHNL_OUT_BUF_CTRL); - if (framecount % 2 == 1) { - writel(paddr->y, mxc_isi->regs + CHNL_OUT_BUF2_ADDR_Y); - writel(paddr->cb, mxc_isi->regs + CHNL_OUT_BUF2_ADDR_U); - writel(paddr->cr, mxc_isi->regs + CHNL_OUT_BUF2_ADDR_V); - val ^= CHNL_OUT_BUF_CTRL_LOAD_BUF2_ADDR_MASK; - } else { - writel(paddr->y, mxc_isi->regs + CHNL_OUT_BUF1_ADDR_Y); - writel(paddr->cb, mxc_isi->regs + CHNL_OUT_BUF1_ADDR_U); - writel(paddr->cr, mxc_isi->regs + CHNL_OUT_BUF1_ADDR_V); - val ^= CHNL_OUT_BUF_CTRL_LOAD_BUF1_ADDR_MASK; - } - writel(val, mxc_isi->regs + CHNL_OUT_BUF_CTRL); -} - - -void mxc_isi_channel_sw_reset(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - val = readl(mxc_isi->regs + CHNL_CTRL); - val |= CHNL_CTRL_SW_RST; - writel(val, mxc_isi->regs + CHNL_CTRL); - mdelay(5); - val &= ~CHNL_CTRL_SW_RST; - writel(val, mxc_isi->regs + CHNL_CTRL); -} - -void mxc_isi_channel_source_config(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - val = readl(mxc_isi->regs + CHNL_CTRL); - val &= ~(CHNL_CTRL_MIPI_VC_ID_MASK | - CHNL_CTRL_SRC_INPUT_MASK | CHNL_CTRL_SRC_TYPE_MASK); - - switch (mxc_isi->interface[IN_PORT]) { - case ISI_INPUT_INTERFACE_MIPI0_CSI2: - val |= CHNL_CTRL_SRC_INPUT_MIPI0; - if (mxc_isi->interface[SUB_IN_PORT] <= CHNL_CTRL_MIPI_VC_ID_VC3 && - mxc_isi->interface[SUB_IN_PORT] >= CHNL_CTRL_MIPI_VC_ID_VC0) - val |= (mxc_isi->interface[SUB_IN_PORT] << CHNL_CTRL_MIPI_VC_ID_OFFSET); - break; - case ISI_INPUT_INTERFACE_MIPI1_CSI2: - val |= CHNL_CTRL_SRC_INPUT_MIPI1; - if (mxc_isi->interface[SUB_IN_PORT] <= CHNL_CTRL_MIPI_VC_ID_VC3 && - mxc_isi->interface[SUB_IN_PORT] >= CHNL_CTRL_MIPI_VC_ID_VC0) - val |= (mxc_isi->interface[SUB_IN_PORT] << CHNL_CTRL_MIPI_VC_ID_OFFSET); - break; - case ISI_INPUT_INTERFACE_DC0: - val |= CHNL_CTRL_SRC_INPUT_DC0; - break; - case ISI_INPUT_INTERFACE_DC1: - val |= CHNL_CTRL_SRC_INPUT_DC1; - break; - case ISI_INPUT_INTERFACE_HDMI: - val |= CHNL_CTRL_SRC_INPUT_HDMI; - break; - case ISI_INPUT_INTERFACE_MEM: - val |= CHNL_CTRL_SRC_INPUT_MEMORY; - val |= (CHNL_CTRL_SRC_TYPE_MEMORY << CHNL_CTRL_SRC_TYPE_OFFSET); - break; - default: - dev_err(&mxc_isi->pdev->dev, "invalid interface\n"); - break; - } - - writel(val, mxc_isi->regs + CHNL_CTRL); -} - -void mxc_isi_channel_set_flip(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - val = readl(mxc_isi->regs + CHNL_IMG_CTRL); - val &= ~(CHNL_IMG_CTRL_VFLIP_EN_MASK | CHNL_IMG_CTRL_HFLIP_EN_MASK); - - if (mxc_isi->vflip) - val |= (CHNL_IMG_CTRL_VFLIP_EN_ENABLE << CHNL_IMG_CTRL_VFLIP_EN_OFFSET); - if (mxc_isi->hflip) - val |= (CHNL_IMG_CTRL_HFLIP_EN_ENABLE << CHNL_IMG_CTRL_HFLIP_EN_OFFSET); - - writel(val, mxc_isi->regs + CHNL_IMG_CTRL); -} - -void mxc_isi_channel_set_csc(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_fmt *dst_fmt = mxc_isi->isi_cap.dst_f.fmt; - struct mxc_isi_fmt *src_fmt = mxc_isi->isi_cap.src_f.fmt; - u32 val, csc = 0; - - val = readl(mxc_isi->regs + CHNL_IMG_CTRL); - val &= ~(CHNL_IMG_CTRL_FORMAT_MASK | - CHNL_IMG_CTRL_YCBCR_MODE_MASK | - CHNL_IMG_CTRL_CSC_BYPASS_MASK | - CHNL_IMG_CTRL_CSC_MODE_MASK); - - /* set outbuf format */ - val |= dst_fmt->color << CHNL_IMG_CTRL_FORMAT_OFFSET; - - mxc_isi->cscen = 1; - - if (is_yuv(src_fmt->fourcc) && is_rgb(dst_fmt->fourcc)) { - /* YUV2RGB */ - csc = YUV2RGB; - /* YCbCr enable??? */ - val |= (CHNL_IMG_CTRL_CSC_MODE_YCBCR2RGB << CHNL_IMG_CTRL_CSC_MODE_OFFSET); - val |= (CHNL_IMG_CTRL_YCBCR_MODE_ENABLE << CHNL_IMG_CTRL_YCBCR_MODE_OFFSET); - } else if (is_rgb(src_fmt->fourcc) && is_yuv(dst_fmt->fourcc)) { - /* RGB2YUV */ - csc = RGB2YUV; - val |= (CHNL_IMG_CTRL_CSC_MODE_RGB2YUV << CHNL_IMG_CTRL_CSC_MODE_OFFSET); - } else { - /* Bypass CSC */ - printk("bypass csc\n"); - mxc_isi->cscen = 0; - val |= CHNL_IMG_CTRL_CSC_BYPASS_ENABLE; - } - - printk_pixelformat("input fmt", src_fmt->fourcc); - printk_pixelformat("output fmt", dst_fmt->fourcc); - - if (mxc_isi->cscen) { - writel(coeffs[csc][0], mxc_isi->regs + CHNL_CSC_COEFF0); - writel(coeffs[csc][1], mxc_isi->regs + CHNL_CSC_COEFF1); - writel(coeffs[csc][2], mxc_isi->regs + CHNL_CSC_COEFF2); - writel(coeffs[csc][3], mxc_isi->regs + CHNL_CSC_COEFF3); - writel(coeffs[csc][4], mxc_isi->regs + CHNL_CSC_COEFF4); - writel(coeffs[csc][5], mxc_isi->regs + CHNL_CSC_COEFF5); - } - - writel(val, mxc_isi->regs + CHNL_IMG_CTRL); -} -void mxc_isi_channel_set_alpha_roi0(struct mxc_isi_dev *mxc_isi, - struct v4l2_rect *rect) -{ - u32 val0, val1; - val0 = (rect->left << 16) | rect->top; - writel(val0, mxc_isi->regs + CHNL_ROI_0_ULC); - val1 = (rect->width << 16) | rect->height; - writel(val0 + val1, mxc_isi->regs + CHNL_ROI_0_LRC); -} - -void mxc_isi_channel_set_alpha(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - val = readl(mxc_isi->regs + CHNL_IMG_CTRL); - val &= ~(CHNL_IMG_CTRL_GBL_ALPHA_VAL_MASK | CHNL_IMG_CTRL_GBL_ALPHA_EN_MASK); - val |= ((mxc_isi->alpha << CHNL_IMG_CTRL_GBL_ALPHA_VAL_OFFSET) | - (CHNL_IMG_CTRL_GBL_ALPHA_EN_ENABLE << CHNL_IMG_CTRL_GBL_ALPHA_EN_OFFSET)); - - writel(val, mxc_isi->regs + CHNL_IMG_CTRL); -} - -void mxc_isi_channel_set_4k(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_frame *src_f = &mxc_isi->isi_cap.src_f; - u32 val; - - val = readl(mxc_isi->regs + CHNL_CTRL); - val &= ~CHNL_CTRL_CHAIN_BUF_MASK; - if (src_f->width > 2046) - val |= (CHNL_CTRL_CHAIN_BUF_2_CHAIN << CHNL_CTRL_CHAIN_BUF_OFFSET); - - writel(val, mxc_isi->regs + CHNL_CTRL); -} - -void mxc_isi_channel_deinterlace_init(struct mxc_isi_dev *mxc_isi) -{ - /* Config for Blending deinterlace */ -} - -void mxc_isi_channel_set_deinterlace(struct mxc_isi_dev *mxc_isi) -{ - /* de-interlacing method - * Weaving-------------Yes - * Line Doubling-------No - * Blending -----------TODO*/ - u32 val; - - val = readl(mxc_isi->regs + CHNL_IMG_CTRL); - val &= ~CHNL_IMG_CTRL_DEINT_MASK; - if (mxc_isi->deinterlace) - val |= mxc_isi->deinterlace << CHNL_IMG_CTRL_DEINT_OFFSET; - if (mxc_isi->deinterlace == CHNL_IMG_CTRL_DEINT_LDOUBLE_ODD_EVEN || - mxc_isi->deinterlace == CHNL_IMG_CTRL_DEINT_LDOUBLE_EVEN_ODD) - mxc_isi_channel_deinterlace_init(mxc_isi); - - writel(val, mxc_isi->regs + CHNL_IMG_CTRL); -} - -void mxc_isi_channel_set_crop(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_frame *src_f = &mxc_isi->isi_cap.src_f; - struct v4l2_rect crop; - u32 val, val0, val1, temp; - - val = readl(mxc_isi->regs + CHNL_IMG_CTRL); - val &= ~CHNL_IMG_CTRL_CROP_EN_MASK; - - if ((src_f->o_height == src_f->height) && - (src_f->o_width == src_f->width)) { - mxc_isi->crop = 0; - writel(val, mxc_isi->regs + CHNL_IMG_CTRL); - return; - } - - if (mxc_isi->scale) { - temp = (src_f->h_off << 12) / mxc_isi->xfactor; - crop.left = temp >> mxc_isi->pre_dec_x; - temp = (src_f->v_off << 12) / mxc_isi->yfactor; - crop.top = temp >> mxc_isi->pre_dec_y; - temp = (src_f->width << 12) / mxc_isi->xfactor; - crop.width = temp >> mxc_isi->pre_dec_x; - temp = (src_f->height << 12) / mxc_isi->yfactor; - crop.height = temp >> mxc_isi->pre_dec_y; - } else { - crop.left = src_f->h_off; - crop.top = src_f->v_off; - crop.width = src_f->width; - crop.height = src_f->height; - } - - mxc_isi->crop = 1; - val |= (CHNL_IMG_CTRL_CROP_EN_ENABLE << CHNL_IMG_CTRL_CROP_EN_OFFSET); - val0 = crop.top | (crop.left << CHNL_CROP_ULC_X_OFFSET); - val1 = crop.height | (crop.width << CHNL_CROP_LRC_X_OFFSET); - - writel(val0, mxc_isi->regs + CHNL_CROP_ULC); - writel((val1 + val0), mxc_isi->regs + CHNL_CROP_LRC); - writel(val, mxc_isi->regs + CHNL_IMG_CTRL); -} - -void mxc_isi_channel_set_scaling(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_frame *dst_f = &mxc_isi->isi_cap.dst_f; - struct mxc_isi_frame *src_f = &mxc_isi->isi_cap.src_f; - u32 decx, decy; - u32 xscale, yscale; - u32 xdec = 0, ydec = 0; - u32 val0, val1; - - if (dst_f->height == src_f->height || - dst_f->width == src_f->width) { - mxc_isi->scale = 0; - return; - } - - dev_info(&mxc_isi->pdev->dev, "input_size(%d,%d), output_size(%d,%d)\n", - src_f->height, src_f->width, dst_f->height, dst_f->width); - - mxc_isi->scale = 1; - - decx = src_f->width / dst_f->width; - decy = src_f->height / dst_f->height; - - if (decx > 1) { - /* Down */ - if (decx >= 2 && decx < 4) { - decx = 2; - xdec = 1; - } else if (decx >= 4 && decx < 8) { - decx = 4; - xdec = 2; - } else if (decx >= 8) { - decx = 8; - xdec = 3; - } - xscale = src_f->width * 0x1000 / (dst_f->width * decx); - } else - /* Up */ - xscale = src_f->width * 0x1000 / dst_f->width; - - if (decy > 1) { - if (decy >= 2 && decy < 4) { - decy = 2; - ydec = 1; - } else if (decy >= 4 && decy < 8) { - decy = 4; - ydec = 2; - } else if (decy >= 8) { - decy = 8; - ydec = 3; - } - yscale = src_f->height * 0x1000 / (dst_f->height * decy); - } else - yscale = src_f->height * 0x1000 / dst_f->height; - - val0 = readl(mxc_isi->regs + CHNL_IMG_CTRL); - val0 |= CHNL_IMG_CTRL_YCBCR_MODE_MASK;//YCbCr Sandor??? - val0 &= ~(CHNL_IMG_CTRL_DEC_X_MASK | CHNL_IMG_CTRL_DEC_Y_MASK); - val0 |= (xdec << CHNL_IMG_CTRL_DEC_X_OFFSET) | - (ydec << CHNL_IMG_CTRL_DEC_Y_OFFSET); - writel(val0, mxc_isi->regs + CHNL_IMG_CTRL); - - if (xscale > ISI_DOWNSCALE_THRESHOLD) - xscale = ISI_DOWNSCALE_THRESHOLD; - if (yscale > ISI_DOWNSCALE_THRESHOLD) - yscale = ISI_DOWNSCALE_THRESHOLD; - - val1 = xscale | (yscale << CHNL_SCALE_FACTOR_Y_SCALE_OFFSET); - - writel(val1, mxc_isi->regs + CHNL_SCALE_FACTOR); - writel(0, mxc_isi->regs + CHNL_SCALE_OFFSET); - - return; -} - -void mxc_isi_channel_init(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - /* Init channel clk first */ - val = readl(mxc_isi->regs + CHNL_CTRL); - val |= (CHNL_CTRL_CLK_EN_ENABLE << CHNL_CTRL_CLK_EN_OFFSET); - writel(val, mxc_isi->regs + CHNL_CTRL); - - /* sw reset */ - mxc_isi_channel_sw_reset(mxc_isi); -} - -void mxc_isi_channel_deinit(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - /* sw reset */ - mxc_isi_channel_sw_reset(mxc_isi); - - /* deinit channel clk first */ - val = (CHNL_CTRL_CLK_EN_ENABLE << CHNL_CTRL_CLK_EN_OFFSET); - writel(val, mxc_isi->regs + CHNL_CTRL); -} - -void mxc_isi_channel_config(struct mxc_isi_dev *mxc_isi) -{ - struct mxc_isi_frame *dst_f = &mxc_isi->isi_cap.dst_f; - struct mxc_isi_frame *src_f = &mxc_isi->isi_cap.src_f; - u32 val; - - /* config output frame size and format */ - val = src_f->o_width | (src_f->o_height << CHNL_IMG_CFG_HEIGHT_OFFSET); - writel(val, mxc_isi->regs + CHNL_IMG_CFG); - - /* check csc and scaling */ - mxc_isi_channel_set_csc(mxc_isi); - - mxc_isi_channel_set_scaling(mxc_isi); - - /* select the source input / src type / virtual channel for mipi*/ - mxc_isi_channel_source_config(mxc_isi); - - /* line pitch */ - val = dst_f->bytesperline[0]; - writel(val, mxc_isi->regs + CHNL_OUT_BUF_PITCH); - - /* TODO */ -#if 0 - mxc_isi_channel_set_crop(mxc_isi); - - mxc_isi_channel_set_flip(mxc_isi); - if (mxc_isi->alphaen) - mxc_isi_channel_set_alpha(mxc_isi); - - mxc_isi_channel_set_4k(mxc_isi); -#endif - - val = readl(mxc_isi->regs + CHNL_CTRL); - val &= ~CHNL_CTRL_CHNL_BYPASS_MASK; - - /* Bypass channel */ - if (!mxc_isi->cscen && !mxc_isi->scale) - val |= (CHNL_CTRL_CHNL_BYPASS_ENABLE << CHNL_CTRL_CHNL_BYPASS_OFFSET); - - writel(val, mxc_isi->regs + CHNL_CTRL); -} - -void mxc_isi_channel_enable(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - val = readl(mxc_isi->regs + CHNL_CTRL); - val |= (CHNL_CTRL_CHNL_EN_ENABLE << CHNL_CTRL_CHNL_EN_OFFSET); - val |= 0xff << CHNL_CTRL_BLANK_PXL_OFFSET; - writel(val, mxc_isi->regs + CHNL_CTRL); - - mxc_isi_enable_irq(mxc_isi); - dump_isi_regs(mxc_isi); -} - -void mxc_isi_channel_disable(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - mxc_isi_disable_irq(mxc_isi); - - val = readl(mxc_isi->regs + CHNL_CTRL); - val &= ~(CHNL_CTRL_CHNL_EN_MASK | CHNL_CTRL_CLK_EN_MASK); - val |= (CHNL_CTRL_CHNL_EN_DISABLE << CHNL_CTRL_CHNL_EN_OFFSET); - val |= (CHNL_CTRL_CLK_EN_DISABLE << CHNL_CTRL_CLK_EN_OFFSET); - writel(val, mxc_isi->regs + CHNL_CTRL); -} - -void mxc_isi_enable_irq(struct mxc_isi_dev *mxc_isi) -{ - u32 val; - - val = CHNL_IER_FRM_RCVD_EN_MASK | - CHNL_IER_OFLW_Y_BUF_EN_MASK | - CHNL_IER_AXI_WR_ERR_U_EN_MASK | - CHNL_IER_AXI_WR_ERR_V_EN_MASK | - CHNL_IER_AXI_WR_ERR_Y_EN_MASK | - CHNL_IER_OFLW_PANIC_V_BUF_EN_MASK | - CHNL_IER_EXCS_OFLW_V_BUF_EN_MASK | - CHNL_IER_OFLW_V_BUF_EN_MASK | - CHNL_IER_OFLW_PANIC_U_BUF_EN_MASK | - CHNL_IER_EXCS_OFLW_U_BUF_EN_MASK | - CHNL_IER_OFLW_U_BUF_EN_MASK | - CHNL_IER_OFLW_PANIC_Y_BUF_EN_MASK | - CHNL_IER_EXCS_OFLW_Y_BUF_EN_MASK | - CHNL_IER_OFLW_Y_BUF_EN_MASK; - - writel(val, mxc_isi->regs + CHNL_IER); -} - -void mxc_isi_disable_irq(struct mxc_isi_dev *mxc_isi) -{ - writel(0, mxc_isi->regs + CHNL_CTRL); -} - -u32 mxc_isi_get_irq_status(struct mxc_isi_dev *mxc_isi) -{ - return readl(mxc_isi->regs + CHNL_STS); -} - -void mxc_isi_clean_irq_status(struct mxc_isi_dev *mxc_isi, u32 val) -{ - writel(val, mxc_isi->regs + CHNL_STS); -} diff --git a/drivers/media/platform/imx8/mxc-isi-hw.h b/drivers/media/platform/imx8/mxc-isi-hw.h deleted file mode 100644 index ea363caa15f629a8b64e20f34cdae83580dcb511..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-isi-hw.h +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#ifndef MXC_ISI_HW_H_ -#define MXC_ISI_HW_H_ - -#include -#include -#include -#include -#include -#include - -#include "mxc-isi-core.h" - -/* ISI Registers Define */ -/* Channel Control Register */ -#define CHNL_CTRL 0x0 -#define CHNL_CTRL_CHNL_EN_OFFSET 31 -#define CHNL_CTRL_CHNL_EN_MASK 0x80000000 -#define CHNL_CTRL_CHNL_EN_DISABLE 0 -#define CHNL_CTRL_CHNL_EN_ENABLE 1 -#define CHNL_CTRL_CLK_EN_OFFSET 30 -#define CHNL_CTRL_CLK_EN_MASK 0x40000000 -#define CHNL_CTRL_CLK_EN_DISABLE 0 -#define CHNL_CTRL_CLK_EN_ENABLE 1 -#define CHNL_CTRL_CHNL_BYPASS_OFFSET 29 -#define CHNL_CTRL_CHNL_BYPASS_MASK 0x20000000 -#define CHNL_CTRL_CHNL_BYPASS_ENABLE 1 -#define CHNL_CTRL_CHAIN_BUF_OFFSET 25 -#define CHNL_CTRL_CHAIN_BUF_MASK 0x60000 -#define CHNL_CTRL_CHAIN_BUF_NO_CHAIN 0 -#define CHNL_CTRL_CHAIN_BUF_2_CHAIN 1 -#define CHNL_CTRL_SW_RST_OFFSET 24 -#define CHNL_CTRL_SW_RST_MASK 0x100000 -#define CHNL_CTRL_SW_RST 0x100000 -#define CHNL_CTRL_BLANK_PXL_OFFSET 16 -#define CHNL_CTRL_MIPI_VC_ID_OFFSET 6 -#define CHNL_CTRL_MIPI_VC_ID_MASK 0xc0 -#define CHNL_CTRL_MIPI_VC_ID_VC0 0 -#define CHNL_CTRL_MIPI_VC_ID_VC1 1 -#define CHNL_CTRL_MIPI_VC_ID_VC2 2 -#define CHNL_CTRL_MIPI_VC_ID_VC3 3 -#define CHNL_CTRL_SRC_TYPE_OFFSET 4 -#define CHNL_CTRL_SRC_TYPE_MASK 0x10 -#define CHNL_CTRL_SRC_TYPE_DEVICE 0 -#define CHNL_CTRL_SRC_TYPE_MEMORY 1 -#define CHNL_CTRL_SRC_INPUT_OFFSET 0 -#define CHNL_CTRL_SRC_INPUT_MASK 0x7 -#define CHNL_CTRL_SRC_INPUT_DC0 0 -#define CHNL_CTRL_SRC_INPUT_DC1 1 -#define CHNL_CTRL_SRC_INPUT_MIPI0 2 -#define CHNL_CTRL_SRC_INPUT_MIPI1 3 -#define CHNL_CTRL_SRC_INPUT_HDMI 4 -#define CHNL_CTRL_SRC_INPUT_MEMORY 5 - -/* Channel Image Control Register */ -#define CHNL_IMG_CTRL 0x4 -#define CHNL_IMG_CTRL_FORMAT_OFFSET 24 -#define CHNL_IMG_CTRL_FORMAT_MASK 0x3F000000 -#define CHNL_IMG_CTRL_GBL_ALPHA_VAL_OFFSET 16 -#define CHNL_IMG_CTRL_GBL_ALPHA_VAL_MASK 0xFF0000 -#define CHNL_IMG_CTRL_GBL_ALPHA_EN_OFFSET 15 -#define CHNL_IMG_CTRL_GBL_ALPHA_EN_ENABLE 1 -#define CHNL_IMG_CTRL_GBL_ALPHA_EN_MASK 0x8000 -#define CHNL_IMG_CTRL_DEINT_OFFSET 12 -#define CHNL_IMG_CTRL_DEINT_MASK 0x7000 -#define CHNL_IMG_CTRL_DEINT_WEAVE_ODD_EVEN 2 -#define CHNL_IMG_CTRL_DEINT_WEAVE_EVEN_ODD 3 -#define CHNL_IMG_CTRL_DEINT_BLEND_ODD_EVEN 4 -#define CHNL_IMG_CTRL_DEINT_BLEND_EVEN_ODD 5 -#define CHNL_IMG_CTRL_DEINT_LDOUBLE_ODD_EVEN 6 -#define CHNL_IMG_CTRL_DEINT_LDOUBLE_EVEN_ODD 7 -#define CHNL_IMG_CTRL_DEC_X_OFFSET 10 -#define CHNL_IMG_CTRL_DEC_X_MASK 0xC00 -#define CHNL_IMG_CTRL_DEC_X_0 0 -#define CHNL_IMG_CTRL_DEC_X_2 1 -#define CHNL_IMG_CTRL_DEC_X_4 2 -#define CHNL_IMG_CTRL_DEC_X_8 3 -#define CHNL_IMG_CTRL_DEC_Y_OFFSET 8 -#define CHNL_IMG_CTRL_DEC_Y_MASK 0x300 -#define CHNL_IMG_CTRL_DEC_Y_0 0 -#define CHNL_IMG_CTRL_DEC_Y_2 1 -#define CHNL_IMG_CTRL_DEC_Y_4 2 -#define CHNL_IMG_CTRL_DEC_Y_8 3 -#define CHNL_IMG_CTRL_CROP_EN_OFFSET 7 -#define CHNL_IMG_CTRL_CROP_EN_MASK 0x80 -#define CHNL_IMG_CTRL_CROP_EN_ENABLE 1 -#define CHNL_IMG_CTRL_VFLIP_EN_OFFSET 6 -#define CHNL_IMG_CTRL_VFLIP_EN_MASK 0x40 -#define CHNL_IMG_CTRL_VFLIP_EN_ENABLE 1 -#define CHNL_IMG_CTRL_HFLIP_EN_OFFSET 5 -#define CHNL_IMG_CTRL_HFLIP_EN_MASK 0x20 -#define CHNL_IMG_CTRL_HFLIP_EN_ENABLE 1 -#define CHNL_IMG_CTRL_YCBCR_MODE_OFFSET 3 -#define CHNL_IMG_CTRL_YCBCR_MODE_MASK 0x8 -#define CHNL_IMG_CTRL_YCBCR_MODE_ENABLE 1 -#define CHNL_IMG_CTRL_CSC_MODE_OFFSET 1 -#define CHNL_IMG_CTRL_CSC_MODE_MASK 0x6 -#define CHNL_IMG_CTRL_CSC_MODE_YUV2RGB 0 -#define CHNL_IMG_CTRL_CSC_MODE_YCBCR2RGB 1 -#define CHNL_IMG_CTRL_CSC_MODE_RGB2YUV 2 -#define CHNL_IMG_CTRL_CSC_MODE_RGB2YCBCR 3 -#define CHNL_IMG_CTRL_CSC_BYPASS_OFFSET 0 -#define CHNL_IMG_CTRL_CSC_BYPASS_MASK 0x1 -#define CHNL_IMG_CTRL_CSC_BYPASS_ENABLE 0x1 - -/* Channel Output Buffer Control Register */ -#define CHNL_OUT_BUF_CTRL 0x8 -#define CHNL_OUT_BUF_CTRL_LOAD_BUF2_ADDR_OFFSET 15 -#define CHNL_OUT_BUF_CTRL_LOAD_BUF2_ADDR_MASK 0x8000 -#define CHNL_OUT_BUF_CTRL_LOAD_BUF1_ADDR_OFFSET 14 -#define CHNL_OUT_BUF_CTRL_LOAD_BUF1_ADDR_MASK 0x4000 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_V_OFFSET 6 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_V_MASK 0xC0 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_V_NO_PANIC 0 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_V_PANIC_25 1 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_V_PANIC_50 2 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_V_PANIC_75 3 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_U_OFFSET 3 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_U_MASK 0x18 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_U_NO_PANIC 0 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_U_PANIC_25 1 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_U_PANIC_50 2 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_U_PANIC_75 3 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_Y_OFFSET 0 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_Y_MASK 0x3 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_Y_NO_PANIC 0 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_Y_PANIC_25 1 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_Y_PANIC_50 2 -#define CHNL_OUT_BUF_CTRL_OFLW_PANIC_SET_THD_Y_PANIC_75 3 - -/* Channel Image Configuration */ -#define CHNL_IMG_CFG 0xC -#define CHNL_IMG_CFG_HEIGHT_OFFSET 16 -#define CHNL_IMG_CFG_HEIGHT_MASK 0x1FFF0000 -#define CHNL_IMG_CFG_WIDTH_OFFSET 0 -#define CHNL_IMG_CFG_WIDTH_MASK 0x1FFF - -/* Channel Interrupt Enable Register */ -#define CHNL_IER 0x10 -#define CHNL_IER_MEM_RD_DONE_EN_OFFSET 31 -#define CHNL_IER_MEM_RD_DONE_EN_MASK 0x80000000 -#define CHNL_IER_MEM_RD_DONE_EN_ENABLE 1 -#define CHNL_IER_LINE_RCVD_EN_OFFSET 30 -#define CHNL_IER_LINE_RCVD_EN_MASK 0x40000000 -#define CHNL_IER_LINE_RCVD_EN_ENABLE 1 -#define CHNL_IER_FRM_RCVD_EN_OFFSET 29 -#define CHNL_IER_FRM_RCVD_EN_MASK 0x20000000 -#define CHNL_IER_FRM_RCVD_EN_ENABLE 1 -#define CHNL_IER_AXI_WR_ERR_V_EN_OFFSET 28 -#define CHNL_IER_AXI_WR_ERR_V_EN_MASK 0x10000000 -#define CHNL_IER_AXI_WR_ERR_V_EN_ENABLE 1 -#define CHNL_IER_AXI_WR_ERR_U_EN_OFFSET 27 -#define CHNL_IER_AXI_WR_ERR_U_EN_MASK 0x8000000 -#define CHNL_IER_AXI_WR_ERR_U_EN_ENABLE 1 -#define CHNL_IER_AXI_WR_ERR_Y_EN_OFFSET 26 -#define CHNL_IER_AXI_WR_ERR_Y_EN_MASK 0x4000000 -#define CHNL_IER_AXI_WR_ERR_Y_EN_ENABLE 1 -#define CHNL_IER_AXI_RD_ERR_EN_OFFSET 25 -#define CHNL_IER_AXI_RD_ERR_EN_MASK 0x2000000 -#define CHNL_IER_AXI_RD_ERR_EN_ENABLE 1 -#define CHNL_IER_OFLW_PANIC_V_BUF_EN_OFFSET 24 -#define CHNL_IER_OFLW_PANIC_V_BUF_EN_MASK 0x1000000 -#define CHNL_IER_OFLW_PANIC_V_BUF_EN_ENABLE 1 -#define CHNL_IER_EXCS_OFLW_V_BUF_EN_OFFSET 23 -#define CHNL_IER_EXCS_OFLW_V_BUF_EN_MASK 0x800000 -#define CHNL_IER_EXCS_OFLW_V_BUF_EN_ENABLE 1 -#define CHNL_IER_OFLW_V_BUF_EN_OFFSET 22 -#define CHNL_IER_OFLW_V_BUF_EN_MASK 0x400000 -#define CHNL_IER_OFLW_V_BUF_EN_ENABLE 1 -#define CHNL_IER_OFLW_PANIC_U_BUF_EN_OFFSET 21 -#define CHNL_IER_OFLW_PANIC_U_BUF_EN_MASK 0x200000 -#define CHNL_IER_OFLW_PANIC_U_BUF_EN_ENABLE 1 -#define CHNL_IER_EXCS_OFLW_U_BUF_EN_OFFSET 20 -#define CHNL_IER_EXCS_OFLW_U_BUF_EN_MASK 0x100000 -#define CHNL_IER_EXCS_OFLW_U_BUF_EN_ENABLE 1 -#define CHNL_IER_OFLW_U_BUF_EN_OFFSET 19 -#define CHNL_IER_OFLW_U_BUF_EN_MASK 0x80000 -#define CHNL_IER_OFLW_U_BUF_EN_ENABLE 1 -#define CHNL_IER_OFLW_PANIC_Y_BUF_EN_OFFSET 18 -#define CHNL_IER_OFLW_PANIC_Y_BUF_EN_MASK 0x40000 -#define CHNL_IER_OFLW_PANIC_Y_BUF_EN_ENABLE 1 -#define CHNL_IER_EXCS_OFLW_Y_BUF_EN_OFFSET 17 -#define CHNL_IER_EXCS_OFLW_Y_BUF_EN_MASK 0x20000 -#define CHNL_IER_EXCS_OFLW_Y_BUF_EN_ENABLE 1 -#define CHNL_IER_OFLW_Y_BUF_EN_OFFSET 16 -#define CHNL_IER_OFLW_Y_BUF_EN_MASK 0x10000 -#define CHNL_IER_OFLW_Y_BUF_EN_ENABLE 1 - -/* Channel Status Register */ -#define CHNL_STS 0x14 -#define CHNL_STS_MEM_RD_DONE_OFFSET 31 -#define CHNL_STS_MEM_RD_DONE_MASK 0x80000000 -#define CHNL_STS_MEM_RD_DONE_ENABLE 1 -#define CHNL_STS_LINE_STRD_OFFSET 30 -#define CHNL_STS_LINE_STRD_MASK 0x40000000 -#define CHNL_STS_LINE_STRD_ENABLE 1 -#define CHNL_STS_FRM_STRD_OFFSET 29 -#define CHNL_STS_FRM_STRD_MASK 0x20000000 -#define CHNL_STS_FRM_STRD_ENABLE 1 -#define CHNL_STS_AXI_WR_ERR_V_OFFSET 28 -#define CHNL_STS_AXI_WR_ERR_V_MASK 0x10000000 -#define CHNL_STS_AXI_WR_ERR_V_ENABLE 1 -#define CHNL_STS_AXI_WR_ERR_U_OFFSET 27 -#define CHNL_STS_AXI_WR_ERR_U_MASK 0x8000000 -#define CHNL_STS_AXI_WR_ERR_U_ENABLE 1 -#define CHNL_STS_AXI_WR_ERR_Y_OFFSET 26 -#define CHNL_STS_AXI_WR_ERR_Y_MASK 0x4000000 -#define CHNL_STS_AXI_WR_ERR_Y_ENABLE 1 -#define CHNL_STS_AXI_RD_ERR_OFFSET 25 -#define CHNL_STS_AXI_RD_ERR_MASK 0x2000000 -#define CHNL_STS_AXI_RD_ERR_ENABLE 1 -#define CHNL_STS_OFLW_PANIC_V_BUF_OFFSET 24 -#define CHNL_STS_OFLW_PANIC_V_BUF_MASK 0x1000000 -#define CHNL_STS_OFLW_PANIC_V_BUF_ENABLE 1 -#define CHNL_STS_EXCS_OFLW_V_BUF_OFFSET 23 -#define CHNL_STS_EXCS_OFLW_V_BUF_MASK 0x800000 -#define CHNL_STS_EXCS_OFLW_V_BUF_ENABLE 1 -#define CHNL_STS_OFLW_V_BUF_OFFSET 22 -#define CHNL_STS_OFLW_V_BUF_MASK 0x400000 -#define CHNL_STS_OFLW_V_BUF_ENABLE 1 -#define CHNL_STS_OFLW_PANIC_U_BUF_OFFSET 21 -#define CHNL_STS_OFLW_PANIC_U_BUF_MASK 0x200000 -#define CHNL_STS_OFLW_PANIC_U_BUF_ENABLE 1 -#define CHNL_STS_EXCS_OFLW_U_BUF_OFFSET 20 -#define CHNL_STS_EXCS_OFLW_U_BUF_MASK 0x100000 -#define CHNL_STS_EXCS_OFLW_U_BUF_ENABLE 1 -#define CHNL_STS_OFLW_U_BUF_OFFSET 19 -#define CHNL_STS_OFLW_U_BUF_MASK 0x80000 -#define CHNL_STS_OFLW_U_BUF_ENABLE 1 -#define CHNL_STS_OFLW_PANIC_Y_BUF_OFFSET 18 -#define CHNL_STS_OFLW_PANIC_Y_BUF_MASK 0x40000 -#define CHNL_STS_OFLW_PANIC_Y_BUF_ENABLE 1 -#define CHNL_STS_EXCS_OFLW_Y_BUF_OFFSET 17 -#define CHNL_STS_EXCS_OFLW_Y_BUF_MASK 0x20000 -#define CHNL_STS_EXCS_OFLW_Y_BUF_ENABLE 1 -#define CHNL_STS_OFLW_Y_BUF_OFFSET 16 -#define CHNL_STS_OFLW_Y_BUF_MASK 0x10000 -#define CHNL_STS_OFLW_Y_BUF_ENABLE 1 -#define CHNL_STS_OFLW_BYTES_OFFSET 0 -#define CHNL_STS_OFLW_BYTES_MASK 0xFF - -/* Channel Scale Factor Register */ -#define CHNL_SCALE_FACTOR 0x18 -#define CHNL_SCALE_FACTOR_Y_SCALE_OFFSET 16 -#define CHNL_SCALE_FACTOR_Y_SCALE_MASK 0x3FFF0000 -#define CHNL_SCALE_FACTOR_X_SCALE_OFFSET 0 -#define CHNL_SCALE_FACTOR_X_SCALE_MASK 0x3FFF - -/* Channel Scale Offset Register */ -#define CHNL_SCALE_OFFSET 0x1C -#define CHNL_SCALE_OFFSET_Y_SCALE_OFFSET 16 -#define CHNL_SCALE_OFFSET_Y_SCALE_MASK 0xFFF0000 -#define CHNL_SCALE_OFFSET_X_SCALE_OFFSET 0 -#define CHNL_SCALE_OFFSET_X_SCALE_MASK 0xFFF - -/* Channel Crop Upper Left Corner Coordinate Register */ -#define CHNL_CROP_ULC 0x20 -#define CHNL_CROP_ULC_X_OFFSET 16 -#define CHNL_CROP_ULC_X_MASK 0xFFF0000 -#define CHNL_CROP_ULC_Y_OFFSET 0 -#define CHNL_CROP_ULC_Y_MASK 0xFFF - -/* Channel Crop Lower Right Corner Coordinate Register */ -#define CHNL_CROP_LRC 0x24 -#define CHNL_CROP_LRC_X_OFFSET 16 -#define CHNL_CROP_LRC_X_MASK 0xFFF0000 -#define CHNL_CROP_LRC_Y_OFFSET 0 -#define CHNL_CROP_LRC_Y_MASK 0xFFF - -/* Channel Color Space Conversion Coefficient Register 0 */ -#define CHNL_CSC_COEFF0 0x28 -#define CHNL_CSC_COEFF0_A2_OFFSET 16 -#define CHNL_CSC_COEFF0_A2_MASK 0x7FF0000 -#define CHNL_CSC_COEFF0_A1_OFFSET 0 -#define CHNL_CSC_COEFF0_A1_MASK 0x7FF - - -/* Channel Color Space Conversion Coefficient Register 1 */ -#define CHNL_CSC_COEFF1 0x2C -#define CHNL_CSC_COEFF1_B1_OFFSET 16 -#define CHNL_CSC_COEFF1_B1_MASK 0x7FF0000 -#define CHNL_CSC_COEFF1_A3_OFFSET 0 -#define CHNL_CSC_COEFF1_A3_MASK 0x7FF - -/* Channel Color Space Conversion Coefficient Register 2 */ -#define CHNL_CSC_COEFF2 0x30 -#define CHNL_CSC_COEFF2_B3_OFFSET 16 -#define CHNL_CSC_COEFF2_B3_MASK 0x7FF0000 -#define CHNL_CSC_COEFF2_B2_OFFSET 0 -#define CHNL_CSC_COEFF2_B2_MASK 0x7FF - -/* Channel Color Space Conversion Coefficient Register 3 */ -#define CHNL_CSC_COEFF3 0x34 -#define CHNL_CSC_COEFF3_C2_OFFSET 16 -#define CHNL_CSC_COEFF3_C2_MASK 0x7FF0000 -#define CHNL_CSC_COEFF3_C1_OFFSET 0 -#define CHNL_CSC_COEFF3_C1_MASK 0x7FF - -/* Channel Color Space Conversion Coefficient Register 4 */ -#define CHNL_CSC_COEFF4 0x38 -#define CHNL_CSC_COEFF4_D1_OFFSET 16 -#define CHNL_CSC_COEFF4_D1_MASK 0x1FF0000 -#define CHNL_CSC_COEFF4_C3_OFFSET 0 -#define CHNL_CSC_COEFF4_C3_MASK 0x7FF - -/* Channel Color Space Conversion Coefficient Register 5 */ -#define CHNL_CSC_COEFF5 0x3C -#define CHNL_CSC_COEFF5_D3_OFFSET 16 -#define CHNL_CSC_COEFF5_D3_MASK 0x1FF0000 -#define CHNL_CSC_COEFF5_D2_OFFSET 0 -#define CHNL_CSC_COEFF5_D2_MASK 0x1FF - -/* Channel Alpha Value Register for ROI 0 */ -#define CHNL_ROI_0_ALPHA 0x40 -#define CHNL_ROI_0_ALPHA_OFFSET 24 -#define CHNL_ROI_0_ALPHA_MASK 0xFF000000 -#define CHNL_ROI_0_ALPHA_EN_OFFSET 16 -#define CHNL_ROI_0_ALPHA_EN_MASK 0x10000 - -/* Channel Upper Left Coordinate Register for ROI 0 */ -#define CHNL_ROI_0_ULC 0x44 -#define CHNL_ROI_0_ULC_X_OFFSET 16 -#define CHNL_ROI_0_ULC_X_MASK 0xFFF0000 -#define CHNL_ROI_0_ULC_Y_OFFSET 0 -#define CHNL_ROI_0_ULC_Y_MASK 0xFFF - -/* Channel Lower Right Coordinate Register for ROI 0 */ -#define CHNL_ROI_0_LRC 0x48 -#define CHNL_ROI_0_LRC_X_OFFSET 16 -#define CHNL_ROI_0_LRC_X_MASK 0xFFF0000 -#define CHNL_ROI_0_LRC_Y_OFFSET 0 -#define CHNL_ROI_0_LRC_Y_MASK 0xFFF - -/* Channel Alpha Value Register for ROI 1 */ -#define CHNL_ROI_1_ALPHA 0x4C -#define CHNL_ROI_1_ALPHA_OFFSET 24 -#define CHNL_ROI_1_ALPHA_MASK 0xFF000000 -#define CHNL_ROI_1_ALPHA_EN_OFFSET 16 -#define CHNL_ROI_1_ALPHA_EN_MASK 0x10000 - -/* Channel Upper Left Coordinate Register for ROI 1 */ -#define CHNL_ROI_1_ULC 0x50 -#define CHNL_ROI_1_ULC_X_OFFSET 16 -#define CHNL_ROI_1_ULC_X_MASK 0xFFF0000 -#define CHNL_ROI_1_ULC_Y_OFFSET 0 -#define CHNL_ROI_1_ULC_Y_MASK 0xFFF - -/* Channel Lower Right Coordinate Register for ROI 1 */ -#define CHNL_ROI_1_LRC 0x54 -#define CHNL_ROI_1_LRC_X_OFFSET 16 -#define CHNL_ROI_1_LRC_X_MASK 0xFFF0000 -#define CHNL_ROI_1_LRC_Y_OFFSET 0 -#define CHNL_ROI_1_LRC_Y_MASK 0xFFF - -/* Channel Alpha Value Register for ROI 2 */ -#define CHNL_ROI_2_ALPHA 0x58 -#define CHNL_ROI_2_ALPHA_OFFSET 24 -#define CHNL_ROI_2_ALPHA_MASK 0xFF000000 -#define CHNL_ROI_2_ALPHA_EN_OFFSET 16 -#define CHNL_ROI_2_ALPHA_EN_MASK 0x10000 - -/* Channel Upper Left Coordinate Register for ROI 2 */ -#define CHNL_ROI_2_ULC 0x5C -#define CHNL_ROI_2_ULC_X_OFFSET 16 -#define CHNL_ROI_2_ULC_X_MASK 0xFFF0000 -#define CHNL_ROI_2_ULC_Y_OFFSET 0 -#define CHNL_ROI_2_ULC_Y_MASK 0xFFF - -/* Channel Lower Right Coordinate Register for ROI 2 */ -#define CHNL_ROI_2_LRC 0x60 -#define CHNL_ROI_2_LRC_X_OFFSET 16 -#define CHNL_ROI_2_LRC_X_MASK 0xFFF0000 -#define CHNL_ROI_2_LRC_Y_OFFSET 0 -#define CHNL_ROI_2_LRC_Y_MASK 0xFFF - -/* Channel Alpha Value Register for ROI 3 */ -#define CHNL_ROI_3_ALPHA 0x64 -#define CHNL_ROI_3_ALPHA_OFFSET 24 -#define CHNL_ROI_3_ALPHA_MASK 0xFF000000 -#define CHNL_ROI_3_ALPHA_EN_OFFSET 16 -#define CHNL_ROI_3_ALPHA_EN_MASK 0x10000 - -/* Channel Upper Left Coordinate Register for ROI 3 */ -#define CHNL_ROI_3_ULC 0x68 -#define CHNL_ROI_3_ULC_X_OFFSET 16 -#define CHNL_ROI_3_ULC_X_MASK 0xFFF0000 -#define CHNL_ROI_3_ULC_Y_OFFSET 0 -#define CHNL_ROI_3_ULC_Y_MASK 0xFFF - -/* Channel Lower Right Coordinate Register for ROI 3 */ -#define CHNL_ROI_3_LRC 0x6C -#define CHNL_ROI_3_LRC_X_OFFSET 16 -#define CHNL_ROI_3_LRC_X_MASK 0xFFF0000 -#define CHNL_ROI_3_LRC_Y_OFFSET 0 -#define CHNL_ROI_3_LRC_Y_MASK 0xFFF - -/* Channel RGB or Luma (Y) Output Buffer 1 Address */ -#define CHNL_OUT_BUF1_ADDR_Y 0x70 - -/* Channel Chroma (U/Cb/UV/CbCr) Output Buffer 1 Address */ -#define CHNL_OUT_BUF1_ADDR_U 0x74 - -/* Channel Chroma (V/Cr) Output Buffer 1 Address */ -#define CHNL_OUT_BUF1_ADDR_V 0x78 - -/* Channel Output Buffer Pitch */ -#define CHNL_OUT_BUF_PITCH 0x7C -#define CHNL_OUT_BUF_PITCH_LINE_PITCH_OFFSET 0 -#define CHNL_OUT_BUF_PITCH_LINE_PITCH_MASK 0xFFFF - -/* Channel Input Buffer Address */ -#define CHNL_IN_BUF_ADDR 0x80 - -/* Channel Input Buffer Pitch */ -#define CHNL_IN_BUF_PITCH 0x84 -#define CHNL_IN_BUF_PITCH_FRM_PITCH_OFFSET 16 -#define CHNL_IN_BUF_PITCH_FRM_PITCH_MASK 0xFFFF0000 -#define CHNL_IN_BUF_PITCH_LINE_PITCH_OFFSET 0 -#define CHNL_IN_BUF_PITCH_LINE_PITCH_MASK 0xFFFF - -/* Channel Memory Read Control */ -#define CHNL_MEM_RD_CTRL 0x88 -#define CHNL_MEM_RD_CTRL_IMG_TYPE_OFFSET 28 -#define CHNL_MEM_RD_CTRL_IMG_TYPE_MASK 0xF0000000 -#define CHNL_MEM_RD_CTRL_READ_MEM_OFFSET 0 -#define CHNL_MEM_RD_CTRL_READ_MEM_MASK 1 -#define CHNL_MEM_RD_CTRL_READ_MEM_ENABLE 1 - -/* Channel RGB or Luma (Y) Output Buffer 2 Address */ -#define CHNL_OUT_BUF2_ADDR_Y 0x8C - -/* Channel Chroma (U/Cb/UV/CbCr) Output Buffer 2 Address */ -#define CHNL_OUT_BUF2_ADDR_U 0x90 - -/* Channel Chroma (V/Cr) Output Buffer 2 Address */ -#define CHNL_OUT_BUF2_ADDR_V 0x94 - -enum isi_csi_coeff { - YUV2RGB = 0, - RGB2YUV, -}; - -void mxc_isi_channel_init(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_deinit(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_config(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_enable(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_disable(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_outbuf(struct mxc_isi_dev *mxc_isi, struct mxc_isi_buffer *buf); -void mxc_isi_frame_write_done(struct mxc_isi_dev *mxc_isi); -void mxc_isi_frame_read_done(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_deinterlace(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_sw_reset(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_source_config(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_flip(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_csc(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_alpha_roi0(struct mxc_isi_dev *mxc_isi, struct v4l2_rect *rect); -void mxc_isi_channel_set_alpha(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_4k(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_deinterlace(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_crop(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_memory_image(struct mxc_isi_dev *mxc_isi); -void mxc_isi_channel_set_scaler(struct mxc_isi_dev *mxc_isi); - -void mxc_isi_clean_irq_status(struct mxc_isi_dev *mxc_isi, u32 val); -u32 mxc_isi_get_irq_status(struct mxc_isi_dev *mxc_isi); -void mxc_isi_enable_irq(struct mxc_isi_dev *mxc_isi); -void mxc_isi_disable_irq(struct mxc_isi_dev *mxc_isi); - -#endif /* MXC_ISI_HW_H_ */ diff --git a/drivers/media/platform/imx8/mxc-jpeg-hw.c b/drivers/media/platform/imx8/mxc-jpeg-hw.c deleted file mode 100644 index 6bb1b1d20f53a86b3d24cd93ce884bef4c6f1c56..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-jpeg-hw.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include -#include -#include "mxc-jpeg-hw.h" - -enum mxc_jpeg_image_format { - MXC_JPEG_YUV420 = 0x0, - MXC_JPEG_YUV422 = 0x1, - MXC_JPEG_RGB = 0x2, - MXC_JPEG_YUV444 = 0x3, - MXC_JPEG_Y = 0x4, - MXC_JPEG_ARGB = 0x6, -}; - -void print_descriptor_info(struct mxc_jpeg_desc *desc) -{ - printk(KERN_DEBUG " MXC JPEG NEXT PTR %x\n", desc->next_descpt_ptr); - printk(KERN_DEBUG " MXC JPEG BUF BASE0 %x\n", desc->buf_base0); - printk(KERN_DEBUG " MXC JPEG PITCH %d\n", desc->line_pitch); - printk(KERN_DEBUG " MXC JPEG BUF BASE %x\n", desc->stm_bufbase); - printk(KERN_DEBUG " MXC JPEG BUF SIZE %d\n", desc->stm_bufsize); - printk(KERN_DEBUG " MXC JPEG IMGSIZE %dx%d\n", desc->w, desc->h); - printk(KERN_DEBUG " MXC JPEG STM CTRL %x\n", desc->stm_ctrl); -} - -void mxc_jpeg_enable_irq(void __iomem *reg, int slot) -{ - writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN)); -} - -void mxc_jpeg_reset(void __iomem *reg) -{ - writel(MXC_ENABLE_DEC, reg); -} - -u32 mxc_jpeg_get_offset(void __iomem *reg, int slot) -{ - return readl(reg + MXC_SLOT_OFFSET(slot, SLOT_BUF_PTR)); -} - -void mxc_jpeg_enc_config(void __iomem *reg, struct mxc_jpeg_desc *cfg_desc, - u32 cfg_handle, u32 tbl_handle, u32 jpg_handle) -{ - u32 regval, slot; - - writel(0x1e0, reg + CAST_STATUS0); - writel(0x3ff, reg + CAST_STATUS1); - writel(0x4b, reg + CAST_STATUS2); - - slot = mxc_jpeg_get_slot(reg); - mxc_jpeg_enable_irq(reg, slot); - writel((1 << (slot + 4)), reg); - - cfg_desc->next_descpt_ptr = 0; - cfg_desc->buf_base0 = tbl_handle; - cfg_desc->buf_base1 = 0; - cfg_desc->line_pitch = 0x300; - cfg_desc->stm_bufbase = jpg_handle; - cfg_desc->stm_bufsize = 0x100000; - cfg_desc->w = 0x0100; - cfg_desc->h = 0x0100; - cfg_desc->stm_ctrl = MXC_CONFIG_MOD; - - //print_descriptor_info(cfg_desc); - writel(cfg_handle, reg + MXC_SLOT_OFFSET(slot, SLOT_NXT_DESCPT_PTR)); - writel(cfg_handle | 1, reg + - MXC_SLOT_OFFSET(slot, SLOT_NXT_DESCPT_PTR)); - writel((1 << (slot + 4)) | MXC_ENDIAN_MD | MXC_ENABLE_DEC | - MXC_DEC_GO, reg); - regval = readl(reg + STM_BUFBASE); - regval = readl(reg + MXC_SLOT_OFFSET(slot, SLOT_BUF_PTR)); -} - -int mxc_jpeg_enable(void __iomem *reg) -{ - u32 regval; - - regval = readl(reg); - writel(MXC_ENABLE_DEC, reg); - regval = readl(reg); - return regval; -} - -void mxc_jpeg_go(void __iomem *reg) -{ - u32 val; - - val = readl(reg); - writel(MXC_ENDIAN_MD | MXC_DEC_GO | val, reg); - writel(0x4, reg + 0x134); - //print_cast_decoder_info(reg); -} - -void print_cast_decoder_info(void __iomem *reg) -{ - int regval; - - regval = readl(reg + MXC_SLOT_OFFSET(0, SLOT_CUR_DESCPT_PTR)); - printk(KERN_DEBUG " MXC_JPEG: CUR DESCPT PTR: %x\n", regval); - regval = readl(reg + 0x100); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 1: %x\n", regval); - regval = readl(reg + 0x104); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 2: %x\n", regval); - regval = readl(reg + 0x108); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 3: %x\n", regval); - regval = readl(reg + 0x10c); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 4: %x\n", regval); - regval = readl(reg + 0x110); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 5: %x\n", regval); - regval = readl(reg + 0x114); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 6: %x\n", regval); - regval = readl(reg + 0x118); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 7: %x\n", regval); - regval = readl(reg + 0x11c); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 8: %x\n", regval); - regval = readl(reg + 0x120); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 9: %x\n", regval); - regval = readl(reg + 0x124); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 10: %x\n", regval); - regval = readl(reg + 0x128); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 11: %x\n", regval); - regval = readl(reg + 0x12c); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 12: %x\n", regval); - regval = readl(reg + 0x130); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 13: %x\n", regval); - regval = readl(reg + 0x134); - printk(KERN_DEBUG " MXC_JPEG: CAST_INFO 14: %x\n", regval); -} - -int mxc_jpeg_get_slot(void __iomem *reg) -{ - int slot_val; - int i = 0; - int tmp = MXC_SLOT_EN; - - slot_val = readl(reg) & 0xF0; - for (; tmp != tmp << 4; tmp = tmp << 1) { - if ((slot_val & tmp) == 0) - return i; - ++i; - } - return -EINVAL; -} - -void mxc_jpeg_enable_slot(void __iomem *reg, int slot) -{ - u32 regval; - - regval = readl(reg); - writel((1 << (slot + 4)) | regval, reg); -} - -void mxc_jpeg_set_addrs(struct mxc_jpeg_desc *desc, u32 buf_base0, u32 bufbase) -{ - desc->buf_base0 = buf_base0; - desc->stm_bufbase = bufbase; -} - -int mxc_jpeg_set_params(struct mxc_jpeg_desc *desc, u32 bufsize, - u16 out_pitch, u32 format) -{ - desc->line_pitch = out_pitch; - desc->stm_bufsize = bufsize; - switch (format) { - case V4L2_PIX_FMT_YUV32: - desc->stm_ctrl |= MXC_JPEG_YUV444 << 3; - break; - case V4L2_PIX_FMT_YUYV: - desc->stm_ctrl |= MXC_JPEG_YUV422 << 3; - break; - case V4L2_PIX_FMT_RGB32: - desc->stm_ctrl |= MXC_JPEG_RGB << 3; - break; - default: - return -1; - } - return 0; -} - -void mxc_jpeg_set_res(struct mxc_jpeg_desc *desc, u16 w, u16 h) -{ - desc->w = w; - desc->h = h; -} - -void mxc_jpeg_set_desc(u32 desc, void __iomem *reg, int slot) -{ - writel(desc | 1, reg + MXC_SLOT_OFFSET(slot, SLOT_NXT_DESCPT_PTR)); -} diff --git a/drivers/media/platform/imx8/mxc-jpeg-hw.h b/drivers/media/platform/imx8/mxc-jpeg-hw.h deleted file mode 100644 index 2107818427cea7f23b9b7c86bc89e5023b8eb041..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-jpeg-hw.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ -#ifndef _MXC_JPEG_HW_H -#define _MXC_JPEG_HW_H -#define COM_STATUS 0x4 -#define OUT_BUFFER0 0x14 -#define OUT_BUFFER1 0x18 -#define OUT_PITCH 0x1C -#define STM_BUFBASE 0x20 -#define STM_BUFSIZE 0x24 -#define IMG_SIZE 0x28 -#define STM_CTRL 0x2C -#define CAST_STATUS0 0x100 -#define CAST_STATUS1 0x104 -#define CAST_STATUS2 0x108 -#define CAST_STATUS3 0x10c -#define CAST_STATUS4 0x110 -#define CAST_STATUS5 0x114 -#define CAST_STATUS6 0x118 -#define CAST_STATUS7 0x11c -#define CAST_STATUS8 0x120 -#define CAST_STATUS9 0x124 -#define CAST_STATUS10 0x128 -#define CAST_STATUS11 0x12c -#define CAST_STATUS12 0x130 -#define CAST_STATUS13 0x134 -#define SLOT_BASE 0x10000 -#define SLOT_STATUS 0x0 -#define SLOT_IRQ_EN 0x4 -#define SLOT_BUF_PTR 0x8 -#define SLOT_CUR_DESCPT_PTR 0xC -#define SLOT_NXT_DESCPT_PTR 0x10 -#define MXC_SLOT_OFFSET(slot, offset) ((SLOT_BASE * (slot + 1)) + offset) - -#define MXC_ENABLE_DEC (0x1) -#define MXC_RESET_DEC (0x1 << 1) -#define MXC_DEC_GO (0x1 << 2) -#define MXC_ENDIAN_MD (0x1 << 3) -#define MXC_SLOT_EN (0x1 << 4) -#define MXC_CONFIG_MOD (0x1 << 9) - -#include "mxc-jpeg.h" -void print_descriptor_info(struct mxc_jpeg_desc *desc); -void mxc_jpeg_reset(void __iomem *reg); -int mxc_jpeg_enable(void __iomem *reg); -void mxc_jpeg_enc_config(void __iomem *reg, struct mxc_jpeg_desc *cfg_desc, - u32 cfg_handle, u32 tbl_handle, u32 jpg_handle); -void mxc_jpeg_go(void __iomem *reg); -int mxc_jpeg_get_slot(void __iomem *reg); -u32 mxc_jpeg_get_offset(void __iomem *reg, int slot); -void mxc_jpeg_enable_slot(void __iomem *reg, int slot); -void mxc_jpeg_enable_irq(void __iomem *reg, int slot); -int mxc_jpeg_set_input(void __iomem *reg, u32 in_buf, u32 bufsize); -int mxc_jpeg_set_output(void __iomem *reg, u16 out_pitch, u32 out_buf, - u16 w, u16 h); -void mxc_jpeg_set_addrs(struct mxc_jpeg_desc *desc, u32 src_addr, u32 dst_addr); -int mxc_jpeg_set_params(struct mxc_jpeg_desc *desc, u32 bufsize, u16 - out_pitch, u32 format); -void mxc_jpeg_set_res(struct mxc_jpeg_desc *desc, u16 w, u16 h); -void mxc_jpeg_set_desc(u32 desc, void __iomem *reg, int slot); -void print_cast_decoder_info(void __iomem *reg); -#endif diff --git a/drivers/media/platform/imx8/mxc-jpeg.c b/drivers/media/platform/imx8/mxc-jpeg.c deleted file mode 100644 index a38bfae5c1153924e3684d7e58ac9eed74bbada1..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-jpeg.c +++ /dev/null @@ -1,1127 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "mxc-jpeg-hw.h" -#include "mxc-jpeg.h" - -static struct mxc_jpeg_fmt mxc_formats[] = { - { - .name = "JPEG", - .fourcc = V4L2_PIX_FMT_JPEG, - .colplanes = 1, - .flags = MXC_JPEG_FMT_TYPE_ENC, - }, - { - .name = "RGB32", - .fourcc = V4L2_PIX_FMT_RGB32, - .depth = 32, - .colplanes = 1, - .h_align = 0, - .v_align = 0, - .flags = MXC_JPEG_FMT_TYPE_RAW, - }, - { - .name = "YUV422", - .fourcc = V4L2_PIX_FMT_YUYV, - .depth = 16, - .colplanes = 1, - .h_align = 2, - .v_align = 0, - .flags = MXC_JPEG_FMT_TYPE_RAW, - }, - { - .name = "YUV444", - .fourcc = V4L2_PIX_FMT_YUV32, - .depth = 32, - .colplanes = 1, - .h_align = 0, - .v_align = 0, - .flags = MXC_JPEG_FMT_TYPE_RAW, - }, -}; - -static const struct of_device_id mxc_jpeg_match[] = { - { - .compatible = "fsl,imx8-jpgdec", - .data = (void *)MXC_JPEG_DECODE, - }, - { - .compatible = "fsl,imx8-jpgenc", - .data = (void *)MXC_JPEG_ENCODE, - }, - { }, -}; - -static const unsigned char hactbl[615] = { -0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, -0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x00, -0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xFF, -0xDB, 0x00, 0x84, 0x00, 0x10, 0x0B, 0x0C, -0x0E, 0x0C, 0x0A, 0x10, 0x0E, 0x0D, 0x0E, -0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 0x1A, -0x18, 0x16, 0x16, 0x18, 0x31, 0x23, 0x25, -0x1D, 0x28, 0x3A, 0x33, 0x3D, 0x3C, 0x39, -0x33, 0x38, 0x37, 0x40, 0x48, 0x5C, 0x4E, -0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, -0x6D, 0x51, 0x57, 0x5F, 0x62, 0x67, 0x68, -0x67, 0x3E, 0x4D, 0x71, 0x79, 0x70, 0x64, -0x78, 0x5C, 0x65, 0x67, 0x63, 0x01, 0x11, -0x12, 0x12, 0x18, 0x15, 0x18, 0x2F, 0x1A, -0x1A, 0x2F, 0x63, 0x42, 0x38, 0x42, 0x63, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0xFF, 0xC0, 0x00, 0x11, 0x08, 0x01, 0x00, -0x01, 0x00, 0x03, 0x01, 0x11, 0x00, 0x02, -0x11, 0x01, 0x03, 0x11, 0x01, 0xFF, 0xC4, -0x01, 0xA2, 0x00, 0x00, 0x01, 0x05, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, -0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, -0x09, 0x0A, 0x0B, 0x10, 0x00, 0x02, 0x01, -0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, -0x04, 0x04, 0x00, 0x00, 0x01, 0x7D, 0x01, -0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, -0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, -0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, -0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15, -0x52, 0xD1, 0xF0, 0x24, 0x33, 0x62, 0x72, -0x82, 0x09, 0x0A, 0x16, 0x17, 0x18, 0x19, -0x1A, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, -0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, -0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, -0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, -0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, -0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, -0x77, 0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, -0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, -0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, -0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, -0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, -0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, -0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, -0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, -0xDA, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, -0xE7, 0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3, -0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, -0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, -0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, -0x0B, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, -0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, -0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, -0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, -0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, -0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, -0xA1, 0xB1, 0xC1, 0x09, 0x23, 0x33, 0x52, -0xF0, 0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, -0x24, 0x34, 0xE1, 0x25, 0xF1, 0x17, 0x18, -0x19, 0x1A, 0x26, 0x27, 0x28, 0x29, 0x2A, -0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, -0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, -0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, -0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, -0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, -0x78, 0x79, 0x7A, 0x82, 0x83, 0x84, 0x85, -0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, -0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, -0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, -0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, -0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, -0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, -0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, -0xDA, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, -0xE8, 0xE9, 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, -0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFF, 0xDD, -0x00, 0x04, 0x00, 0x20, 0xFF, 0xDA, 0x00, -0x0C, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, -0x11, 0x00, 0x3F, 0x00, 0xFF, 0xD9 -}; - -struct mxc_jpeg_src_buf { - struct vb2_v4l2_buffer b; - struct list_head list; - struct mxc_jpeg_desc *desc; - void *tbl; - int flags; - dma_addr_t handle; - dma_addr_t cfg_handle; - dma_addr_t tbl_handle; -}; - -#define MXC_NUM_FORMATS ARRAY_SIZE(mxc_formats) -static inline u32 mxc_jpeg_align(u32 val, u32 align) -{ - return (val + align - 1) & ~(align - 1); -} - - -static inline struct mxc_jpeg_ctx *mxc_jpeg_fh_to_ctx(struct v4l2_fh *fh) -{ - return container_of(fh, struct mxc_jpeg_ctx, fh); -} - -static inline struct mxc_jpeg_src_buf *mxc_jpeg_vb2_to_srcbuf( - struct vb2_buffer *vb) -{ - return container_of(to_vb2_v4l2_buffer(vb), struct mxc_jpeg_src_buf, b); -} - -static int enum_fmt(struct mxc_jpeg_fmt *mxc_formats, int n, - struct v4l2_fmtdesc *f, u32 type) -{ - int i, num = 0; - - for (i = 0; i < n; ++i) { - if (mxc_formats[i].flags & type) { - /* index-th format of type type found ? */ - if (num == f->index) - break; - /* Correct type but haven't reached our index yet, - * just increment per-type index - */ - ++num; - } - } - - /* Format not found */ - if (i >= n) - return -EINVAL; - - strlcpy(f->description, mxc_formats[i].name, sizeof(f->description)); - f->pixelformat = mxc_formats[i].fourcc; - - return 0; -} - -void mxc_jpeg_addrs(struct mxc_jpeg_desc *desc, struct vb2_buffer *b_base0_buf, -struct vb2_buffer *bufbase_buf, int offset) -{ - u32 buf_base0, bufbase; - - buf_base0 = vb2_dma_contig_plane_dma_addr(b_base0_buf, 0); - bufbase = vb2_dma_contig_plane_dma_addr(bufbase_buf, 0); - mxc_jpeg_set_addrs(desc, buf_base0, bufbase + offset); -} - -static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv) -{ - struct mxc_jpeg_dev *jpeg = priv; - struct mxc_jpeg_ctx *ctx; - void __iomem *reg = jpeg->base_reg; - struct vb2_buffer *src_buf, *dst_buf; - struct mxc_jpeg_src_buf *jpeg_src_buf; - enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; - struct mxc_jpeg_desc *desc; - dma_addr_t dma_handle; - u32 dec_ret, offset, slot; - struct mxc_jpeg_q_data *q_data; - void *testaddri; - void *testaddro; - - dec_ret = readl(reg + 0x10000); - writel(dec_ret, reg + 0x10000); - if (!(dec_ret & 0x8)) - return IRQ_HANDLED; - ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev); - dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); - src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); - jpeg_src_buf = mxc_jpeg_vb2_to_srcbuf(src_buf); - - if (ctx->mode == MXC_JPEG_ENCODE && - ctx->enc_state == MXC_JPEG_ENC_CONF) { - q_data = &ctx->out_q; - desc = jpeg_src_buf->desc; - dma_handle = jpeg_src_buf->handle; - - testaddri = vb2_plane_vaddr(src_buf, 0); - testaddro = vb2_plane_vaddr(dst_buf, 0); - - offset = mxc_jpeg_get_offset(jpeg->base_reg, 0); - mxc_jpeg_addrs(desc, src_buf, dst_buf, offset); - slot = mxc_jpeg_get_slot(jpeg->base_reg); - mxc_jpeg_set_params(desc, mxc_jpeg_align( - vb2_plane_size(src_buf, 0), 1024), - q_data->bytesperline[0], - q_data->fmt->fourcc); - mxc_jpeg_set_res(desc, q_data->w, q_data->h); - ctx->enc_state = MXC_JPEG_ENC_DONE; - mxc_jpeg_set_desc(dma_handle, jpeg->base_reg, slot); - return IRQ_HANDLED; - } - buf_state = VB2_BUF_STATE_DONE; - v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); - v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state); - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state); - v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); - return IRQ_HANDLED; -} -void mxc_jpeg_config_enc(struct vb2_buffer *out_buf, - struct mxc_jpeg_src_buf *jpeg_src_buf, - struct mxc_jpeg_dev *jpeg) -{ - dma_addr_t jpg_handle; - - jpg_handle = vb2_dma_contig_plane_dma_addr(out_buf, 0); - jpeg_src_buf->tbl = dma_zalloc_coherent(jpeg->dev, - sizeof(unsigned char) * 615, - &jpeg_src_buf->tbl_handle, 0); - memcpy(jpeg_src_buf->tbl, &hactbl, sizeof(unsigned char) * 615); - - mxc_jpeg_enc_config(jpeg->base_reg, jpeg_src_buf->desc, jpeg_src_buf->handle, - jpeg_src_buf->tbl_handle, jpg_handle); - -} -static void mxc_jpeg_device_run(void *priv) -{ - struct mxc_jpeg_ctx *ctx = priv; - struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg; - struct vb2_buffer *src_buf, *dst_buf; - unsigned long flags; - struct mxc_jpeg_q_data *cap_q_data = &ctx->cap_q; - struct mxc_jpeg_src_buf *jpeg_src_buf; - int slot; - void *testaddri; - void *testaddro; - dma_addr_t dma_handle; - struct mxc_jpeg_desc *desc; - - - src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); - dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); - jpeg_src_buf = mxc_jpeg_vb2_to_srcbuf(src_buf); - desc = jpeg_src_buf->desc; - dma_handle = jpeg_src_buf->handle; - - - testaddri = vb2_plane_vaddr(src_buf, 0); - testaddro = vb2_plane_vaddr(dst_buf, 0); - spin_lock_irqsave(&ctx->mxc_jpeg->hw_lock, flags); - mxc_jpeg_enable(jpeg->base_reg); - - if (ctx->mode == MXC_JPEG_ENCODE) { - ctx->enc_state = MXC_JPEG_ENC_CONF; - mxc_jpeg_config_enc(dst_buf, jpeg_src_buf, jpeg); - } else { - mxc_jpeg_addrs(desc, dst_buf, src_buf, 0); - slot = mxc_jpeg_get_slot(jpeg->base_reg); - mxc_jpeg_enable_slot(jpeg->base_reg, slot); - mxc_jpeg_set_params(desc, - mxc_jpeg_align(vb2_plane_size(src_buf, 0), - 1024), - cap_q_data->bytesperline[0], - cap_q_data->fmt->fourcc); - mxc_jpeg_enable_irq(jpeg->base_reg, slot); - mxc_jpeg_set_desc(dma_handle, jpeg->base_reg, slot); - mxc_jpeg_go(jpeg->base_reg); - } - spin_unlock_irqrestore(&ctx->mxc_jpeg->hw_lock, flags); -} -static int mxc_jpeg_job_ready(void *priv) -{ - return 1; -} -static void mxc_jpeg_job_abort(void *priv) -{ -} - -static struct mxc_jpeg_q_data *mxc_jpeg_get_q_data(struct mxc_jpeg_ctx *ctx, - enum v4l2_buf_type type) -{ - if (V4L2_TYPE_IS_OUTPUT(type)) - return &ctx->out_q; - return &ctx->cap_q; -} - -static int mxc_jpeg_queue_setup(struct vb2_queue *q, - unsigned int *num_buffers, - unsigned int *num_planes, - unsigned int sizes[], - struct device *alloc_ctxs[]) -{ - struct mxc_jpeg_ctx *ctx = vb2_get_drv_priv(q); - struct mxc_jpeg_q_data *q_data = NULL; - - q_data = mxc_jpeg_get_q_data(ctx, q->type); - if (!q_data) - return -EINVAL; - *num_planes = 1; - sizes[0] = 10; - - if (q_data->sizeimage[0] > 0) - sizes[0] = q_data->sizeimage[0]; - - return 0; -} -static int mxc_jpeg_start_streaming(struct vb2_queue *q, unsigned int count) -{ - struct mxc_jpeg_ctx *ctx = vb2_get_drv_priv(q); - int ret; - - ret = pm_runtime_get_sync(ctx->mxc_jpeg->dev); - return ret > 0 ? 0 : ret; -} - -static void mxc_jpeg_stop_streaming(struct vb2_queue *q) -{ - struct mxc_jpeg_ctx *ctx = vb2_get_drv_priv(q); - - pm_runtime_put(&ctx->mxc_jpeg->pdev->dev); -} -struct mxc_jpeg_stream { - u8 *addr; - u32 loc; - u32 end; -}; -static u8 get_byte(struct mxc_jpeg_stream *stream) -{ - u8 ret; - - if (stream->loc >= stream->end) - return -1; - ret = stream->addr[stream->loc]; - stream->loc++; - return ret; -} -static u16 get_word_be(struct mxc_jpeg_stream *stream, u32 *word) -{ - u16 ret1; - u16 ret2; - - ret1 = get_byte(stream); - ret2 = get_byte(stream); - if (ret1 != -1 && ret2 != -1) { - *word = ((ret1 << 8) | ret2); - return 0; - } - return -1; -} -static int mxc_jpeg_parse(struct mxc_jpeg_desc *desc, u8 *src_addr, u32 size) -{ - struct mxc_jpeg_stream stream; - bool notfound = true; - int height, width, byte, length, word; - - stream.addr = src_addr; - stream.end = size; - stream.loc = 0; - while (notfound) { - byte = get_byte(&stream); - if (byte == -1) - return -EINVAL; - if (byte != 0xff) - continue; - do { - byte = get_byte(&stream); - } while (byte == 0xff); - if (byte == -1) - return false; - if (byte == 0) - continue; - length = 0; - switch (byte) { - case SOF2: - case SOF0: - if (get_word_be(&stream, &word)) - break; - length = (long)word - 2; - if (!length) - return false; - if (get_byte(&stream) == -1) - break; - if (get_word_be(&stream, &height)) - break; - if (get_word_be(&stream, &width)) - break; - notfound = false; - break; - default: - notfound = true; - } - } - if (width % 8 != 0 || height % 8 != 0) - return -EINVAL; - desc->w = width; - desc->h = height; - return 0; -} -static void mxc_jpeg_buf_queue(struct vb2_buffer *vb) -{ - int ret; - struct mxc_jpeg_src_buf *jpeg_src_buf; - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); - struct mxc_jpeg_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); - - if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) - goto end; - jpeg_src_buf = container_of(vbuf, struct mxc_jpeg_src_buf, b); - jpeg_src_buf->desc = dma_zalloc_coherent(ctx->mxc_jpeg->dev, - sizeof(struct mxc_jpeg_desc), - &jpeg_src_buf->handle, 0); - if (ctx->mode != MXC_JPEG_DECODE) - goto end; - ret = mxc_jpeg_parse(jpeg_src_buf->desc, (u8 *)vb2_plane_vaddr(vb, 0), - vb2_get_plane_payload(vb, 0)); - if (ret) { - v4l2_err(&ctx->mxc_jpeg->v4l2_dev, - "driver does not support this resolution\n"); - vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); - return; - } - - if (ctx->state == MXC_JPEG_INIT) { - struct vb2_queue *dst_vq = v4l2_m2m_get_vq( - ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); - static const struct v4l2_event ev_src_ch = { - .type = V4L2_EVENT_SOURCE_CHANGE, - .u.src_change.changes = - V4L2_EVENT_SRC_CH_RESOLUTION, - }; - - v4l2_event_queue_fh(&ctx->fh, &ev_src_ch); - if (vb2_is_streaming(dst_vq)) - ctx->state = MXC_JPEG_RUNNING; - } - -end: - v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); -} -static int mxc_jpeg_buf_prepare(struct vb2_buffer *vb) -{ - struct mxc_jpeg_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); - struct mxc_jpeg_q_data *q_data = NULL; - - q_data = mxc_jpeg_get_q_data(ctx, vb->vb2_queue->type); - if (!q_data) - return -EINVAL; - - vb2_set_plane_payload(vb, 0, q_data->sizeimage[0]); - return 0; -} - -static void mxc_jpeg_buf_clean(struct vb2_buffer *vb) -{ - struct mxc_jpeg_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); - struct mxc_jpeg_src_buf *jpeg_src_buf; - - jpeg_src_buf = container_of(vbuf, struct mxc_jpeg_src_buf, b); - - if (ctx->mode == MXC_JPEG_ENCODE && - ctx->enc_state == MXC_JPEG_ENC_CONF) - dma_free_coherent(ctx->mxc_jpeg->dev, sizeof(hactbl), - jpeg_src_buf->tbl, jpeg_src_buf->tbl_handle); - - dma_free_coherent(ctx->mxc_jpeg->dev, sizeof(struct mxc_jpeg_desc), - jpeg_src_buf->desc, jpeg_src_buf->handle); -} - -static const struct vb2_ops mxc_jpeg_qops = { - .queue_setup = mxc_jpeg_queue_setup, - - .buf_prepare = mxc_jpeg_buf_prepare, - .buf_queue = mxc_jpeg_buf_queue, - .wait_prepare = vb2_ops_wait_prepare, - .wait_finish = vb2_ops_wait_finish, - .start_streaming = mxc_jpeg_start_streaming, - .stop_streaming = mxc_jpeg_stop_streaming, - .buf_cleanup = mxc_jpeg_buf_clean, -}; -static int mxc_jpeg_queue_init(void *priv, struct vb2_queue *src_vq, - struct vb2_queue *dst_vq) -{ - struct mxc_jpeg_ctx *ctx = priv; - int ret; - - src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - src_vq->io_modes = VB2_MMAP | VB2_USERPTR; - src_vq->drv_priv = ctx; - src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); - src_vq->ops = &mxc_jpeg_qops; - src_vq->mem_ops = &vb2_dma_contig_memops; - src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - src_vq->lock = &ctx->mxc_jpeg->lock; - src_vq->dev = ctx->mxc_jpeg->dev; - - ret = vb2_queue_init(src_vq); - if (ret) - return ret; - - dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - dst_vq->io_modes = VB2_MMAP | VB2_USERPTR; - dst_vq->drv_priv = ctx; - dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); - dst_vq->ops = &mxc_jpeg_qops; - dst_vq->mem_ops = &vb2_dma_contig_memops; - dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - dst_vq->lock = &ctx->mxc_jpeg->lock; - dst_vq->dev = ctx->mxc_jpeg->dev; - - ret = vb2_queue_init(dst_vq); - return ret; -} - -static struct mxc_jpeg_fmt *mxc_jpeg_find_format(struct mxc_jpeg_ctx *ctx, - u32 pixelformat, - unsigned int fmt_type) -{ - unsigned int k, fmt_flag; - - fmt_flag = fmt_type; - - if (ctx->mode == MXC_JPEG_ENCODE) - fmt_flag = (fmt_type == MXC_JPEG_FMT_TYPE_RAW) ? - MXC_JPEG_FMT_TYPE_ENC : - MXC_JPEG_FMT_TYPE_RAW; - - for (k = 0; k < MXC_JPEG_NUM_FORMATS; k++) { - struct mxc_jpeg_fmt *fmt = &mxc_formats[k]; - - if (fmt->fourcc == pixelformat && fmt->flags == fmt_flag) - return fmt; - } - return NULL; -} - - -static int mxc_jpeg_open(struct file *file) -{ - struct mxc_jpeg_dev *mxc_jpeg = video_drvdata(file); - struct video_device *mxc_vfd = video_devdata(file); - struct mxc_jpeg_ctx *ctx; - struct mxc_jpeg_fmt *out_fmt, *cap_fmt; - int ret = 0; - - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); - if (!ctx) - return -ENOMEM; - - if (mutex_lock_interruptible(&mxc_jpeg->lock)) { - ret = -ERESTARTSYS; - goto free; - } - - pm_runtime_get_sync(mxc_jpeg->dev); - - v4l2_fh_init(&ctx->fh, mxc_vfd); - file->private_data = &ctx->fh; - v4l2_fh_add(&ctx->fh); - - ctx->mxc_jpeg = mxc_jpeg; - if (mxc_jpeg->mode == MXC_JPEG_ENCODE) { - ctx->mode = MXC_JPEG_ENCODE; - cap_fmt = mxc_jpeg_find_format(ctx, V4L2_PIX_FMT_RGB24, - MXC_JPEG_FMT_TYPE_ENC); - out_fmt = mxc_jpeg_find_format(ctx, V4L2_PIX_FMT_JPEG, - MXC_JPEG_FMT_TYPE_RAW); - } else { - ctx->mode = MXC_JPEG_DECODE; - out_fmt = mxc_jpeg_find_format(ctx, V4L2_PIX_FMT_RGB24, - MXC_JPEG_FMT_TYPE_RAW); - cap_fmt = mxc_jpeg_find_format(ctx, V4L2_PIX_FMT_JPEG, - MXC_JPEG_FMT_TYPE_ENC); - } - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(mxc_jpeg->m2m_dev, ctx, - mxc_jpeg_queue_init); - ctx->out_q.fmt = out_fmt; - ctx->cap_q.fmt = cap_fmt; - if (IS_ERR(ctx->fh.m2m_ctx)) { - ret = PTR_ERR(ctx->fh.m2m_ctx); - goto error; - } - - - - mutex_unlock(&mxc_jpeg->lock); - return 0; - -error: - v4l2_fh_del(&ctx->fh); - v4l2_fh_exit(&ctx->fh); - mutex_unlock(&mxc_jpeg->lock); -free: - kfree(ctx); - return ret; -} - -static int mxc_jpeg_querycap(struct file *file, void *priv, - struct v4l2_capability *cap) -{ - struct mxc_jpeg_dev *mxc_jpeg = video_drvdata(file); - - strlcpy(cap->driver, MXC_JPEG_NAME " decoder", sizeof(cap->driver)); - strlcpy(cap->card, MXC_JPEG_NAME " decoder", sizeof(cap->card)); - snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s", - dev_name(mxc_jpeg->dev)); - cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M; - cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; - - return 0; -} -static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_fmtdesc *f) -{ - return enum_fmt(mxc_formats, MXC_NUM_FORMATS, f, - MXC_IN_FORMAT); -} - -static int mxc_jpeg_enum_fmt_vid_out(struct file *file, void *priv, - struct v4l2_fmtdesc *f) -{ - return enum_fmt(mxc_formats, MXC_NUM_FORMATS, f, - MXC_OUT_FORMAT); -} -static void mxc_jpeg_bound_align_image(u32 *w, unsigned int wmin, - unsigned int wmax, unsigned int walign, - u32 *h, unsigned int hmin, - unsigned int hmax, unsigned int halign) -{ - int width, height, w_step, h_step; - - width = *w; - height = *h; - w_step = 1 << walign; - h_step = 1 << halign; - - v4l_bound_align_image(w, wmin, wmax, walign, h, hmin, hmax, halign, 0); - if (*w < width && (*w + w_step) <= wmax) - *w += w_step; - if (*h < height && (*h + h_step) <= hmax) - *h += h_step; -} -static int mxc_jpeg_try_fmt(struct v4l2_format *f, struct mxc_jpeg_fmt *fmt, - struct mxc_jpeg_ctx *ctx, int q_type) -{ - struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; - struct v4l2_plane_pix_format *pfmt = &pix_mp->plane_fmt[0]; - u32 stride, h; - - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); - pix_mp->field = V4L2_FIELD_NONE; - pix_mp->num_planes = fmt->colplanes; - pix_mp->pixelformat = fmt->fourcc; - - if (q_type == MXC_JPEG_FMT_TYPE_ENC && ctx->mode == MXC_JPEG_DECODE) { - struct v4l2_plane_pix_format *pfmt = &pix_mp->plane_fmt[0]; - - mxc_jpeg_bound_align_image(&pix_mp->width, - MXC_JPEG_MIN_WIDTH, - MXC_JPEG_MAX_WIDTH, - MXC_JPEG_MIN_WIDTH, - &pix_mp->height, - MXC_JPEG_MIN_HEIGHT, - MXC_JPEG_MAX_HEIGHT, - MXC_JPEG_MIN_WIDTH); - - memset(pfmt->reserved, 0, sizeof(pfmt->reserved)); - pfmt->bytesperline = 0; - /* Source size must be aligned to 128 */ - pfmt->sizeimage = mxc_jpeg_align(pfmt->sizeimage, 128); - if (pfmt->sizeimage == 0) - pfmt->sizeimage = MXC_JPEG_DEFAULT_SIZEIMAGE; - return 0; - } - - /* type is MXC_JPEG_FMT_TYPE_RAW */ - mxc_jpeg_bound_align_image(&pix_mp->width, MXC_JPEG_MIN_WIDTH, - MXC_JPEG_MAX_WIDTH, MXC_JPEG_MIN_WIDTH, - &pix_mp->height, MXC_JPEG_MIN_HEIGHT, - MXC_JPEG_MAX_HEIGHT, MXC_JPEG_MIN_WIDTH); - - pfmt = &pix_mp->plane_fmt[0]; - stride = pix_mp->width * 3; - h = pix_mp->height; - memset(pfmt->reserved, 0, sizeof(pfmt->reserved)); - pfmt->bytesperline = stride; - pfmt->sizeimage = stride * h; - - return 0; -} -static int mxc_jpeg_try_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) -{ - struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv); - struct mxc_jpeg_fmt *fmt; - - fmt = mxc_jpeg_find_format(ctx, f->fmt.pix_mp.pixelformat, - MXC_JPEG_FMT_TYPE_RAW); - return mxc_jpeg_try_fmt(f, fmt, ctx, MXC_JPEG_FMT_TYPE_RAW); -} -static int mxc_jpeg_try_fmt_vid_out(struct file *file, void *priv, - struct v4l2_format *f) -{ - struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv); - struct mxc_jpeg_fmt *fmt; - - fmt = mxc_jpeg_find_format(ctx, f->fmt.pix_mp.pixelformat, - MXC_JPEG_FMT_TYPE_ENC); - return mxc_jpeg_try_fmt(f, fmt, ctx, MXC_JPEG_FMT_TYPE_ENC); -} -static int mxc_jpeg_s_fmt(struct mxc_jpeg_ctx *ctx, - struct v4l2_format *f) -{ - struct vb2_queue *vq; - struct mxc_jpeg_q_data *q_data = NULL; - struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; - struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg; - unsigned int f_type; - - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); - if (!vq) - return -EINVAL; - - q_data = mxc_jpeg_get_q_data(ctx, f->type); - - if (vb2_is_busy(vq)) { - v4l2_err(&jpeg->v4l2_dev, "queue busy\n"); - return -EBUSY; - } - - f_type = f->type; - - q_data->fmt = mxc_jpeg_find_format(ctx, pix_mp->pixelformat, f_type); - q_data->w = pix_mp->width; - q_data->h = pix_mp->height; - q_data->bytesperline[0] = pix_mp->plane_fmt[0].bytesperline; - q_data->sizeimage[0] = pix_mp->plane_fmt[0].sizeimage; - - return 0; -} -static int mxc_jpeg_s_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) -{ - int ret; - - ret = mxc_jpeg_try_fmt_vid_cap(file, priv, f); - if (ret) - return ret; - - return mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f); -} -static int mxc_jpeg_s_fmt_vid_out(struct file *file, void *priv, - struct v4l2_format *f) -{ - int ret; - - ret = mxc_jpeg_try_fmt_vid_out(file, priv, f); - if (ret) - return ret; - - return mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f); -} -static int mxc_jpeg_g_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) -{ - return 0; -} -static int mxc_jpeg_g_fmt_vid_out(struct file *file, void *priv, - struct v4l2_format *f) -{ - return 0; -} - -static int mxc_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) -{ - struct v4l2_fh *fh = file->private_data; - struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv); - struct vb2_queue *vq; - struct vb2_buffer *vb; - struct mxc_jpeg_src_buf *jpeg_src_buf; - - if (buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) - goto end; - - vq = v4l2_m2m_get_vq(fh->m2m_ctx, buf->type); - if (buf->index >= vq->num_buffers) { - dev_err(ctx->mxc_jpeg->dev, "buffer index out of range\n"); - return -EINVAL; - } - - vb = vq->bufs[buf->index]; - jpeg_src_buf = mxc_jpeg_vb2_to_srcbuf(vb); -end: - return v4l2_m2m_qbuf(file, fh->m2m_ctx, buf); -} - -static const struct v4l2_ioctl_ops mxc_jpeg_ioctl_ops = { - .vidioc_querycap = mxc_jpeg_querycap, - .vidioc_enum_fmt_vid_cap = mxc_jpeg_enum_fmt_vid_cap, - .vidioc_enum_fmt_vid_out = mxc_jpeg_enum_fmt_vid_out, - - .vidioc_try_fmt_vid_cap = mxc_jpeg_try_fmt_vid_cap, - .vidioc_try_fmt_vid_out = mxc_jpeg_try_fmt_vid_out, - - .vidioc_s_fmt_vid_cap = mxc_jpeg_s_fmt_vid_cap, - .vidioc_s_fmt_vid_out = mxc_jpeg_s_fmt_vid_out, - - .vidioc_g_fmt_vid_cap = mxc_jpeg_g_fmt_vid_cap, - .vidioc_g_fmt_vid_out = mxc_jpeg_g_fmt_vid_out, - - .vidioc_qbuf = mxc_jpeg_qbuf, - - .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, - .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, - .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, - .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, - .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, - .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, - .vidioc_streamon = v4l2_m2m_ioctl_streamon, - .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, -}; - -static int mxc_jpeg_release(struct file *file) -{ - struct mxc_jpeg_dev *mxc_jpeg = video_drvdata(file); - struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(file->private_data); - - mutex_lock(&mxc_jpeg->lock); - v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); - v4l2_fh_del(&ctx->fh); - v4l2_fh_exit(&ctx->fh); - kfree(ctx); - mutex_unlock(&mxc_jpeg->lock); - - pm_runtime_put_sync(mxc_jpeg->dev); - return 0; -} - -static const struct v4l2_file_operations mxc_jpeg_fops = { - .owner = THIS_MODULE, - .open = mxc_jpeg_open, - .release = mxc_jpeg_release, - .poll = v4l2_m2m_fop_poll, - .unlocked_ioctl = video_ioctl2, - .mmap = v4l2_m2m_fop_mmap, -}; -static struct v4l2_m2m_ops mxc_jpeg_m2m_ops = { - .device_run = mxc_jpeg_device_run, - .job_ready = mxc_jpeg_job_ready, - .job_abort = mxc_jpeg_job_abort, -}; - -static int mxc_jpeg_probe(struct platform_device *pdev) -{ - struct mxc_jpeg_dev *jpeg; - struct device *dev = &pdev->dev; - struct resource *res; - int dec_irq; - int ret; - int mode; - const struct of_device_id *of_id; - - of_id = of_match_node(mxc_jpeg_match, dev->of_node); - mode = (int)(u64) of_id->data; - - jpeg = devm_kzalloc(dev, sizeof(struct mxc_jpeg_dev), GFP_KERNEL); - if (!jpeg) - return -ENOMEM; - - mutex_init(&jpeg->lock); - spin_lock_init(&jpeg->hw_lock); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - dec_irq = platform_get_irq(pdev, 0); - if (!res || dec_irq < 0) { - dev_err(&pdev->dev, "Failed to get dec_irq %d.\n", dec_irq); - ret = -EINVAL; - goto err_irq; - } - ret = devm_request_irq(&pdev->dev, dec_irq, mxc_jpeg_dec_irq, 0, - pdev->name, jpeg); - if (ret) { - dev_err(&pdev->dev, "Failed to request dec_irq %d (%d)\n", - dec_irq, ret); - ret = -EINVAL; - goto err_irq; - } - jpeg->base_reg = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(jpeg->base_reg)) - return PTR_ERR(jpeg->base_reg); - - jpeg->pdev = pdev; - jpeg->dev = dev; - jpeg->mode = mode; - - /* Start clock */ - jpeg->clk_ipg = devm_clk_get(dev, "ipg"); - if (IS_ERR(jpeg->clk_ipg)) { - dev_err(dev, "failed to get clock: ipg\n"); - goto err_clk; - } - - jpeg->clk_per = devm_clk_get(dev, "per"); - if (IS_ERR(jpeg->clk_per)) { - dev_err(dev, "failed to get clock: per\n"); - goto err_clk; - } - - /* v4l2 */ - ret = v4l2_device_register(dev, &jpeg->v4l2_dev); - if (ret) { - dev_err(dev, "failed to register v4l2 device\n"); - goto err_register; - } - jpeg->m2m_dev = v4l2_m2m_init(&mxc_jpeg_m2m_ops); - if (IS_ERR(jpeg->m2m_dev)) { - dev_err(dev, "failed to register v4l2 device\n"); - goto err_m2m; - } - - jpeg->dec_vdev = video_device_alloc(); - if (!jpeg->dec_vdev) { - dev_err(dev, "failed to register v4l2 device\n"); - goto err_vdev_alloc; - } - if (mode == MXC_JPEG_ENCODE) - snprintf(jpeg->dec_vdev->name, - sizeof(jpeg->dec_vdev->name), - "%s-enc", MXC_JPEG_M2M_NAME); - else - snprintf(jpeg->dec_vdev->name, - sizeof(jpeg->dec_vdev->name), - "%s-dec", MXC_JPEG_M2M_NAME); - - jpeg->dec_vdev->fops = &mxc_jpeg_fops; - jpeg->dec_vdev->ioctl_ops = &mxc_jpeg_ioctl_ops; - jpeg->dec_vdev->minor = -1; - jpeg->dec_vdev->release = video_device_release; - jpeg->dec_vdev->lock = &jpeg->lock; - jpeg->dec_vdev->v4l2_dev = &jpeg->v4l2_dev; - jpeg->dec_vdev->vfl_dir = VFL_DIR_M2M; - jpeg->dec_vdev->device_caps = V4L2_CAP_STREAMING | - V4L2_CAP_VIDEO_M2M; - - ret = video_register_device(jpeg->dec_vdev, VFL_TYPE_GRABBER, -1); - if (ret) { - dev_err(dev, "failed to register video device\n"); - goto err_vdev_register; - } - video_set_drvdata(jpeg->dec_vdev, jpeg); - if (mode == MXC_JPEG_ENCODE) - v4l2_info(&jpeg->v4l2_dev, - "encoder device registered as /dev/video%d (%d,%d)\n", - jpeg->dec_vdev->num, VIDEO_MAJOR, - jpeg->dec_vdev->minor); - else - v4l2_info(&jpeg->v4l2_dev, - "decoder device registered as /dev/video%d (%d,%d)\n", - jpeg->dec_vdev->num, VIDEO_MAJOR, - jpeg->dec_vdev->minor); - - platform_set_drvdata(pdev, jpeg); - pm_runtime_enable(dev); - return 0; - -err_vdev_register: - video_device_release(jpeg->dec_vdev); - -err_vdev_alloc: - v4l2_m2m_release(jpeg->m2m_dev); - -err_m2m: - v4l2_device_unregister(&jpeg->v4l2_dev); - -err_register: -err_irq: -err_clk: - return ret; -} - -#ifdef CONFIG_PM -static int mxc_jpeg_runtime_resume(struct device *dev) -{ - struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev); - int ret; - - ret = clk_prepare_enable(jpeg->clk_ipg); - if (ret < 0) { - dev_err(dev, "failed to enable clock: ipg\n"); - goto err_clk; - } - - ret = clk_prepare_enable(jpeg->clk_per); - if (ret < 0) { - dev_err(dev, "failed to enable clock: per\n"); - goto err_clk; - } - - return 0; - -err_clk: - return ret; -} - -static int mxc_jpeg_runtime_suspend(struct device *dev) -{ - struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev); - - clk_disable_unprepare(jpeg->clk_ipg); - clk_disable_unprepare(jpeg->clk_per); - - return 0; -} -#endif - -static const struct dev_pm_ops mxc_jpeg_pm_ops = { - SET_RUNTIME_PM_OPS(mxc_jpeg_runtime_suspend, - mxc_jpeg_runtime_resume, NULL) -}; - -static int mxc_jpeg_remove(struct platform_device *pdev) -{ - struct mxc_jpeg_dev *jpeg = platform_get_drvdata(pdev); - - pm_runtime_disable(&pdev->dev); - video_unregister_device(jpeg->dec_vdev); - video_device_release(jpeg->dec_vdev); - v4l2_m2m_release(jpeg->m2m_dev); - v4l2_device_unregister(&jpeg->v4l2_dev); - return 0; -} - -MODULE_DEVICE_TABLE(of, mxc_jpeg_match); - -static struct platform_driver mxc_jpeg_driver = { - .probe = mxc_jpeg_probe, - .remove = mxc_jpeg_remove, - .driver = { - .name = "mxc-jpeg", - .of_match_table = mxc_jpeg_match, - .pm = &mxc_jpeg_pm_ops, - }, -}; -module_platform_driver(mxc_jpeg_driver); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/media/platform/imx8/mxc-jpeg.h b/drivers/media/platform/imx8/mxc-jpeg.h deleted file mode 100644 index 79cbed0b23ec9506169fb7954c31e7dd0bf7f687..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-jpeg.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include -#include -#include - -#ifndef _MXC_JPEG_CORE_H -#define _MXC_JPEG_CORE_H - -#define MXC_JPEG_M2M_NAME "mxc-jpeg" -#define MXC_JPEG_NAME "mxc-jpeg" -#define MXC_IN_FORMAT 0 -#define MXC_OUT_FORMAT 1 -#define MXC_JPEG_INIT 0 -#define MXC_JPEG_RUNNING 1 -#define MXC_JPEG_FMT_TYPE_ENC 0 -#define MXC_JPEG_FMT_TYPE_RAW 1 -#define MXC_JPEG_NUM_FORMATS 4 -#define MXC_JPEG_MIN_HEIGHT 0x8 -#define MXC_JPEG_MIN_WIDTH 0x8 -#define MXC_JPEG_MAX_HEIGHT 0x2000 -#define MXC_JPEG_MAX_WIDTH 0x2000 -#define MXC_JPEG_DEFAULT_SIZEIMAGE 10000 -#define MXC_JPEG_DECODE 0 -#define MXC_JPEG_ENCODE 1 -#define MXC_JPEG_ENC_CONF 1 -#define MXC_JPEG_ENC_DONE 0 -#define SOF0 0xC0 -#define SOF2 0xC2 -#define MXC_JPEG_ENC_CONF_DONE 1 - - -/** - * struct jpeg_fmt - driver's internal color format data - * @name: format description - * @fourcc: fourcc code, 0 if not applicable - * @depth: number of bits per pixel - * @colplanes: number of color planes (1 for packed formats) - * @h_align: horizontal alignment order (align to 2^h_align) - * @v_align: vertical alignment order (align to 2^v_align) - * @flags: flags describing format applicability - */ -struct mxc_jpeg_fmt { - char *name; - u32 fourcc; - int depth; - int colplanes; - int memplanes; - int h_align; - int v_align; - int subsampling; - u32 flags; -}; -struct mxc_jpeg_desc { - u32 next_descpt_ptr; - u32 buf_base0; - u32 buf_base1; - u32 line_pitch; - u32 stm_bufbase; - u32 stm_bufsize; - u16 w; - u16 h; - u32 stm_ctrl; -} __packed; - -struct mxc_jpeg_q_data { - struct mxc_jpeg_fmt *fmt; - u32 sizeimage[1]; - u32 bytesperline[2]; - int w; - int h; - u32 stride; -}; -struct mxc_jpeg_ctx { - struct mxc_jpeg_dev *mxc_jpeg; - struct mxc_jpeg_q_data out_q; - struct mxc_jpeg_q_data cap_q; - struct v4l2_rect crop_rect; - unsigned long state; - struct v4l2_fh fh; - unsigned int mode; - unsigned int enc_state; -}; - -struct mxc_jpeg_dev { - spinlock_t hw_lock; - unsigned int mode; - struct mutex lock; - struct mutex lock2; - //wait_queue_head_t irq_queue; - bool enc; - bool dec; - struct clk *clk_ipg; - struct clk *clk_per; - struct platform_device *pdev; - struct device *dev; - void __iomem *base_reg; - void __iomem *enc_reg; - struct v4l2_device v4l2_dev; - struct v4l2_m2m_dev *m2m_dev; - struct video_device *dec_vdev; - unsigned int irq; - int id; - - struct mxc_jpeg_desc *cfg_desc; - dma_addr_t cfg_handle; -}; -#endif diff --git a/drivers/media/platform/imx8/mxc-media-dev.c b/drivers/media/platform/imx8/mxc-media-dev.c deleted file mode 100644 index 5fd4d609f75c99c69770f4078b928f6aa8d05419..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-media-dev.c +++ /dev/null @@ -1,604 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mxc-media-dev.h" -#include "mxc-isi-core.h" -#include "mxc-mipi-csi2.h" - -/*create default links between registered entities */ -static int mxc_md_create_links(struct mxc_md *mxc_md) -{ - struct media_entity *source, *sink; - struct mxc_isi_dev *mxc_isi; - struct mxc_sensor_info *sensor; - struct mxc_mipi_csi2_dev *mipi_csi2; - int i, j, ret = 0; - u16 source_pad, sink_pad; - u32 flags; - u32 mipi_vc = 0; - - /* Create links between each ISI's subdev and video node */ - flags = MEDIA_LNK_FL_ENABLED; - for (i = 0; i < MXC_ISI_MAX_DEVS; i++) { - mxc_isi = mxc_md->mxc_isi[i]; - if (!mxc_isi) - continue; - - /* Connect ISI source to video device */ - source = &mxc_isi->isi_cap.sd.entity; - sink = &mxc_isi->isi_cap.vdev.entity; - sink_pad = 0; - - switch (mxc_isi->interface[OUT_PORT]) { - case ISI_OUTPUT_INTERFACE_DC0: - source_pad = MXC_ISI_SD_PAD_SOURCE_DC0; - break; - case ISI_OUTPUT_INTERFACE_DC1: - source_pad = MXC_ISI_SD_PAD_SOURCE_DC1; - break; - case ISI_OUTPUT_INTERFACE_MEM: - source_pad = MXC_ISI_SD_PAD_SOURCE_MEM; - break; - default: - v4l2_err(&mxc_md->v4l2_dev, "Wrong output interface: %x\n", - mxc_isi->interface[OUT_PORT]); - return -EINVAL; - } - - ret = media_create_pad_link(source, source_pad, - sink, sink_pad, flags); - if (ret) { - v4l2_err(&mxc_md->v4l2_dev, "Failed created link [%s] %c> [%s]\n", - source->name, flags ? '=' : '-', sink->name); - break; - } - - /* Notify capture subdev entity ,ISI cap link setup */ - ret = media_entity_call(source, link_setup, &source->pads[source_pad], - &sink->pads[sink_pad], flags); - if (ret) { - v4l2_err(&mxc_md->v4l2_dev, "failed call link_setup [%s] %c> [%s]\n", - source->name, flags ? '=' : '-', sink->name); - break; - } - - v4l2_info(&mxc_md->v4l2_dev, "created link [%s] %c> [%s]\n", - source->name, flags ? '=' : '-', sink->name); - - /* Connect MIPI/HDMI/Mem source to ISI sink */ - sink = &mxc_isi->isi_cap.sd.entity; - - switch (mxc_isi->interface[IN_PORT]) { - - case ISI_INPUT_INTERFACE_MIPI0_CSI2: - if (mxc_md->mipi_csi2[0] == NULL) - continue; - source = &mxc_md->mipi_csi2[0]->sd.entity; - - switch (mxc_isi->interface[SUB_IN_PORT]) { - case ISI_INPUT_SUB_INTERFACE_VC1: - source_pad = MXC_MIPI_CSI2_VC1_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI0_VC1; - break; - case ISI_INPUT_SUB_INTERFACE_VC2: - source_pad = MXC_MIPI_CSI2_VC2_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI0_VC2; - break; - case ISI_INPUT_SUB_INTERFACE_VC3: - source_pad = MXC_MIPI_CSI2_VC3_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI0_VC3; - break; - default: - source_pad = MXC_MIPI_CSI2_VC0_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI0_VC0; - break; - } - break; - - case ISI_INPUT_INTERFACE_MIPI1_CSI2: - if (mxc_md->mipi_csi2[1] == NULL) - continue; - source = &mxc_md->mipi_csi2[1]->sd.entity; - - switch (mxc_isi->interface[SUB_IN_PORT]) { - case ISI_INPUT_SUB_INTERFACE_VC1: - source_pad = MXC_MIPI_CSI2_VC1_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI1_VC1; - break; - case ISI_INPUT_SUB_INTERFACE_VC2: - source_pad = MXC_MIPI_CSI2_VC2_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI1_VC2; - break; - case ISI_INPUT_SUB_INTERFACE_VC3: - source_pad = MXC_MIPI_CSI2_VC3_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI1_VC3; - break; - default: - source_pad = MXC_MIPI_CSI2_VC0_PAD_SOURCE; - sink_pad = MXC_ISI_SD_PAD_SINK_MIPI1_VC0; - break; - } - break; - - case ISI_INPUT_INTERFACE_HDMI: - case ISI_INPUT_INTERFACE_DC0: - case ISI_INPUT_INTERFACE_DC1: - case ISI_INPUT_INTERFACE_MEM: - default: - v4l2_err(&mxc_md->v4l2_dev, "Not support input interface: %x\n", - mxc_isi->interface[IN_PORT]); - return -EINVAL; - } - /* Create link MIPI/HDMI to ISI */ - ret = media_create_pad_link(source, source_pad, sink, sink_pad, flags); - if (ret) { - v4l2_err(&mxc_md->v4l2_dev, "created link [%s] %c> [%s]\n", - source->name, flags ? '=' : '-', sink->name); - break; - } - - /* Notify ISI subdev entity */ - ret = media_entity_call(sink, link_setup, &sink->pads[sink_pad], - &source->pads[source_pad], 0); - if (ret) - break; - - /* Notify MIPI/HDMI entity */ - ret = media_entity_call(source, link_setup, &source->pads[source_pad], - &sink->pads[sink_pad], 0); - if (ret) - break; - - v4l2_info(&mxc_md->v4l2_dev, "created link [%s] %c> [%s]\n", - source->name, flags ? '=' : '-', sink->name); - } - - /* Connect MIPI Sensor to MIPI CSI2 */ - for (i = 0; i < mxc_md->num_sensors; i++) { - sensor = &mxc_md->sensor[i]; - if (sensor == NULL || sensor->sd == NULL) - continue; - - mipi_csi2 = mxc_md->mipi_csi2[sensor->id]; - if (mipi_csi2 == NULL) - continue; - - source = &sensor->sd->entity; - sink = &mipi_csi2->sd.entity; - - source_pad = 0; //sensor source pad: MIPI_CSI2_SENS_VC0_PAD_SOURCE - sink_pad = source_pad; //mipi sink pad: MXC_MIPI_CSI2_VC0_PAD_SINK; - - if (mipi_csi2->vchannel == true) - mipi_vc = 4; - else - mipi_vc = 0; - - for (j = 0; j < mipi_vc; j++) { - ret = media_create_pad_link(source, source_pad + j, sink, sink_pad + j, - MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); - if (ret) - return ret; - - /* Notify MIPI subdev entity */ - ret = media_entity_call(sink, link_setup, &sink->pads[sink_pad + j], - &source->pads[source_pad + j], 0); - if (ret) - return ret; - - /* Notify MIPI sensor subdev entity */ - ret = media_entity_call(source, link_setup, &source->pads[source_pad + j], - &sink->pads[sink_pad + j], 0); - if (ret) - return ret; - } - - v4l2_info(&mxc_md->v4l2_dev, "created link [%s] => [%s]\n", - sensor->sd->entity.name, mipi_csi2->sd.entity.name); - } - - /* TODO */ - /* Notify HDMI IN / DC0 / DC1 subdev entity */ - return 0; -} - -static int subdev_notifier_bound(struct v4l2_async_notifier *notifier, - struct v4l2_subdev *sd, - struct v4l2_async_subdev *asd) -{ - struct mxc_md *mxc_md = notifier_to_mxc_md(notifier); - struct mxc_sensor_info *sensor = NULL; - int i; - - /* Find platform data for this sensor subdev */ - for (i = 0; i < ARRAY_SIZE(mxc_md->sensor); i++) { - if (mxc_md->sensor[i].asd.match.fwnode == of_fwnode_handle(sd->dev->of_node)) - sensor = &mxc_md->sensor[i]; - } - - if (sensor == NULL) - return -EINVAL; - - sd->grp_id = GRP_ID_MXC_SENSOR; - - sensor->sd = sd; - - mxc_md->num_sensors++; - - v4l2_info(&mxc_md->v4l2_dev, "Registered sensor subdevice: %s (%d)\n", - sd->name, mxc_md->num_sensors); - - return 0; -} - -static int subdev_notifier_complete(struct v4l2_async_notifier *notifier) -{ - struct mxc_md *mxc_md = notifier_to_mxc_md(notifier); - int ret; - - mutex_lock(&mxc_md->media_dev.graph_mutex); - - ret = mxc_md_create_links(mxc_md); - if (ret < 0) - goto unlock; - - ret = v4l2_device_register_subdev_nodes(&mxc_md->v4l2_dev); -unlock: - mutex_unlock(&mxc_md->media_dev.graph_mutex); - if (ret < 0) { - v4l2_err(&mxc_md->v4l2_dev, "%s error exit\n", __func__); - return ret; - } - - return media_device_register(&mxc_md->media_dev); -} - - -/** - * mxc_sensor_notify - v4l2_device notification from a sensor subdev - */ -void mxc_sensor_notify(struct v4l2_subdev *sd, unsigned int notification, - void *arg) -{ - return; -} - -/* Register mipi sensor sub-devices */ -static int register_sensor_entities(struct mxc_md *mxc_md) -{ - struct device_node *parent = mxc_md->pdev->dev.of_node; - struct device_node *node, *ep, *rem; - struct v4l2_fwnode_endpoint endpoint; - int index = 0; - - mxc_md->num_sensors = 0; - - /* Attach sensors linked to MIPI CSI2 */ - for_each_available_child_of_node(parent, node) { - struct device_node *port; - - if (of_node_cmp(node->name, "csi")) - continue; - /* csi2 node have only port */ - port = of_get_next_child(node, NULL); - if (!port) - continue; - - /* port can have only endpoint */ - ep = of_get_next_child(port, NULL); - if (!ep) - return -EINVAL; - - v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &endpoint); - if (WARN_ON(endpoint.base.port >= MXC_MAX_MIPI_SENSORS)) { - v4l2_err(&mxc_md->v4l2_dev, "Failed to get sensor endpoint\n"); - return -EINVAL; - } - - mxc_md->sensor[index].id = endpoint.base.port; - - /* remote port---sensor node */ - rem = of_graph_get_remote_port_parent(ep); - of_node_put(ep); - if (rem == NULL) { - v4l2_info(&mxc_md->v4l2_dev, "Remote device at %s not found\n", - ep->full_name); - continue; - } - - mxc_md->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE; - mxc_md->sensor[index].asd.match.fwnode = of_fwnode_handle(rem); - mxc_md->async_subdevs[index] = &mxc_md->sensor[index].asd; - - mxc_md->num_sensors++; - - index++; - } - - return 0; -} - -static int register_isi_entity(struct mxc_md *mxc_md, struct mxc_isi_dev *mxc_isi) -{ - struct v4l2_subdev *sd = &mxc_isi->isi_cap.sd; - int ret; - - if (WARN_ON(mxc_isi->id >= MXC_ISI_MAX_DEVS || mxc_md->mxc_isi[mxc_isi->id])) - return -EBUSY; - - sd->grp_id = GRP_ID_MXC_ISI; - - ret = v4l2_device_register_subdev(&mxc_md->v4l2_dev, sd); - if (!ret) - mxc_md->mxc_isi[mxc_isi->id] = mxc_isi; - else - v4l2_err(&mxc_md->v4l2_dev, "Failed to register ISI.%d (%d)\n", - mxc_isi->id, ret); - return ret; -} - -static int register_mipi_csi2_entity(struct mxc_md *mxc_md, - struct mxc_mipi_csi2_dev *mipi_csi2) -{ - struct v4l2_subdev *sd = &mipi_csi2->sd; - int ret; - - if (WARN_ON(mipi_csi2->id >= MXC_MIPI_CSI2_MAX_DEVS)) - return -ENOENT; - - sd->grp_id = GRP_ID_MXC_MIPI_CSI2; - ret = v4l2_device_register_subdev(&mxc_md->v4l2_dev, sd); - if (!ret) - mxc_md->mipi_csi2[mipi_csi2->id] = mipi_csi2; - else - v4l2_err(&mxc_md->v4l2_dev, - "Failed to register MIPI-CSIS.%d (%d)\n", mipi_csi2->id, ret); - return ret; -} - -static int mxc_md_register_platform_entity(struct mxc_md *mxc_md, - struct platform_device *pdev, - int plat_entity) -{ - struct device *dev = &pdev->dev; - int ret = -EPROBE_DEFER; - void *drvdata; - - /* Lock to ensure dev->driver won't change. */ - device_lock(dev); - - if (!dev->driver || !try_module_get(dev->driver->owner)) - goto dev_unlock; - - drvdata = dev_get_drvdata(dev); - /* Some subdev didn't probe successfully id drvdata is NULL */ - if (drvdata) { - switch (plat_entity) { - case IDX_ISI: - ret = register_isi_entity(mxc_md, drvdata); - break; - case IDX_MIPI_CSI2: - ret = register_mipi_csi2_entity(mxc_md, drvdata); - break; - default: - ret = -ENODEV; - } - } - module_put(dev->driver->owner); - -dev_unlock: - device_unlock(dev); - if (ret == -EPROBE_DEFER) - dev_info(&mxc_md->pdev->dev, "deferring %s device registration\n", - dev_name(dev)); - else if (ret < 0) - dev_err(&mxc_md->pdev->dev, "%s device registration failed (%d)\n", - dev_name(dev), ret); - - return ret; -} - -/* Register ISI, MIPI CSI2 and HDMI In Media entities */ -static int mxc_md_register_platform_entities(struct mxc_md *mxc_md, - struct device_node *parent) -{ - struct device_node *node; - int ret = 0; - - for_each_available_child_of_node(parent, node) { - struct platform_device *pdev; - int plat_entity = -1; - - pdev = of_find_device_by_node(node); - if (!pdev) - continue; - - /* If driver of any entity isn't ready try all again later. */ - if (!strcmp(node->name, ISI_OF_NODE_NAME)) - plat_entity = IDX_ISI; - else if (!strcmp(node->name, MIPI_CSI2_OF_NODE_NAME)) - plat_entity = IDX_MIPI_CSI2; - - if (plat_entity >= 0) - ret = mxc_md_register_platform_entity(mxc_md, pdev, - plat_entity); - put_device(&pdev->dev); - if (ret < 0) - break; - } - - return ret; -} - -static void mxc_md_unregister_entities(struct mxc_md *mxc_md) -{ - int i; - - for (i = 0; i < MXC_ISI_MAX_DEVS; i++) { - struct mxc_isi_dev *dev = mxc_md->mxc_isi[i]; - if (dev == NULL) - continue; - v4l2_device_unregister_subdev(&dev->isi_cap.sd); - mxc_md->mxc_isi[i] = NULL; - } - for (i = 0; i < MXC_MIPI_CSI2_MAX_DEVS; i++) { - if (mxc_md->mipi_csi2[i] == NULL) - continue; - v4l2_device_unregister_subdev(&mxc_md->mipi_csi2[i]->sd); - mxc_md->mipi_csi2[i] = NULL; - } - - v4l2_info(&mxc_md->v4l2_dev, "Unregistered all entities\n"); -} - -static int mxc_md_link_notify(struct media_link *link, unsigned int flags, - unsigned int notification) -{ - return 0; -} - -static const struct media_device_ops mxc_md_ops = { - .link_notify = mxc_md_link_notify, -}; - -static const struct v4l2_async_notifier_operations subdev_notifier_ops = { - .bound = subdev_notifier_bound, - .complete = subdev_notifier_complete, -}; - -static int mxc_md_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct v4l2_device *v4l2_dev; - struct mxc_md *mxc_md; - int ret; - - mxc_md = devm_kzalloc(dev, sizeof(*mxc_md), GFP_KERNEL); - if (!mxc_md) - return -ENOMEM; - - mxc_md->pdev = pdev; - platform_set_drvdata(pdev, mxc_md); - - /* register media device */ - strlcpy(mxc_md->media_dev.model, "FSL Capture Media Deivce", - sizeof(mxc_md->media_dev.model)); - mxc_md->media_dev.ops = &mxc_md_ops; - mxc_md->media_dev.dev = dev; - - /* register v4l2 device */ - v4l2_dev = &mxc_md->v4l2_dev; - v4l2_dev->mdev = &mxc_md->media_dev; - v4l2_dev->notify = mxc_sensor_notify; - strlcpy(v4l2_dev->name, "mx8-img-md", sizeof(v4l2_dev->name)); - - media_device_init(&mxc_md->media_dev); - - ret = v4l2_device_register(dev, &mxc_md->v4l2_dev); - if (ret < 0) { - v4l2_err(v4l2_dev, "Failed to register v4l2_device: %d\n", ret); - goto err_md; - } - - ret = mxc_md_register_platform_entities(mxc_md, dev->of_node); - if (ret < 0) - goto err_v4l2_dev; - - ret = register_sensor_entities(mxc_md); - if (ret < 0) - goto err_m_ent; - - if (mxc_md->num_sensors > 0) { - mxc_md->subdev_notifier.subdevs = mxc_md->async_subdevs; - mxc_md->subdev_notifier.num_subdevs = mxc_md->num_sensors; - mxc_md->subdev_notifier.ops = &subdev_notifier_ops; - mxc_md->num_sensors = 0; - - ret = v4l2_async_notifier_register(&mxc_md->v4l2_dev, - &mxc_md->subdev_notifier); - if (ret < 0) { - printk("Sensor register failed\n"); - goto err_m_ent; - } - } - - return 0; - -err_m_ent: - mxc_md_unregister_entities(mxc_md); -err_v4l2_dev: - v4l2_device_unregister(&mxc_md->v4l2_dev); -err_md: - media_device_cleanup(&mxc_md->media_dev); - return ret; -} - -static int mxc_md_remove(struct platform_device *pdev) -{ - struct mxc_md *mxc_md = platform_get_drvdata(pdev); - - if (!mxc_md) - return 0; - - v4l2_async_notifier_unregister(&mxc_md->subdev_notifier); - - v4l2_device_unregister(&mxc_md->v4l2_dev); - mxc_md_unregister_entities(mxc_md); - media_device_unregister(&mxc_md->media_dev); - media_device_cleanup(&mxc_md->media_dev); - - return 0; -} - -static const struct of_device_id mxc_md_of_match[] = { - { .compatible = "fsl,mxc-md",}, - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(of, mxc_md_of_match); - - -static struct platform_driver mxc_md_driver = { - .driver = { - .name = MXC_MD_DRIVER_NAME, - .of_match_table = mxc_md_of_match, - }, - .probe = mxc_md_probe, - .remove = mxc_md_remove, -}; - -module_platform_driver(mxc_md_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("MXC Media Device driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:" MXC_MD_DRIVER_NAME); diff --git a/drivers/media/platform/imx8/mxc-media-dev.h b/drivers/media/platform/imx8/mxc-media-dev.h deleted file mode 100644 index a0665599c81f5f56a5a5b1e09ac264ec5389fbff..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-media-dev.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#ifndef MXC_MEDIA_DEV_H_ -#define MXC_MEDIA_DEV_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mxc-mipi-csi2.h" -#include "mxc-isi-core.h" -#include "mxc-isi-hw.h" - -#define MXC_MD_DRIVER_NAME "mxc-md" -#define MXC_MAX_MIPI_SENSORS 2 - -#define MJPEG_DEC_OF_NODE_NAME "jpegdec" -#define MJPEG_ENC_OF_NODE_NAME "jpegenc" - -/* - * The subdevices' group IDs. - */ -#define GRP_ID_MXC_SENSOR (1 << 8) -#define GRP_ID_MXC_ISI (1 << 9) -#define GRP_ID_MXC_MIPI_CSI2 (1 << 11) -#define GRP_ID_MXC_HDMI_IN (1 << 12) -#define GRP_ID_MXC_MJPEG_DEC (1 << 13) -#define GRP_ID_MXC_MJPEG_ENC (1 << 14) - -enum mxc_subdev_index { - IDX_SENSOR, - IDX_ISI, - IDX_MIPI_CSI2, - IDX_HDMI_IN, - IDX_MJPEG_ENC, - IDX_MJPEG_DEC, - IDX_MAX, -}; - -struct mxc_sensor_info { - int id; - struct v4l2_subdev *sd; - struct v4l2_async_subdev asd; -// struct mxc_isi_dev *host; -}; - -struct mxc_mjpeg_dec{ - struct v4l2_device *v4l2_dev; - struct v4l2_subdev sd; -}; - -struct mxc_mjpeg_enc{ - struct v4l2_device *v4l2_dev; - struct v4l2_subdev sd; -}; - -struct mxc_md { - struct mxc_isi_dev *mxc_isi[MXC_ISI_MAX_DEVS]; - struct mxc_hdmi_in_dev *hdmi_in; - struct mxc_mipi_csi2_dev *mipi_csi2[MXC_MIPI_CSI2_MAX_DEVS]; - struct mxc_sensor_info sensor[MXC_MAX_MIPI_SENSORS]; - struct mxc_mjpeg_dec *mjpeg_dec; - struct mxc_mjpeg_enc *mjpeg_enc; - - int num_sensors; - - struct media_device media_dev; - struct v4l2_device v4l2_dev; - struct platform_device *pdev; - - struct v4l2_async_notifier subdev_notifier; - struct v4l2_async_subdev *async_subdevs[MXC_MAX_MIPI_SENSORS]; -}; - -static inline struct mxc_md *notifier_to_mxc_md(struct v4l2_async_notifier *n) -{ - return container_of(n, struct mxc_md, subdev_notifier); -}; - -int mxc_isi_initialize_capture_subdev(struct mxc_isi_dev *mxc_isi); -void mxc_isi_unregister_capture_subdev(struct mxc_isi_dev *mxc_isi); -int mxc_isi_register_m2m_device(struct mxc_isi_dev *mxc_isi, - struct v4l2_device *v4l2_dev); -void mxc_sensor_notify(struct v4l2_subdev *sd, unsigned int notification, - void *arg); -void mxc_isi_unregister_m2m_device(struct mxc_isi_dev *mxc_isi); -int mxc_isi_register_driver(void); -void mxc_isi_unregister_driver(void); -#endif diff --git a/drivers/media/platform/imx8/mxc-mipi-csi2.c b/drivers/media/platform/imx8/mxc-mipi-csi2.c deleted file mode 100644 index c09c24ab19bd3afdceb1f3d623b84d3be2d1d029..0000000000000000000000000000000000000000 --- a/drivers/media/platform/imx8/mxc-mipi-csi2.c +++ /dev/null @@ -1,754 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mxc-mipi-csi2.h" -static int debug; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Debug level (0-2)"); - -/* 0~ 80Mbps: 0xB - * 80~250Mbps: 0x8 - * 250~1.5Gbps: 0x6*/ -static u8 rxhs_settle[3] = {0xB, 0x8, 0x6}; - -static struct mxc_mipi_csi2_dev *sd_to_mxc_mipi_csi2_dev(struct v4l2_subdev *sdev) -{ - return container_of(sdev, struct mxc_mipi_csi2_dev, sd); -} - -/**************************************** - * rxhs-settle calculate - * UI = 1000 / mipi csi phy clock - * THS-SETTLE_mim = 85ns + 6 * UI - * THS-SETTLE_max = 145ns +10 * UI - * PRG_RXHS_SETTLE = THS-SETTLE / (Tperiod of RxClk_ESC) + 1 - ****************************************/ -static int calc_hs_settle(struct mxc_mipi_csi2_dev *csi2dev, u32 dphy_clk) -{ - u32 esc_rate; - u32 hs_settle; - u32 rxhs_settle; - - esc_rate = clk_get_rate(csi2dev->clk_esc) / 1000000; - hs_settle = 115 + 8 * 1000 / dphy_clk; - rxhs_settle = hs_settle / (1000 / esc_rate) - 1; - return rxhs_settle; -} - -#ifdef debug -static void mxc_mipi_csi2_reg_dump(struct mxc_mipi_csi2_dev *csi2dev) -{ - printk("MIPI CSI2 HC register dump, mipi csi%d\n", csi2dev->id); - printk("MIPI CSI2 HC num of lanes 0x100 = 0x%x\n", readl(csi2dev->base_regs + 0x100)); - printk("MIPI CSI2 HC dis lanes 0x104 = 0x%x\n", readl(csi2dev->base_regs + 0x104)); - printk("MIPI CSI2 HC BIT ERR 0x108 = 0x%x\n", readl(csi2dev->base_regs + 0x108)); - printk("MIPI CSI2 HC IRQ STATUS 0x10C = 0x%x\n", readl(csi2dev->base_regs + 0x10C)); - printk("MIPI CSI2 HC IRQ MASK 0x110 = 0x%x\n", readl(csi2dev->base_regs + 0x110)); - printk("MIPI CSI2 HC ULPS STATUS 0x114 = 0x%x\n", readl(csi2dev->base_regs + 0x114)); - printk("MIPI CSI2 HC DPHY ErrSotHS 0x118 = 0x%x\n", readl(csi2dev->base_regs + 0x118)); - printk("MIPI CSI2 HC DPHY ErrSotSync 0x11c = 0x%x\n", readl(csi2dev->base_regs + 0x11c)); - printk("MIPI CSI2 HC DPHY ErrEsc 0x120 = 0x%x\n", readl(csi2dev->base_regs + 0x120)); - printk("MIPI CSI2 HC DPHY ErrSyncEsc 0x124 = 0x%x\n", readl(csi2dev->base_regs + 0x124)); - printk("MIPI CSI2 HC DPHY ErrControl 0x128 = 0x%x\n", readl(csi2dev->base_regs + 0x128)); - printk("MIPI CSI2 HC DISABLE_PAYLOAD 0x12C = 0x%x\n", readl(csi2dev->base_regs + 0x12C)); - printk("MIPI CSI2 HC DISABLE_PAYLOAD 0x130 = 0x%x\n", readl(csi2dev->base_regs + 0x130)); - printk("MIPI CSI2 HC IGNORE_VC 0x180 = 0x%x\n", readl(csi2dev->base_regs + 0x180)); - printk("MIPI CSI2 HC VID_VC 0x184 = 0x%x\n", readl(csi2dev->base_regs + 0x184)); - printk("MIPI CSI2 HC FIFO_SEND_LEVEL 0x188 = 0x%x\n", readl(csi2dev->base_regs + 0x188)); - printk("MIPI CSI2 HC VID_VSYNC 0x18C = 0x%x\n", readl(csi2dev->base_regs + 0x18C)); - printk("MIPI CSI2 HC VID_SYNC_FP 0x190 = 0x%x\n", readl(csi2dev->base_regs + 0x190)); - printk("MIPI CSI2 HC VID_HSYNC 0x194 = 0x%x\n", readl(csi2dev->base_regs + 0x194)); - printk("MIPI CSI2 HC VID_HSYNC_BP 0x198 = 0x%x\n", readl(csi2dev->base_regs + 0x198)); - printk("MIPI CSI2 CSR register dump\n"); - printk("MIPI CSI2 CSR PLM_CTRL 0x000 = 0x%x\n", readl(csi2dev->csr_regs + 0x000)); - printk("MIPI CSI2 CSR PHY_CTRL 0x004 = 0x%x\n", readl(csi2dev->csr_regs + 0x004)); - printk("MIPI CSI2 CSR PHY_Status 0x008 = 0x%x\n", readl(csi2dev->csr_regs + 0x008)); - printk("MIPI CSI2 CSR PHY_Test_Status 0x010 = 0x%x\n", readl(csi2dev->csr_regs + 0x010)); - printk("MIPI CSI2 CSR PHY_Test_Status 0x014 = 0x%x\n", readl(csi2dev->csr_regs + 0x014)); - printk("MIPI CSI2 CSR PHY_Test_Status 0x018 = 0x%x\n", readl(csi2dev->csr_regs + 0x018)); - printk("MIPI CSI2 CSR PHY_Test_Status 0x01C = 0x%x\n", readl(csi2dev->csr_regs + 0x01C)); - printk("MIPI CSI2 CSR PHY_Test_Status 0x020 = 0x%x\n", readl(csi2dev->csr_regs + 0x020)); - printk("MIPI CSI2 CSR VC Interlaced 0x030 = 0x%x\n", readl(csi2dev->csr_regs + 0x030)); - printk("MIPI CSI2 CSR Data Type Dis 0x038 = 0x%x\n", readl(csi2dev->csr_regs + 0x038)); - printk("MIPI CSI2 CSR 420 1st type 0x040 = 0x%x\n", readl(csi2dev->csr_regs + 0x040)); - printk("MIPI CSI2 CSR Ctr_Ck_Rst_Ctr 0x044 = 0x%x\n", readl(csi2dev->csr_regs + 0x044)); - printk("MIPI CSI2 CSR Stream Fencing 0x048 = 0x%x\n", readl(csi2dev->csr_regs + 0x048)); - printk("MIPI CSI2 CSR Stream Fencing 0x04C = 0x%x\n", readl(csi2dev->csr_regs + 0x04C)); -} -#else -static void mxc_mipi_csi2_reg_dump(struct mxc_mipi_csi2_dev *csi2dev) -{ -} -#endif - -static void mipi_sc_fw_init(struct mxc_mipi_csi2_dev *csi2dev, char enable) -{ - sc_ipc_t ipcHndl; - sc_err_t sciErr; - sc_rsrc_t rsrc_id; - uint32_t mu_id; - - sciErr = sc_ipc_getMuID(&mu_id); - if (sciErr != SC_ERR_NONE) { - pr_err("Cannot obtain MU ID\n"); - return; - } - - sciErr = sc_ipc_open(&ipcHndl, mu_id); - if (sciErr != SC_ERR_NONE) { - pr_err("sc_ipc_open failed! (sciError = %d)\n", sciErr); - return; - } - - if (csi2dev->id == 1) - rsrc_id = SC_R_CSI_1; - else - rsrc_id = SC_R_CSI_0; - - sciErr = sc_misc_set_control(ipcHndl, rsrc_id, SC_C_MIPI_RESET, enable); - if (sciErr != SC_ERR_NONE) - pr_err("sc_misc_MIPI reset failed! (sciError = %d)\n", sciErr); - - msleep(10); - - sc_ipc_close(mu_id); -} - -static void mxc_mipi_csi2_reset(struct mxc_mipi_csi2_dev *csi2dev) -{ - u32 val; - - /* Reset MIPI CSI */ - val = CSI2SS_CTRL_CLK_RESET_EN | CSI2SS_CTRL_CLK_RESET_CLK_OFF; - writel(val, csi2dev->csr_regs + CSI2SS_CTRL_CLK_RESET); -} - -static void mxc_mipi_csi2_enable(struct mxc_mipi_csi2_dev *csi2dev) -{ - u32 val = 0; - - val = readl(csi2dev->csr_regs + CSI2SS_PLM_CTRL); - while (val & CSI2SS_PLM_CTRL_PL_CLK_RUN) { - msleep(10); - val = readl(csi2dev->csr_regs + CSI2SS_PLM_CTRL); - printk("Waiting pl clk running, val=0x%x\n", val); - } - - /* Enable Pixel link Master*/ - val = readl(csi2dev->csr_regs + CSI2SS_PLM_CTRL); - val |= CSI2SS_PLM_CTRL_ENABLE_PL; - writel(val, csi2dev->csr_regs + CSI2SS_PLM_CTRL); - - val |= CSI2SS_PLM_CTRL_VALID_OVERRIDE; - writel(val, csi2dev->csr_regs + CSI2SS_PLM_CTRL); - - /* PHY Enable */ - val = readl(csi2dev->csr_regs + CSI2SS_PHY_CTRL); - val &= ~(CSI2SS_PHY_CTRL_PD_MASK | CSI2SS_PLM_CTRL_POLARITY_MASK); - writel(val, csi2dev->csr_regs + CSI2SS_PHY_CTRL); - - /* Deassert reset */ - writel(1, csi2dev->csr_regs + CSI2SS_CTRL_CLK_RESET); -} - -static void mxc_mipi_csi2_disable(struct mxc_mipi_csi2_dev *csi2dev) -{ - /* Disable Data lanes */ - writel(0xf, csi2dev->base_regs + CSI2RX_CFG_DISABLE_DATA_LANES); - - /* Disable Pixel Link */ - writel(0, csi2dev->csr_regs + CSI2SS_PLM_CTRL); - - /* Disable PHY */ - writel(0, csi2dev->csr_regs + CSI2SS_PHY_CTRL); - - /* Reset */ - writel(2, csi2dev->csr_regs + CSI2SS_CTRL_CLK_RESET); -} - -static void mxc_mipi_csi2_csr_config(struct mxc_mipi_csi2_dev *csi2dev) -{ - u32 val; - - /* format */ - val = 0; - writel(val, csi2dev->csr_regs + CSI2SS_DATA_TYPE); - - /* polarity */ - val = readl(csi2dev->csr_regs + CSI2SS_PLM_CTRL); - val &= ~(CSI2SS_PLM_CTRL_VSYNC_OVERRIDE | - CSI2SS_PLM_CTRL_HSYNC_OVERRIDE | - CSI2SS_PLM_CTRL_VALID_OVERRIDE | - CSI2SS_PLM_CTRL_POLARITY_MASK); - - writel(val, csi2dev->csr_regs + CSI2SS_PLM_CTRL); - - val = CSI2SS_PHY_CTRL_RX_ENABLE | - CSI2SS_PHY_CTRL_DDRCLK_EN << CSI2SS_PHY_CTRL_DDRCLK_EN_OFFSET | - CSI2SS_PHY_CTRL_CONT_CLK_MODE << CSI2SS_PHY_CTRL_CONT_CLK_MODE_OFFSET | - csi2dev->hs_settle << CSI2SS_PHY_CTRL_RX_HS_SETTLE_OFFSET | - CSI2SS_PHY_CTRL_PD << CSI2SS_PHY_CTRL_PD_OFFSET | - CSI2SS_PHY_CTRL_RTERM_SEL << CSI2SS_PHY_CTRL_RTERM_SEL_OFFSET; - - writel(val, csi2dev->csr_regs + CSI2SS_PHY_CTRL); -} - -static void mxc_mipi_csi2_hc_config(struct mxc_mipi_csi2_dev *csi2dev) -{ - u32 val0, val1; - u32 i; - - val0 = 0; - - /* Lanes */ - writel(csi2dev->num_lanes - 1, csi2dev->base_regs + CSI2RX_CFG_NUM_LANES); - - for (i = 0; i < csi2dev->num_lanes; i++) - val0 |= (1 << (csi2dev->data_lanes[i] - 1)); - - val1 = 0xF & ~val0; - writel(val1, csi2dev->base_regs + CSI2RX_CFG_DISABLE_DATA_LANES); - - /* Mask interrupt */ - writel(0x1FF, csi2dev->base_regs + CSI2RX_IRQ_MASK); - - /* vid_vc */ - writel(3, csi2dev->base_regs + 0x184); -} - -static struct media_pad *mxc_csi2_get_remote_sensor_pad(struct mxc_mipi_csi2_dev *csi2dev) -{ - struct v4l2_subdev *subdev = &csi2dev->sd; - struct media_pad *sink_pad, *source_pad; - int i; - - while (1) { - source_pad = NULL; - for (i = 0; i < subdev->entity.num_pads; i++) { - sink_pad = &subdev->entity.pads[i]; - - if (sink_pad->flags & MEDIA_PAD_FL_SINK) { - source_pad = media_entity_remote_pad(sink_pad); - if (source_pad) - break; - } - } - /* return first pad point in the loop */ - return source_pad; - } - - if (i == subdev->entity.num_pads) - v4l2_err(&csi2dev->v4l2_dev, "%s, No remote pad found!\n", __func__); - - return NULL; -} - -static int mxc_csi2_get_sensor_fmt(struct mxc_mipi_csi2_dev *csi2dev) -{ - struct v4l2_mbus_framefmt *mf = &csi2dev->format; - struct v4l2_subdev *sen_sd; - struct media_pad *source_pad; - struct v4l2_subdev_format src_fmt; - int ret; - - /* Get remote source pad */ - source_pad = mxc_csi2_get_remote_sensor_pad(csi2dev); - if (source_pad == NULL) { - v4l2_err(&csi2dev->v4l2_dev, "%s, No remote pad found!\n", __func__); - return -EINVAL; - } - - /* Get remote source pad subdev */ - sen_sd = media_entity_to_v4l2_subdev(source_pad->entity); - if (sen_sd == NULL) { - v4l2_err(&csi2dev->v4l2_dev, "%s, No remote subdev found!\n", __func__); - return -EINVAL; - } - - src_fmt.pad = source_pad->index; - ret = v4l2_subdev_call(sen_sd, pad, get_fmt, NULL, &src_fmt); - if (ret < 0 && ret != -ENOIOCTLCMD) - return -EINVAL; - - /* Update input frame size and formate */ - memcpy(mf, &src_fmt.format, sizeof(struct v4l2_mbus_framefmt)); - - dev_dbg(&csi2dev->pdev->dev, "width=%d, height=%d, fmt.code=0x%x\n", mf->width, mf->height, mf->code); - - /* Get rxhs settle */ - if (src_fmt.format.reserved[0] != 0) - csi2dev->hs_settle = calc_hs_settle(csi2dev, src_fmt.format.reserved[0]); - else { - if (src_fmt.format.height * src_fmt.format.width > 1024 * 768) - csi2dev->hs_settle = rxhs_settle[2]; - else if (src_fmt.format.height * src_fmt.format.width < 480 * 320) - csi2dev->hs_settle = rxhs_settle[0]; - else - csi2dev->hs_settle = rxhs_settle[1]; - } - - return 0; -} - -static int mipi_csi2_clk_init(struct mxc_mipi_csi2_dev *csi2dev) -{ - struct device *dev = &csi2dev->pdev->dev; - - csi2dev->clk_apb = devm_clk_get(dev, "clk_apb"); - if (IS_ERR(csi2dev->clk_apb)) { - dev_err(dev, "failed to get csi apb clk\n"); - return PTR_ERR(csi2dev->clk_apb); - } - - csi2dev->clk_core = devm_clk_get(dev, "clk_core"); - if (IS_ERR(csi2dev->clk_core)) { - dev_err(dev, "failed to get csi core clk\n"); - return PTR_ERR(csi2dev->clk_core); - } - - csi2dev->clk_esc = devm_clk_get(dev, "clk_esc"); - if (IS_ERR(csi2dev->clk_esc)) { - dev_err(dev, "failed to get csi esc clk\n"); - return PTR_ERR(csi2dev->clk_esc); - } - - csi2dev->clk_pxl = devm_clk_get(dev, "clk_pxl"); - if (IS_ERR(csi2dev->clk_pxl)) { - dev_err(dev, "failed to get csi pixel link clk\n"); - return PTR_ERR(csi2dev->clk_pxl); - } - - return 0; -} - -static int mipi_csi2_clk_enable(struct mxc_mipi_csi2_dev *csi2dev) -{ - struct device *dev = &csi2dev->pdev->dev; - int ret; - - ret = clk_prepare_enable(csi2dev->clk_apb); - if (ret < 0) { - dev_err(dev, "%s, pre clk_apb error\n", __func__); - return ret; - } - ret = clk_prepare_enable(csi2dev->clk_core); - if (ret < 0) { - dev_err(dev, "%s, pre clk_core error\n", __func__); - return ret; - } - ret = clk_prepare_enable(csi2dev->clk_esc); - if (ret < 0) { - dev_err(dev, "%s, prepare clk_esc error\n", __func__); - return ret; - } - ret = clk_prepare_enable(csi2dev->clk_pxl); - if (ret < 0) { - dev_err(dev, "%s, prepare clk_pxl error\n", __func__); - return ret; - } - - return ret; -} - -static void mipi_csi2_clk_disable(struct mxc_mipi_csi2_dev *csi2dev) -{ - clk_disable_unprepare(csi2dev->clk_apb); - clk_disable_unprepare(csi2dev->clk_core); - clk_disable_unprepare(csi2dev->clk_esc); - clk_disable_unprepare(csi2dev->clk_pxl); -} - -static int mipi_csi2_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) -{ - return 0; -} - -/* mipi csi2 subdev media entity operations */ -static int mipi_csi2_link_setup(struct media_entity *entity, - const struct media_pad *local, - const struct media_pad *remote, u32 flags) -{ - /* TODO */ - /* Add MIPI source and sink pad link configuration */ - if (local->flags & MEDIA_PAD_FL_SOURCE) { - switch (local->index) { - case MXC_MIPI_CSI2_VC0_PAD_SOURCE: - case MXC_MIPI_CSI2_VC1_PAD_SOURCE: - case MXC_MIPI_CSI2_VC2_PAD_SOURCE: - case MXC_MIPI_CSI2_VC3_PAD_SOURCE: - break; - default: - return 0; - } - } else if (local->flags & MEDIA_PAD_FL_SINK) { - switch (local->index) { - case MXC_MIPI_CSI2_VC0_PAD_SINK: - case MXC_MIPI_CSI2_VC1_PAD_SINK: - case MXC_MIPI_CSI2_VC2_PAD_SINK: - case MXC_MIPI_CSI2_VC3_PAD_SINK: - break; - default: - return 0; - } - } - return 0; -} - -static const struct media_entity_operations mipi_csi2_sd_media_ops = { - .link_setup = mipi_csi2_link_setup, -}; - -/* - * V4L2 subdev operations - */ -static int mipi_csi2_s_power(struct v4l2_subdev *sd, int on) -{ - return 0; -} - -static int mipi_csi2_s_stream(struct v4l2_subdev *sd, int enable) -{ - struct mxc_mipi_csi2_dev *csi2dev = sd_to_mxc_mipi_csi2_dev(sd); - struct device *dev = &csi2dev->pdev->dev; - int ret = 0; - - dev_dbg(&csi2dev->pdev->dev, "%s: %d, csi2dev: 0x%x\n", - __func__, enable, csi2dev->flags); - - if (enable) { - pm_runtime_get_sync(dev); - if (!csi2dev->running) { - mxc_csi2_get_sensor_fmt(csi2dev); - mxc_mipi_csi2_hc_config(csi2dev); - mxc_mipi_csi2_reset(csi2dev); - mxc_mipi_csi2_csr_config(csi2dev); - mxc_mipi_csi2_enable(csi2dev); - mxc_mipi_csi2_reg_dump(csi2dev); - } - csi2dev->running++; - } else { - - if (csi2dev->running) - mxc_mipi_csi2_disable(csi2dev); - csi2dev->running--; - pm_runtime_put(dev); - } - - return ret; -} - -static int mipi_csi2_get_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) -{ - struct mxc_mipi_csi2_dev *csi2dev = sd_to_mxc_mipi_csi2_dev(sd); - struct v4l2_mbus_framefmt *mf = &fmt->format; - - mxc_csi2_get_sensor_fmt(csi2dev); - - memcpy(mf, &csi2dev->format, sizeof(struct v4l2_mbus_framefmt)); - /* Source/Sink pads crop rectangle size */ - - return 0; -} - -static int mipi_csi2_set_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) -{ - return 0; -} - -static const struct v4l2_subdev_internal_ops mipi_csi2_sd_internal_ops = { - .open = mipi_csi2_open, -}; - -static struct v4l2_subdev_pad_ops mipi_csi2_pad_ops = { - .get_fmt = mipi_csi2_get_fmt, - .set_fmt = mipi_csi2_set_fmt, -}; - -static struct v4l2_subdev_core_ops mipi_csi2_core_ops = { - .s_power = mipi_csi2_s_power, -}; - -static struct v4l2_subdev_video_ops mipi_csi2_video_ops = { - .s_stream = mipi_csi2_s_stream, -}; - -static struct v4l2_subdev_ops mipi_csi2_subdev_ops = { - .core = &mipi_csi2_core_ops, - .video = &mipi_csi2_video_ops, - .pad = &mipi_csi2_pad_ops, -}; -static int mipi_csi2_parse_dt(struct mxc_mipi_csi2_dev *csi2dev) -{ - struct device *dev = &csi2dev->pdev->dev; - struct device_node *node = dev->of_node; - struct v4l2_fwnode_endpoint endpoint; - u32 i; - - csi2dev->id = of_alias_get_id(node, "csi"); - - csi2dev->vchannel = of_property_read_bool(node, "virtual-channel"); - - node = of_graph_get_next_endpoint(node, NULL); - if (!node) { - dev_err(dev, "No port node at %s\n", node->full_name); - return -EINVAL; - } - - /* Get port node */ - v4l2_fwnode_endpoint_parse(of_fwnode_handle(node), &endpoint); - - csi2dev->num_lanes = endpoint.bus.mipi_csi2.num_data_lanes; - for (i = 0; i < 4; i++) - csi2dev->data_lanes[i] = endpoint.bus.mipi_csi2.data_lanes[i]; - - of_node_put(node); - - return 0; -} - -static int mipi_csi2_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct resource *mem_res; - struct mxc_mipi_csi2_dev *csi2dev; - int ret = -ENOMEM; - - dev_info(&pdev->dev, "%s\n", __func__); - csi2dev = devm_kzalloc(dev, sizeof(*csi2dev), GFP_KERNEL); - if (!csi2dev) - return -ENOMEM; - - csi2dev->pdev = pdev; - mutex_init(&csi2dev->lock); - - ret = mipi_csi2_parse_dt(csi2dev); - if (ret < 0) - return -EINVAL ; - - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - csi2dev->base_regs = devm_ioremap_resource(dev, mem_res); - if (IS_ERR(csi2dev->base_regs)) { - dev_err(dev, "Failed to get mipi csi2 HC register\n"); - return PTR_ERR(csi2dev->base_regs); - } - - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - csi2dev->csr_regs = devm_ioremap_resource(dev, mem_res); - if (IS_ERR(csi2dev->csr_regs)) { - dev_err(dev, "Failed to get mipi CSR register\n"); - return PTR_ERR(csi2dev->csr_regs); - } - - ret = mipi_csi2_clk_init(csi2dev); - if (ret < 0) - return -EINVAL ; - - v4l2_subdev_init(&csi2dev->sd, &mipi_csi2_subdev_ops); - - csi2dev->sd.owner = THIS_MODULE; - snprintf(csi2dev->sd.name, sizeof(csi2dev->sd.name), "%s.%d", - MXC_MIPI_CSI2_SUBDEV_NAME, csi2dev->id); - - csi2dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - csi2dev->sd.entity.function = MEDIA_ENT_F_IO_V4L; - - csi2dev->pads[MXC_MIPI_CSI2_VC0_PAD_SINK].flags = MEDIA_PAD_FL_SINK; - csi2dev->pads[MXC_MIPI_CSI2_VC1_PAD_SINK].flags = MEDIA_PAD_FL_SINK; - csi2dev->pads[MXC_MIPI_CSI2_VC2_PAD_SINK].flags = MEDIA_PAD_FL_SINK; - csi2dev->pads[MXC_MIPI_CSI2_VC3_PAD_SINK].flags = MEDIA_PAD_FL_SINK; - csi2dev->pads[MXC_MIPI_CSI2_VC0_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - csi2dev->pads[MXC_MIPI_CSI2_VC1_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - csi2dev->pads[MXC_MIPI_CSI2_VC2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - csi2dev->pads[MXC_MIPI_CSI2_VC3_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - - ret = media_entity_pads_init(&csi2dev->sd.entity, - MXC_MIPI_CSI2_VCX_PADS_NUM, csi2dev->pads); - if (ret < 0) - goto e_clkdis; - - csi2dev->sd.entity.ops = &mipi_csi2_sd_media_ops; - - /* This allows to retrieve the platform device id by the host driver */ - v4l2_set_subdevdata(&csi2dev->sd, pdev); - - /* .. and a pointer to the subdev. */ - platform_set_drvdata(pdev, csi2dev); - - mipi_sc_fw_init(csi2dev, 1); - - csi2dev->running = 0; - csi2dev->flags = MXC_MIPI_CSI2_PM_POWERED; - - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - pm_runtime_get_sync(dev); - - ret = mipi_csi2_clk_enable(csi2dev); - if (ret < 0) - goto e_clkdis; - - dev_info(&pdev->dev, "lanes: %d, name: %s\n", - csi2dev->num_lanes, csi2dev->sd.name); - pm_runtime_put_sync(dev); - - return 0; - -e_clkdis: - media_entity_cleanup(&csi2dev->sd.entity); - return ret; -} - -static int mipi_csi2_remove(struct platform_device *pdev) -{ - struct v4l2_subdev *sd = platform_get_drvdata(pdev); - struct mxc_mipi_csi2_dev *csi2dev = sd_to_mxc_mipi_csi2_dev(sd); - - pm_runtime_get_sync(&pdev->dev); - mipi_sc_fw_init(csi2dev, 0); - media_entity_cleanup(&csi2dev->sd.entity); - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); - - return 0; -} - -static int mipi_csi2_suspend(struct device *dev, bool runtime) -{ - struct mxc_mipi_csi2_dev *csi2dev = dev_get_drvdata(dev); - struct v4l2_subdev *sd = &csi2dev->sd; - - mutex_lock(&csi2dev->lock); - if (csi2dev->flags & MXC_MIPI_CSI2_PM_POWERED) { - if (csi2dev->running) - mipi_csi2_s_stream(sd, false); - - mipi_csi2_clk_disable(csi2dev); - csi2dev->flags &= ~MXC_MIPI_CSI2_PM_POWERED; - - if (runtime) - csi2dev->flags |= MXC_MIPI_CSI2_RUNTIME_SUSPENDED; - else - csi2dev->flags |= MXC_MIPI_CSI2_PM_SUSPENDED; - } - mutex_unlock(&csi2dev->lock); - return 0; -} - -static int mipi_csi2_resume(struct device *dev, bool runtime) -{ - struct mxc_mipi_csi2_dev *csi2dev = dev_get_drvdata(dev); - struct v4l2_subdev *sd = &csi2dev->sd; - int ret; - - mutex_lock(&csi2dev->lock); - if (!(csi2dev->flags & MXC_MIPI_CSI2_RUNTIME_SUSPENDED) && - !(csi2dev->flags & MXC_MIPI_CSI2_PM_SUSPENDED)) { - mutex_unlock(&csi2dev->lock); - return 0; - } - - if (!(csi2dev->flags & MXC_MIPI_CSI2_PM_POWERED)) { - ret = mipi_csi2_clk_enable(csi2dev); - if (ret < 0) { - mutex_unlock(&csi2dev->lock); - dev_err(dev, "%s:%d fail\n", __func__, __LINE__); - return -EAGAIN; - } - - if (csi2dev->running) - mipi_csi2_s_stream(sd, true); - - csi2dev->flags |= MXC_MIPI_CSI2_PM_POWERED; - if (runtime) - csi2dev->flags &= ~MXC_MIPI_CSI2_RUNTIME_SUSPENDED; - else - csi2dev->flags &= ~MXC_MIPI_CSI2_PM_SUSPENDED; - } - mutex_unlock(&csi2dev->lock); - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int mipi_csi2_pm_suspend(struct device *dev) -{ - return mipi_csi2_suspend(dev, false); -} - -static int mipi_csi2_pm_resume(struct device *dev) -{ - return mipi_csi2_resume(dev, false); -} -#endif - -static int mipi_csi2_runtime_suspend(struct device *dev) -{ - return mipi_csi2_suspend(dev, true); -} -static int mipi_csi2_runtime_resume(struct device *dev) -{ - return mipi_csi2_resume(dev, true); -} - -static const struct dev_pm_ops mipi_csi_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(mipi_csi2_pm_suspend, mipi_csi2_pm_resume) - SET_RUNTIME_PM_OPS(mipi_csi2_runtime_suspend, mipi_csi2_runtime_resume, NULL) -}; - -static const struct of_device_id mipi_csi2_of_match[] = { - { .compatible = "fsl,mxc-mipi-csi2",}, - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(of, mipi_csi2_of_match); - - -static struct platform_driver mipi_csi2_driver = { - .driver = { - .name = MXC_MIPI_CSI2_DRIVER_NAME, - .of_match_table = mipi_csi2_of_match, - .pm = &mipi_csi_pm_ops, - }, - .probe = mipi_csi2_probe, - .remove = mipi_csi2_remove, -}; - -module_platform_driver(mipi_csi2_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("MXC MIPI CSI2 driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:" MXC_MIPI_CSI2_DRIVER_NAME); diff --git a/drivers/media/platform/imx8/mxc-mipi-csi2_yav.c b/drivers/media/platform/imx8/mxc-mipi-csi2_yav.c index c0c7821b0eda2764b3af339f04b9f89df70b7bec..c6b4869dcb5e18bfa0a2fe72a985108d05cea54a 100644 --- a/drivers/media/platform/imx8/mxc-mipi-csi2_yav.c +++ b/drivers/media/platform/imx8/mxc-mipi-csi2_yav.c @@ -468,6 +468,8 @@ static int mipi_csi2_parse_dt(struct mxc_mipi_csi2_dev *csi2dev) u32 i; csi2dev->id = of_alias_get_id(node, "csi"); + if (csi2dev->id < 0) + return csi2dev->id; csi2dev->vchannel = of_property_read_bool(node, "virtual-channel"); diff --git a/drivers/media/platform/mxc/capture/Kconfig b/drivers/media/platform/mxc/capture/Kconfig index 4a24230004b24a8b05111404edc0c5e868ea63c2..1f654b9a523b66ce3dfcb1732b5b6667c20b411c 100644 --- a/drivers/media/platform/mxc/capture/Kconfig +++ b/drivers/media/platform/mxc/capture/Kconfig @@ -9,38 +9,12 @@ config VIDEO_MXC_CSI_CAMERA ---help--- This is the video4linux2 capture driver based on CSI module. -config MXC_VADC - tristate "mxc VADC support" - depends on VIDEO_MXC_CAPTURE && VIDEO_V4L2 - ---help--- - If you plan to use the VADC with your MXC system, say Y here. - config MXC_MIPI_CSI tristate "mxc mipi csi driver" depends on (VIDEO_MXC_CAPTURE || VIDEO_MX8_CAPTURE) && VIDEO_V4L2 ---help--- This is a V4L2 driver for i.MX7D SoC MIPI-CSI2 receiver devices. -menu "MXC Camera/V4L2 PRP Features support" -config VIDEO_MXC_IPU_CAMERA - bool - select VIDEO_V4L2_MXC_INT_DEVICE - depends on VIDEO_MXC_CAPTURE && MXC_IPU - default y - -config MXC_CAMERA_OV5640 - tristate "OmniVision ov5640 camera support" - depends on !VIDEO_MXC_EMMA_CAMERA && I2C - depends on VIDEO_V4L2_MXC_INT_DEVICE - ---help--- - If you plan to use the ov5640 Camera with your MXC system, say Y here. - -config MXC_CAMERA_OV5640_V2 - tristate "OmniVision ov5640 camera support" - depends on (VIDEO_MXC_CAPTURE || VIDEO_MX8_CAPTURE) && I2C - ---help--- - If you plan to use the ov5640 Camera with your MXC system, say Y here. - config MXC_CAMERA_OV5642 tristate "OmniVision ov5642 camera support" depends on !VIDEO_MXC_EMMA_CAMERA && I2C @@ -48,77 +22,10 @@ config MXC_CAMERA_OV5642 ---help--- If you plan to use the ov5642 Camera with your MXC system, say Y here. -config MXC_CAMERA_OV5640_MIPI - tristate "OmniVision ov5640 camera support using mipi" - depends on !VIDEO_MXC_EMMA_CAMERA && I2C && MXC_MIPI_CSI2 - depends on VIDEO_V4L2_MXC_INT_DEVICE - ---help--- - If you plan to use the ov5640 Camera with mipi interface in your MXC system, say Y here. - config MXC_CAMERA_OV5640_MIPI_V2 tristate "OmniVision ov5640 camera support using mipi" depends on MXC_MIPI_CSI && I2C ---help--- If you plan to use the ov5640 Camera with mipi interface in your MXC system, say Y here. -config MXC_CAMERA_OV5647_MIPI - tristate "OmniVision ov5647 camera support using mipi" - depends on MXC_MIPI_CSI && I2C - ---help--- - If you plan to use the ov5647 Camera with mipi interface in your MXC system, say Y here. - -config MXC_TVIN_ADV7180 - tristate "Analog Device adv7180 TV Decoder Input support" - depends on !VIDEO_MXC_EMMA_CAMERA && I2C - depends on VIDEO_V4L2_MXC_INT_DEVICE - ---help--- - If you plan to use the adv7180 video decoder with your MXC system, say Y here. - -choice - prompt "Select Overlay Rounting" - default MXC_IPU_DEVICE_QUEUE_SDC - depends on VIDEO_MXC_IPU_CAMERA && FB_MXC_SYNC_PANEL - -config MXC_IPU_DEVICE_QUEUE_SDC - tristate "Queue ipu device for overlay library" - depends on VIDEO_MXC_IPU_CAMERA - ---help--- - Use case CSI->MEM->IPU DEVICE->SDC: - Images from sensor will be frist recieved in memory,then - queue to ipu device for processing if needed, and displaying - it on synchronous display with SDC use case. - -config MXC_IPU_PRP_VF_SDC - bool "Pre-Processor VF SDC library" - depends on VIDEO_MXC_IPU_CAMERA - ---help--- - Use case PRP_VF_SDC: - Preprocessing image from smart sensor for viewfinder and - displaying it on synchronous display with SDC use case. - If SDC BG is selected, Rotation will not be supported. - CSI -> IC (PRP VF) -> MEM - MEM -> IC (ROT) -> MEM - MEM -> SDC (FG/BG) - -endchoice - -config MXC_IPU_PRP_ENC - tristate "Pre-processor Encoder library" - depends on VIDEO_MXC_IPU_CAMERA - default y - ---help--- - Use case PRP_ENC: - Preprocessing image from smart sensor for encoder. - CSI -> IC (PRP ENC) -> MEM - -config MXC_IPU_CSI_ENC - tristate "IPU CSI Encoder library" - depends on VIDEO_MXC_IPU_CAMERA - default y - ---help--- - Use case IPU_CSI_ENC: - Get raw image with CSI from smart sensor for encoder. - CSI -> MEM -endmenu - endif diff --git a/drivers/media/platform/mxc/capture/Makefile b/drivers/media/platform/mxc/capture/Makefile index e6e4b99f9435caf106a5d17d99c32f95a4e0a179..e3c6e4c5604c26a24ef8327380454733f20a50ad 100644 --- a/drivers/media/platform/mxc/capture/Makefile +++ b/drivers/media/platform/mxc/capture/Makefile @@ -1,38 +1,5 @@ -ifeq ($(CONFIG_VIDEO_MXC_IPU_CAMERA),y) - obj-$(CONFIG_VIDEO_MXC_CAPTURE) += mxc_v4l2_capture.o - obj-$(CONFIG_MXC_IPU_PRP_VF_SDC) += ipu_prp_vf_sdc.o ipu_prp_vf_sdc_bg.o - obj-$(CONFIG_MXC_IPU_DEVICE_QUEUE_SDC) += ipu_fg_overlay_sdc.o ipu_bg_overlay_sdc.o - obj-$(CONFIG_MXC_IPU_PRP_ENC) += ipu_prp_enc.o ipu_still.o - obj-$(CONFIG_MXC_IPU_CSI_ENC) += ipu_csi_enc.o ipu_still.o -endif - obj-$(CONFIG_VIDEO_MXC_CSI_CAMERA) += mx6s_capture.o -obj-$(CONFIG_MXC_VADC) += mxc_vadc.o -obj-$(CONFIG_MXC_MIPI_CSI) += mxc_mipi_csi.o - -# Used for iMX 6QDL -ov5640_camera_int-objs := ov5640.o -obj-$(CONFIG_MXC_CAMERA_OV5640) += ov5640_camera_int.o - -# Used for iMX 6UL/ULL/SX/SL/SLL -ov5640_camera_v2-objs := ov5640_v2.o -obj-$(CONFIG_MXC_CAMERA_OV5640_V2) += ov5640_camera_v2.o - -ov5642_camera-objs := ov5642.o -obj-$(CONFIG_MXC_CAMERA_OV5642) += ov5642_camera.o - -# Used for iMX 6QDL/DQSCM -ov5640_camera_mipi_int-objs := ov5640_mipi.o -obj-$(CONFIG_MXC_CAMERA_OV5640_MIPI) += ov5640_camera_mipi_int.o # Used for iMX 7D ov5640_camera_mipi_v2-objs := ov5640_mipi_v2.o obj-$(CONFIG_MXC_CAMERA_OV5640_MIPI_V2) += ov5640_camera_mipi_v2.o - -ov5647_camera_mipi-objs := ov5647_mipi.o -obj-$(CONFIG_MXC_CAMERA_OV5647_MIPI) += ov5647_camera_mipi.o - -adv7180_tvin-objs := adv7180.o -obj-$(CONFIG_MXC_TVIN_ADV7180) += adv7180_tvin.o - -obj-$(CONFIG_VIDEO_V4L2_MXC_INT_DEVICE) += v4l2-int-device.o diff --git a/drivers/media/platform/mxc/capture/adv7180.c b/drivers/media/platform/mxc/capture/adv7180.c deleted file mode 100644 index abd615927a48f5b6ff2b2daed5622834d811b48d..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/adv7180.c +++ /dev/null @@ -1,1380 +0,0 @@ -/* - * Copyright 2005-2014 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file adv7180.c - * - * @brief Analog Device ADV7180 video decoder functions - * - * @ingroup Camera - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "v4l2-int-device.h" -#include "mxc_v4l2_capture.h" - -#define ADV7180_VOLTAGE_ANALOG 1800000 -#define ADV7180_VOLTAGE_DIGITAL_CORE 1800000 -#define ADV7180_VOLTAGE_DIGITAL_IO 3300000 -#define ADV7180_VOLTAGE_PLL 1800000 - -static struct regulator *dvddio_regulator; -static struct regulator *dvdd_regulator; -static struct regulator *avdd_regulator; -static struct regulator *pvdd_regulator; -static int pwn_gpio; - -static int adv7180_probe(struct i2c_client *adapter, - const struct i2c_device_id *id); -static int adv7180_detach(struct i2c_client *client); - -static const struct i2c_device_id adv7180_id[] = { - {"adv7180", 0}, - {}, -}; - -MODULE_DEVICE_TABLE(i2c, adv7180_id); - -static struct i2c_driver adv7180_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "adv7180", - }, - .probe = adv7180_probe, - .remove = adv7180_detach, - .id_table = adv7180_id, -}; - -/*! - * Maintains the information on the current state of the sensor. - */ -struct sensor { - struct sensor_data sen; - v4l2_std_id std_id; -} adv7180_data; - - -/*! List of input video formats supported. The video formats is corresponding - * with v4l2 id in video_fmt_t - */ -typedef enum { - ADV7180_NTSC = 0, /*!< Locked on (M) NTSC video signal. */ - ADV7180_PAL, /*!< (B, G, H, I, N)PAL video signal. */ - ADV7180_NOT_LOCKED, /*!< Not locked on a signal. */ -} video_fmt_idx; - -/*! Number of video standards supported (including 'not locked' signal). */ -#define ADV7180_STD_MAX (ADV7180_PAL + 1) - -/*! Video format structure. */ -typedef struct { - int v4l2_id; /*!< Video for linux ID. */ - char name[16]; /*!< Name (e.g., "NTSC", "PAL", etc.) */ - u16 raw_width; /*!< Raw width. */ - u16 raw_height; /*!< Raw height. */ - u16 active_width; /*!< Active width. */ - u16 active_height; /*!< Active height. */ - int frame_rate; /*!< Frame rate. */ -} video_fmt_t; - -/*! Description of video formats supported. - * - * PAL: raw=720x625, active=720x576. - * NTSC: raw=720x525, active=720x480. - */ -static video_fmt_t video_fmts[] = { - { /*! NTSC */ - .v4l2_id = V4L2_STD_NTSC, - .name = "NTSC", - .raw_width = 720, /* SENS_FRM_WIDTH */ - .raw_height = 525, /* SENS_FRM_HEIGHT */ - .active_width = 720, /* ACT_FRM_WIDTH plus 1 */ - .active_height = 480, /* ACT_FRM_WIDTH plus 1 */ - .frame_rate = 30, - }, - { /*! (B, G, H, I, N) PAL */ - .v4l2_id = V4L2_STD_PAL, - .name = "PAL", - .raw_width = 720, - .raw_height = 625, - .active_width = 720, - .active_height = 576, - .frame_rate = 25, - }, - { /*! Unlocked standard */ - .v4l2_id = V4L2_STD_ALL, - .name = "Autodetect", - .raw_width = 720, - .raw_height = 625, - .active_width = 720, - .active_height = 576, - .frame_rate = 0, - }, -}; - -/*!* Standard index of ADV7180. */ -static video_fmt_idx video_idx = ADV7180_PAL; - -/*! @brief This mutex is used to provide mutual exclusion. - * - * Create a mutex that can be used to provide mutually exclusive - * read/write access to the globally accessible data structures - * and variables that were defined above. - */ -static DEFINE_MUTEX(mutex); - -#define IF_NAME "adv7180" -#define ADV7180_INPUT_CTL 0x00 /* Input Control */ -#define ADV7180_STATUS_1 0x10 /* Status #1 */ -#define ADV7180_BRIGHTNESS 0x0a /* Brightness */ -#define ADV7180_IDENT 0x11 /* IDENT */ -#define ADV7180_VSYNC_FIELD_CTL_1 0x31 /* VSYNC Field Control #1 */ -#define ADV7180_MANUAL_WIN_CTL 0x3d /* Manual Window Control */ -#define ADV7180_SD_SATURATION_CB 0xe3 /* SD Saturation Cb */ -#define ADV7180_SD_SATURATION_CR 0xe4 /* SD Saturation Cr */ -#define ADV7180_PWR_MNG 0x0f /* Power Management */ - -/* supported controls */ -/* This hasn't been fully implemented yet. - * This is how it should work, though. */ -static struct v4l2_queryctrl adv7180_qctrl[] = { - { - .id = V4L2_CID_BRIGHTNESS, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Brightness", - .minimum = 0, /* check this value */ - .maximum = 255, /* check this value */ - .step = 1, /* check this value */ - .default_value = 127, /* check this value */ - .flags = 0, - }, { - .id = V4L2_CID_SATURATION, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Saturation", - .minimum = 0, /* check this value */ - .maximum = 255, /* check this value */ - .step = 0x1, /* check this value */ - .default_value = 127, /* check this value */ - .flags = 0, - } -}; - -static inline void adv7180_power_down(int enable) -{ - gpio_set_value_cansleep(pwn_gpio, !enable); - msleep(2); -} - -static int adv7180_regulator_enable(struct device *dev) -{ - int ret = 0; - - dvddio_regulator = devm_regulator_get(dev, "DOVDD"); - - if (!IS_ERR(dvddio_regulator)) { - regulator_set_voltage(dvddio_regulator, - ADV7180_VOLTAGE_DIGITAL_IO, - ADV7180_VOLTAGE_DIGITAL_IO); - ret = regulator_enable(dvddio_regulator); - if (ret) { - dev_err(dev, "set io voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set io voltage ok\n"); - } - } else { - dev_warn(dev, "cannot get io voltage\n"); - } - - dvdd_regulator = devm_regulator_get(dev, "DVDD"); - if (!IS_ERR(dvdd_regulator)) { - regulator_set_voltage(dvdd_regulator, - ADV7180_VOLTAGE_DIGITAL_CORE, - ADV7180_VOLTAGE_DIGITAL_CORE); - ret = regulator_enable(dvdd_regulator); - if (ret) { - dev_err(dev, "set core voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set core voltage ok\n"); - } - } else { - dev_warn(dev, "cannot get core voltage\n"); - } - - avdd_regulator = devm_regulator_get(dev, "AVDD"); - if (!IS_ERR(avdd_regulator)) { - regulator_set_voltage(avdd_regulator, - ADV7180_VOLTAGE_ANALOG, - ADV7180_VOLTAGE_ANALOG); - ret = regulator_enable(avdd_regulator); - if (ret) { - dev_err(dev, "set analog voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set analog voltage ok\n"); - } - } else { - dev_warn(dev, "cannot get analog voltage\n"); - } - - pvdd_regulator = devm_regulator_get(dev, "PVDD"); - if (!IS_ERR(pvdd_regulator)) { - regulator_set_voltage(pvdd_regulator, - ADV7180_VOLTAGE_PLL, - ADV7180_VOLTAGE_PLL); - ret = regulator_enable(pvdd_regulator); - if (ret) { - dev_err(dev, "set pll voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set pll voltage ok\n"); - } - } else { - dev_warn(dev, "cannot get pll voltage\n"); - } - - return ret; -} - - -/*********************************************************************** - * I2C transfert. - ***********************************************************************/ - -/*! Read one register from a ADV7180 i2c slave device. - * - * @param *reg register in the device we wish to access. - * - * @return 0 if success, an error code otherwise. - */ -static inline int adv7180_read(u8 reg) -{ - int val; - - val = i2c_smbus_read_byte_data(adv7180_data.sen.i2c_client, reg); - if (val < 0) { - dev_dbg(&adv7180_data.sen.i2c_client->dev, - "%s:read reg error: reg=%2x\n", __func__, reg); - return -1; - } - return val; -} - -/*! Write one register of a ADV7180 i2c slave device. - * - * @param *reg register in the device we wish to access. - * - * @return 0 if success, an error code otherwise. - */ -static int adv7180_write_reg(u8 reg, u8 val) -{ - s32 ret; - - ret = i2c_smbus_write_byte_data(adv7180_data.sen.i2c_client, reg, val); - if (ret < 0) { - dev_dbg(&adv7180_data.sen.i2c_client->dev, - "%s:write reg error:reg=%2x,val=%2x\n", __func__, - reg, val); - return -1; - } - return 0; -} - -/*********************************************************************** - * mxc_v4l2_capture interface. - ***********************************************************************/ - -/*! - * Return attributes of current video standard. - * Since this device autodetects the current standard, this function also - * sets the values that need to be changed if the standard changes. - * There is no set std equivalent function. - * - * @return None. - */ -static void adv7180_get_std(v4l2_std_id *std) -{ - int status_1, standard, idx; - bool locked; - - dev_dbg(&adv7180_data.sen.i2c_client->dev, "In adv7180_get_std\n"); - - status_1 = adv7180_read(ADV7180_STATUS_1); - locked = status_1 & 0x1; - standard = status_1 & 0x70; - - mutex_lock(&mutex); - *std = V4L2_STD_ALL; - idx = ADV7180_NOT_LOCKED; - if (locked) { - if (standard == 0x40) { - *std = V4L2_STD_PAL; - idx = ADV7180_PAL; - } else if (standard == 0) { - *std = V4L2_STD_NTSC; - idx = ADV7180_NTSC; - } - } - mutex_unlock(&mutex); - - /* This assumes autodetect which this device uses. */ - if (*std != adv7180_data.std_id) { - video_idx = idx; - adv7180_data.std_id = *std; - adv7180_data.sen.pix.width = video_fmts[video_idx].raw_width; - adv7180_data.sen.pix.height = video_fmts[video_idx].raw_height; - } -} - -/*********************************************************************** - * IOCTL Functions from v4l2_int_ioctl_desc. - ***********************************************************************/ - -/*! - * ioctl_g_ifparm - V4L2 sensor interface handler for vidioc_int_g_ifparm_num - * s: pointer to standard V4L2 device structure - * p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure - * - * Gets slave interface parameters. - * Calculates the required xclk value to support the requested - * clock parameters in p. This value is returned in the p - * parameter. - * - * vidioc_int_g_ifparm returns platform-specific information about the - * interface settings used by the sensor. - * - * Called on open. - */ -static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) -{ - dev_dbg(&adv7180_data.sen.i2c_client->dev, "adv7180:ioctl_g_ifparm\n"); - - if (s == NULL) { - pr_err(" ERROR!! no slave device set!\n"); - return -1; - } - - /* Initialize structure to 0s then set any non-0 values. */ - memset(p, 0, sizeof(*p)); - p->if_type = V4L2_IF_TYPE_BT656; /* This is the only possibility. */ - p->u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT; - p->u.bt656.nobt_hs_inv = 1; - p->u.bt656.bt_sync_correct = 1; - - /* ADV7180 has a dedicated clock so no clock settings needed. */ - - return 0; -} - -/*! - * Sets the camera power. - * - * s pointer to the camera device - * on if 1, power is to be turned on. 0 means power is to be turned off - * - * ioctl_s_power - V4L2 sensor interface handler for vidioc_int_s_power_num - * @s: pointer to standard V4L2 device structure - * @on: power state to which device is to be set - * - * Sets devices power state to requrested state, if possible. - * This is called on open, close, suspend and resume. - */ -static int ioctl_s_power(struct v4l2_int_device *s, int on) -{ - struct sensor *sensor = s->priv; - - dev_dbg(&adv7180_data.sen.i2c_client->dev, "adv7180:ioctl_s_power\n"); - - if (on && !sensor->sen.on) { - if (adv7180_write_reg(ADV7180_PWR_MNG, 0x04) != 0) - return -EIO; - - /* - * FIXME:Additional 400ms to wait the chip to be stable? - * This is a workaround for preview scrolling issue. - */ - msleep(400); - } else if (!on && sensor->sen.on) { - if (adv7180_write_reg(ADV7180_PWR_MNG, 0x24) != 0) - return -EIO; - } - - sensor->sen.on = on; - - return 0; -} - -/*! - * ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure - * - * Returns the sensor's video CAPTURE parameters. - */ -static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - struct sensor *sensor = s->priv; - struct v4l2_captureparm *cparm = &a->parm.capture; - - dev_dbg(&adv7180_data.sen.i2c_client->dev, "In adv7180:ioctl_g_parm\n"); - - switch (a->type) { - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - pr_debug(" type is V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); - memset(a, 0, sizeof(*a)); - a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cparm->capability = sensor->sen.streamcap.capability; - cparm->timeperframe = sensor->sen.streamcap.timeperframe; - cparm->capturemode = sensor->sen.streamcap.capturemode; - break; - - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - break; - - default: - pr_debug("ioctl_g_parm:type is unknown %d\n", a->type); - break; - } - - return 0; -} - -/*! - * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure - * - * Configures the sensor to use the input parameters, if possible. If - * not possible, reverts to the old parameters and returns the - * appropriate error code. - * - * This driver cannot change these settings. - */ -static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - dev_dbg(&adv7180_data.sen.i2c_client->dev, "In adv7180:ioctl_s_parm\n"); - - switch (a->type) { - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - break; - } - - return 0; -} - -/*! - * ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap - * @s: pointer to standard V4L2 device structure - * @f: pointer to standard V4L2 v4l2_format structure - * - * Returns the sensor's current pixel format in the v4l2_format - * parameter. - */ -static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) -{ - struct sensor *sensor = s->priv; - - dev_dbg(&adv7180_data.sen.i2c_client->dev, "adv7180:ioctl_g_fmt_cap\n"); - - switch (f->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - pr_debug(" Returning size of %dx%d\n", - sensor->sen.pix.width, sensor->sen.pix.height); - f->fmt.pix = sensor->sen.pix; - break; - - case V4L2_BUF_TYPE_PRIVATE: { - v4l2_std_id std; - adv7180_get_std(&std); - f->fmt.pix.pixelformat = (u32)std; - } - break; - - default: - f->fmt.pix = sensor->sen.pix; - break; - } - - return 0; -} - -/*! - * ioctl_queryctrl - V4L2 sensor interface handler for VIDIOC_QUERYCTRL ioctl - * @s: pointer to standard V4L2 device structure - * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure - * - * If the requested control is supported, returns the control information - * from the video_control[] array. Otherwise, returns -EINVAL if the - * control is not supported. - */ -static int ioctl_queryctrl(struct v4l2_int_device *s, - struct v4l2_queryctrl *qc) -{ - int i; - - dev_dbg(&adv7180_data.sen.i2c_client->dev, "adv7180:ioctl_queryctrl\n"); - - for (i = 0; i < ARRAY_SIZE(adv7180_qctrl); i++) - if (qc->id && qc->id == adv7180_qctrl[i].id) { - memcpy(qc, &(adv7180_qctrl[i]), - sizeof(*qc)); - return 0; - } - - return -EINVAL; -} - -/*! - * ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure - * - * If the requested control is supported, returns the control's current - * value from the video_control[] array. Otherwise, returns -EINVAL - * if the control is not supported. - */ -static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int ret = 0; - int sat = 0; - - dev_dbg(&adv7180_data.sen.i2c_client->dev, "In adv7180:ioctl_g_ctrl\n"); - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_BRIGHTNESS\n"); - adv7180_data.sen.brightness = adv7180_read(ADV7180_BRIGHTNESS); - vc->value = adv7180_data.sen.brightness; - break; - case V4L2_CID_CONTRAST: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_CONTRAST\n"); - vc->value = adv7180_data.sen.contrast; - break; - case V4L2_CID_SATURATION: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_SATURATION\n"); - sat = adv7180_read(ADV7180_SD_SATURATION_CB); - adv7180_data.sen.saturation = sat; - vc->value = adv7180_data.sen.saturation; - break; - case V4L2_CID_HUE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_HUE\n"); - vc->value = adv7180_data.sen.hue; - break; - case V4L2_CID_AUTO_WHITE_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_AUTO_WHITE_BALANCE\n"); - break; - case V4L2_CID_DO_WHITE_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_DO_WHITE_BALANCE\n"); - break; - case V4L2_CID_RED_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_RED_BALANCE\n"); - vc->value = adv7180_data.sen.red; - break; - case V4L2_CID_BLUE_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_BLUE_BALANCE\n"); - vc->value = adv7180_data.sen.blue; - break; - case V4L2_CID_GAMMA: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_GAMMA\n"); - break; - case V4L2_CID_EXPOSURE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_EXPOSURE\n"); - vc->value = adv7180_data.sen.ae_mode; - break; - case V4L2_CID_AUTOGAIN: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_AUTOGAIN\n"); - break; - case V4L2_CID_GAIN: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_GAIN\n"); - break; - case V4L2_CID_HFLIP: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_HFLIP\n"); - break; - case V4L2_CID_VFLIP: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_VFLIP\n"); - break; - default: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " Default case\n"); - vc->value = 0; - ret = -EPERM; - break; - } - - return ret; -} - -/*! - * ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure - * - * If the requested control is supported, sets the control's current - * value in HW (and updates the video_control[] array). Otherwise, - * returns -EINVAL if the control is not supported. - */ -static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int retval = 0; - u8 tmp; - - dev_dbg(&adv7180_data.sen.i2c_client->dev, "In adv7180:ioctl_s_ctrl\n"); - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_BRIGHTNESS\n"); - tmp = vc->value; - adv7180_write_reg(ADV7180_BRIGHTNESS, tmp); - adv7180_data.sen.brightness = vc->value; - break; - case V4L2_CID_CONTRAST: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_CONTRAST\n"); - break; - case V4L2_CID_SATURATION: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_SATURATION\n"); - tmp = vc->value; - adv7180_write_reg(ADV7180_SD_SATURATION_CB, tmp); - adv7180_write_reg(ADV7180_SD_SATURATION_CR, tmp); - adv7180_data.sen.saturation = vc->value; - break; - case V4L2_CID_HUE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_HUE\n"); - break; - case V4L2_CID_AUTO_WHITE_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_AUTO_WHITE_BALANCE\n"); - break; - case V4L2_CID_DO_WHITE_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_DO_WHITE_BALANCE\n"); - break; - case V4L2_CID_RED_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_RED_BALANCE\n"); - break; - case V4L2_CID_BLUE_BALANCE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_BLUE_BALANCE\n"); - break; - case V4L2_CID_GAMMA: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_GAMMA\n"); - break; - case V4L2_CID_EXPOSURE: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_EXPOSURE\n"); - break; - case V4L2_CID_AUTOGAIN: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_AUTOGAIN\n"); - break; - case V4L2_CID_GAIN: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_GAIN\n"); - break; - case V4L2_CID_HFLIP: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_HFLIP\n"); - break; - case V4L2_CID_VFLIP: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " V4L2_CID_VFLIP\n"); - break; - default: - dev_dbg(&adv7180_data.sen.i2c_client->dev, - " Default case\n"); - retval = -EPERM; - break; - } - - return retval; -} - -/*! - * ioctl_enum_framesizes - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMESIZES ioctl - * @s: pointer to standard V4L2 device structure - * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_framesizes(struct v4l2_int_device *s, - struct v4l2_frmsizeenum *fsize) -{ - if (fsize->index >= 1) - return -EINVAL; - - fsize->discrete.width = video_fmts[video_idx].active_width; - fsize->discrete.height = video_fmts[video_idx].active_height; - - return 0; -} - -/*! - * ioctl_enum_frameintervals - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMEINTERVALS ioctl - * @s: pointer to standard V4L2 device structure - * @fival: standard V4L2 VIDIOC_ENUM_FRAMEINTERVALS ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_frameintervals(struct v4l2_int_device *s, - struct v4l2_frmivalenum *fival) -{ - video_fmt_t fmt; - int i; - - if (fival->index != 0) - return -EINVAL; - - for (i = 0; i < ARRAY_SIZE(video_fmts) - 1; i++) { - fmt = video_fmts[i]; - if (fival->width == fmt.active_width && - fival->height == fmt.active_height) { - fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; - fival->discrete.numerator = 1; - fival->discrete.denominator = fmt.frame_rate; - return 0; - } - } - - return -EINVAL; -} - -/*! - * ioctl_g_chip_ident - V4L2 sensor interface handler for - * VIDIOC_DBG_G_CHIP_IDENT ioctl - * @s: pointer to standard V4L2 device structure - * @id: pointer to int - * - * Return 0. - */ -static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id) -{ - ((struct v4l2_dbg_chip_ident *)id)->match.type = - V4L2_CHIP_MATCH_I2C_DRIVER; - strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name, - "adv7180_decoder"); - ((struct v4l2_dbg_chip_ident *)id)->ident = V4L2_IDENT_ADV7180; - - return 0; -} - -/*! - * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT - * @s: pointer to standard V4L2 device structure - */ -static int ioctl_init(struct v4l2_int_device *s) -{ - dev_dbg(&adv7180_data.sen.i2c_client->dev, "In adv7180:ioctl_init\n"); - return 0; -} - -/*! - * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num - * @s: pointer to standard V4L2 device structure - * - * Initialise the device when slave attaches to the master. - */ -static int ioctl_dev_init(struct v4l2_int_device *s) -{ - dev_dbg(&adv7180_data.sen.i2c_client->dev, "adv7180:ioctl_dev_init\n"); - return 0; -} - -/*! - * This structure defines all the ioctls for this module. - */ -static struct v4l2_int_ioctl_desc adv7180_ioctl_desc[] = { - - {vidioc_int_dev_init_num, (v4l2_int_ioctl_func*)ioctl_dev_init}, - - /*! - * Delinitialise the dev. at slave detach. - * The complement of ioctl_dev_init. - */ -/* {vidioc_int_dev_exit_num, (v4l2_int_ioctl_func *)ioctl_dev_exit}, */ - - {vidioc_int_s_power_num, (v4l2_int_ioctl_func*)ioctl_s_power}, - {vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*)ioctl_g_ifparm}, -/* {vidioc_int_g_needs_reset_num, - (v4l2_int_ioctl_func *)ioctl_g_needs_reset}, */ -/* {vidioc_int_reset_num, (v4l2_int_ioctl_func *)ioctl_reset}, */ - {vidioc_int_init_num, (v4l2_int_ioctl_func*)ioctl_init}, - - /*! - * VIDIOC_ENUM_FMT ioctl for the CAPTURE buffer type. - */ -/* {vidioc_int_enum_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap}, */ - - /*! - * VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. - * This ioctl is used to negotiate the image capture size and - * pixel format without actually making it take effect. - */ -/* {vidioc_int_try_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_try_fmt_cap}, */ - - {vidioc_int_g_fmt_cap_num, (v4l2_int_ioctl_func*)ioctl_g_fmt_cap}, - - /*! - * If the requested format is supported, configures the HW to use that - * format, returns error code if format not supported or HW can't be - * correctly configured. - */ -/* {vidioc_int_s_fmt_cap_num, (v4l2_int_ioctl_func *)ioctl_s_fmt_cap}, */ - - {vidioc_int_g_parm_num, (v4l2_int_ioctl_func*)ioctl_g_parm}, - {vidioc_int_s_parm_num, (v4l2_int_ioctl_func*)ioctl_s_parm}, - {vidioc_int_queryctrl_num, (v4l2_int_ioctl_func*)ioctl_queryctrl}, - {vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func*)ioctl_g_ctrl}, - {vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func*)ioctl_s_ctrl}, - {vidioc_int_enum_framesizes_num, - (v4l2_int_ioctl_func *)ioctl_enum_framesizes}, - {vidioc_int_enum_frameintervals_num, - (v4l2_int_ioctl_func *) - ioctl_enum_frameintervals}, - {vidioc_int_g_chip_ident_num, - (v4l2_int_ioctl_func *)ioctl_g_chip_ident}, -}; - -static struct v4l2_int_slave adv7180_slave = { - .ioctls = adv7180_ioctl_desc, - .num_ioctls = ARRAY_SIZE(adv7180_ioctl_desc), -}; - -static struct v4l2_int_device adv7180_int_device = { - .module = THIS_MODULE, - .name = "adv7180", - .type = v4l2_int_type_slave, - .u = { - .slave = &adv7180_slave, - }, -}; - - -/*********************************************************************** - * I2C client and driver. - ***********************************************************************/ - -/*! ADV7180 Reset function. - * - * @return None. - */ -static void adv7180_hard_reset(bool cvbs) -{ - dev_dbg(&adv7180_data.sen.i2c_client->dev, - "In adv7180:adv7180_hard_reset\n"); - - if (cvbs) { - /* Set CVBS input on AIN1 */ - adv7180_write_reg(ADV7180_INPUT_CTL, 0x00); - } else { - /* - * Set YPbPr input on AIN1,4,5 and normal - * operations(autodection of all stds). - */ - adv7180_write_reg(ADV7180_INPUT_CTL, 0x09); - } - - /* Datasheet recommends */ - adv7180_write_reg(0x01, 0xc8); - adv7180_write_reg(0x02, 0x04); - adv7180_write_reg(0x03, 0x00); - adv7180_write_reg(0x04, 0x45); - adv7180_write_reg(0x05, 0x00); - adv7180_write_reg(0x06, 0x02); - adv7180_write_reg(0x07, 0x7F); - adv7180_write_reg(0x08, 0x80); - adv7180_write_reg(0x0A, 0x00); - adv7180_write_reg(0x0B, 0x00); - adv7180_write_reg(0x0C, 0x36); - adv7180_write_reg(0x0D, 0x7C); - adv7180_write_reg(0x0E, 0x00); - adv7180_write_reg(0x0F, 0x00); - adv7180_write_reg(0x13, 0x00); - adv7180_write_reg(0x14, 0x12); - adv7180_write_reg(0x15, 0x00); - adv7180_write_reg(0x16, 0x00); - adv7180_write_reg(0x17, 0x01); - adv7180_write_reg(0x18, 0x93); - adv7180_write_reg(0xF1, 0x19); - adv7180_write_reg(0x1A, 0x00); - adv7180_write_reg(0x1B, 0x00); - adv7180_write_reg(0x1C, 0x00); - adv7180_write_reg(0x1D, 0x40); - adv7180_write_reg(0x1E, 0x00); - adv7180_write_reg(0x1F, 0x00); - adv7180_write_reg(0x20, 0x00); - adv7180_write_reg(0x21, 0x00); - adv7180_write_reg(0x22, 0x00); - adv7180_write_reg(0x23, 0xC0); - adv7180_write_reg(0x24, 0x00); - adv7180_write_reg(0x25, 0x00); - adv7180_write_reg(0x26, 0x00); - adv7180_write_reg(0x27, 0x58); - adv7180_write_reg(0x28, 0x00); - adv7180_write_reg(0x29, 0x00); - adv7180_write_reg(0x2A, 0x00); - adv7180_write_reg(0x2B, 0xE1); - adv7180_write_reg(0x2C, 0xAE); - adv7180_write_reg(0x2D, 0xF4); - adv7180_write_reg(0x2E, 0x00); - adv7180_write_reg(0x2F, 0xF0); - adv7180_write_reg(0x30, 0x00); - adv7180_write_reg(0x31, 0x12); - adv7180_write_reg(0x32, 0x41); - adv7180_write_reg(0x33, 0x84); - adv7180_write_reg(0x34, 0x00); - adv7180_write_reg(0x35, 0x02); - adv7180_write_reg(0x36, 0x00); - adv7180_write_reg(0x37, 0x01); - adv7180_write_reg(0x38, 0x80); - adv7180_write_reg(0x39, 0xC0); - adv7180_write_reg(0x3A, 0x10); - adv7180_write_reg(0x3B, 0x05); - adv7180_write_reg(0x3C, 0x58); - adv7180_write_reg(0x3D, 0xB2); - adv7180_write_reg(0x3E, 0x64); - adv7180_write_reg(0x3F, 0xE4); - adv7180_write_reg(0x40, 0x90); - adv7180_write_reg(0x41, 0x01); - adv7180_write_reg(0x42, 0x7E); - adv7180_write_reg(0x43, 0xA4); - adv7180_write_reg(0x44, 0xFF); - adv7180_write_reg(0x45, 0xB6); - adv7180_write_reg(0x46, 0x12); - adv7180_write_reg(0x48, 0x00); - adv7180_write_reg(0x49, 0x00); - adv7180_write_reg(0x4A, 0x00); - adv7180_write_reg(0x4B, 0x00); - adv7180_write_reg(0x4C, 0x00); - adv7180_write_reg(0x4D, 0xEF); - adv7180_write_reg(0x4E, 0x08); - adv7180_write_reg(0x4F, 0x08); - adv7180_write_reg(0x50, 0x08); - adv7180_write_reg(0x51, 0x24); - adv7180_write_reg(0x52, 0x0B); - adv7180_write_reg(0x53, 0x4E); - adv7180_write_reg(0x54, 0x80); - adv7180_write_reg(0x55, 0x00); - adv7180_write_reg(0x56, 0x10); - adv7180_write_reg(0x57, 0x00); - adv7180_write_reg(0x58, 0x00); - adv7180_write_reg(0x59, 0x00); - adv7180_write_reg(0x5A, 0x00); - adv7180_write_reg(0x5B, 0x00); - adv7180_write_reg(0x5C, 0x00); - adv7180_write_reg(0x5D, 0x00); - adv7180_write_reg(0x5E, 0x00); - adv7180_write_reg(0x5F, 0x00); - adv7180_write_reg(0x60, 0x00); - adv7180_write_reg(0x61, 0x00); - adv7180_write_reg(0x62, 0x20); - adv7180_write_reg(0x63, 0x00); - adv7180_write_reg(0x64, 0x00); - adv7180_write_reg(0x65, 0x00); - adv7180_write_reg(0x66, 0x00); - adv7180_write_reg(0x67, 0x03); - adv7180_write_reg(0x68, 0x01); - adv7180_write_reg(0x69, 0x00); - adv7180_write_reg(0x6A, 0x00); - adv7180_write_reg(0x6B, 0xC0); - adv7180_write_reg(0x6C, 0x00); - adv7180_write_reg(0x6D, 0x00); - adv7180_write_reg(0x6E, 0x00); - adv7180_write_reg(0x6F, 0x00); - adv7180_write_reg(0x70, 0x00); - adv7180_write_reg(0x71, 0x00); - adv7180_write_reg(0x72, 0x00); - adv7180_write_reg(0x73, 0x10); - adv7180_write_reg(0x74, 0x04); - adv7180_write_reg(0x75, 0x01); - adv7180_write_reg(0x76, 0x00); - adv7180_write_reg(0x77, 0x3F); - adv7180_write_reg(0x78, 0xFF); - adv7180_write_reg(0x79, 0xFF); - adv7180_write_reg(0x7A, 0xFF); - adv7180_write_reg(0x7B, 0x1E); - adv7180_write_reg(0x7C, 0xC0); - adv7180_write_reg(0x7D, 0x00); - adv7180_write_reg(0x7E, 0x00); - adv7180_write_reg(0x7F, 0x00); - adv7180_write_reg(0x80, 0x00); - adv7180_write_reg(0x81, 0xC0); - adv7180_write_reg(0x82, 0x04); - adv7180_write_reg(0x83, 0x00); - adv7180_write_reg(0x84, 0x0C); - adv7180_write_reg(0x85, 0x02); - adv7180_write_reg(0x86, 0x03); - adv7180_write_reg(0x87, 0x63); - adv7180_write_reg(0x88, 0x5A); - adv7180_write_reg(0x89, 0x08); - adv7180_write_reg(0x8A, 0x10); - adv7180_write_reg(0x8B, 0x00); - adv7180_write_reg(0x8C, 0x40); - adv7180_write_reg(0x8D, 0x00); - adv7180_write_reg(0x8E, 0x40); - adv7180_write_reg(0x8F, 0x00); - adv7180_write_reg(0x90, 0x00); - adv7180_write_reg(0x91, 0x50); - adv7180_write_reg(0x92, 0x00); - adv7180_write_reg(0x93, 0x00); - adv7180_write_reg(0x94, 0x00); - adv7180_write_reg(0x95, 0x00); - adv7180_write_reg(0x96, 0x00); - adv7180_write_reg(0x97, 0xF0); - adv7180_write_reg(0x98, 0x00); - adv7180_write_reg(0x99, 0x00); - adv7180_write_reg(0x9A, 0x00); - adv7180_write_reg(0x9B, 0x00); - adv7180_write_reg(0x9C, 0x00); - adv7180_write_reg(0x9D, 0x00); - adv7180_write_reg(0x9E, 0x00); - adv7180_write_reg(0x9F, 0x00); - adv7180_write_reg(0xA0, 0x00); - adv7180_write_reg(0xA1, 0x00); - adv7180_write_reg(0xA2, 0x00); - adv7180_write_reg(0xA3, 0x00); - adv7180_write_reg(0xA4, 0x00); - adv7180_write_reg(0xA5, 0x00); - adv7180_write_reg(0xA6, 0x00); - adv7180_write_reg(0xA7, 0x00); - adv7180_write_reg(0xA8, 0x00); - adv7180_write_reg(0xA9, 0x00); - adv7180_write_reg(0xAA, 0x00); - adv7180_write_reg(0xAB, 0x00); - adv7180_write_reg(0xAC, 0x00); - adv7180_write_reg(0xAD, 0x00); - adv7180_write_reg(0xAE, 0x60); - adv7180_write_reg(0xAF, 0x00); - adv7180_write_reg(0xB0, 0x00); - adv7180_write_reg(0xB1, 0x60); - adv7180_write_reg(0xB2, 0x1C); - adv7180_write_reg(0xB3, 0x54); - adv7180_write_reg(0xB4, 0x00); - adv7180_write_reg(0xB5, 0x00); - adv7180_write_reg(0xB6, 0x00); - adv7180_write_reg(0xB7, 0x13); - adv7180_write_reg(0xB8, 0x03); - adv7180_write_reg(0xB9, 0x33); - adv7180_write_reg(0xBF, 0x02); - adv7180_write_reg(0xC0, 0x00); - adv7180_write_reg(0xC1, 0x00); - adv7180_write_reg(0xC2, 0x00); - adv7180_write_reg(0xC3, 0x00); - adv7180_write_reg(0xC4, 0x00); - adv7180_write_reg(0xC5, 0x81); - adv7180_write_reg(0xC6, 0x00); - adv7180_write_reg(0xC7, 0x00); - adv7180_write_reg(0xC8, 0x00); - adv7180_write_reg(0xC9, 0x04); - adv7180_write_reg(0xCC, 0x69); - adv7180_write_reg(0xCD, 0x00); - adv7180_write_reg(0xCE, 0x01); - adv7180_write_reg(0xCF, 0xB4); - adv7180_write_reg(0xD0, 0x00); - adv7180_write_reg(0xD1, 0x10); - adv7180_write_reg(0xD2, 0xFF); - adv7180_write_reg(0xD3, 0xFF); - adv7180_write_reg(0xD4, 0x7F); - adv7180_write_reg(0xD5, 0x7F); - adv7180_write_reg(0xD6, 0x3E); - adv7180_write_reg(0xD7, 0x08); - adv7180_write_reg(0xD8, 0x3C); - adv7180_write_reg(0xD9, 0x08); - adv7180_write_reg(0xDA, 0x3C); - adv7180_write_reg(0xDB, 0x9B); - adv7180_write_reg(0xDC, 0xAC); - adv7180_write_reg(0xDD, 0x4C); - adv7180_write_reg(0xDE, 0x00); - adv7180_write_reg(0xDF, 0x00); - adv7180_write_reg(0xE0, 0x14); - adv7180_write_reg(0xE1, 0x80); - adv7180_write_reg(0xE2, 0x80); - adv7180_write_reg(0xE3, 0x80); - adv7180_write_reg(0xE4, 0x80); - adv7180_write_reg(0xE5, 0x25); - adv7180_write_reg(0xE6, 0x44); - adv7180_write_reg(0xE7, 0x63); - adv7180_write_reg(0xE8, 0x65); - adv7180_write_reg(0xE9, 0x14); - adv7180_write_reg(0xEA, 0x63); - adv7180_write_reg(0xEB, 0x55); - adv7180_write_reg(0xEC, 0x55); - adv7180_write_reg(0xEE, 0x00); - adv7180_write_reg(0xEF, 0x4A); - adv7180_write_reg(0xF0, 0x44); - adv7180_write_reg(0xF1, 0x0C); - adv7180_write_reg(0xF2, 0x32); - adv7180_write_reg(0xF3, 0x00); - adv7180_write_reg(0xF4, 0x3F); - adv7180_write_reg(0xF5, 0xE0); - adv7180_write_reg(0xF6, 0x69); - adv7180_write_reg(0xF7, 0x10); - adv7180_write_reg(0xF8, 0x00); - adv7180_write_reg(0xF9, 0x03); - adv7180_write_reg(0xFA, 0xFA); - adv7180_write_reg(0xFB, 0x40); -} - -/*! ADV7180 I2C attach function. - * - * @param *adapter struct i2c_adapter *. - * - * @return Error code indicating success or failure. - */ - -/*! - * ADV7180 I2C probe function. - * Function set in i2c_driver struct. - * Called by insmod. - * - * @param *adapter I2C adapter descriptor. - * - * @return Error code indicating success or failure. - */ -static int adv7180_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int rev_id; - int ret = 0; - u32 cvbs = true; - struct pinctrl *pinctrl; - struct device *dev = &client->dev; - - printk(KERN_ERR"DBG sensor data is at %p\n", &adv7180_data); - - /* ov5640 pinctrl */ - pinctrl = devm_pinctrl_get_select_default(dev); - if (IS_ERR(pinctrl)) { - dev_err(dev, "setup pinctrl failed\n"); - return PTR_ERR(pinctrl); - } - - /* request power down pin */ - pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); - if (!gpio_is_valid(pwn_gpio)) { - dev_err(dev, "no sensor pwdn pin available\n"); - return -ENODEV; - } - ret = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, - "adv7180_pwdn"); - if (ret < 0) { - dev_err(dev, "no power pin available!\n"); - return ret; - } - - adv7180_regulator_enable(dev); - - adv7180_power_down(0); - - msleep(1); - - /* Set initial values for the sensor struct. */ - memset(&adv7180_data, 0, sizeof(adv7180_data)); - adv7180_data.sen.i2c_client = client; - adv7180_data.sen.streamcap.timeperframe.denominator = 30; - adv7180_data.sen.streamcap.timeperframe.numerator = 1; - adv7180_data.std_id = V4L2_STD_ALL; - video_idx = ADV7180_NOT_LOCKED; - adv7180_data.sen.pix.width = video_fmts[video_idx].raw_width; - adv7180_data.sen.pix.height = video_fmts[video_idx].raw_height; - adv7180_data.sen.pix.pixelformat = V4L2_PIX_FMT_UYVY; /* YUV422 */ - adv7180_data.sen.pix.priv = 1; /* 1 is used to indicate TV in */ - adv7180_data.sen.on = true; - - adv7180_data.sen.sensor_clk = devm_clk_get(dev, "csi_mclk"); - if (IS_ERR(adv7180_data.sen.sensor_clk)) { - dev_err(dev, "get mclk failed\n"); - return PTR_ERR(adv7180_data.sen.sensor_clk); - } - - ret = of_property_read_u32(dev->of_node, "mclk", - &adv7180_data.sen.mclk); - if (ret) { - dev_err(dev, "mclk frequency is invalid\n"); - return ret; - } - - ret = of_property_read_u32( - dev->of_node, "mclk_source", - (u32 *) &(adv7180_data.sen.mclk_source)); - if (ret) { - dev_err(dev, "mclk_source invalid\n"); - return ret; - } - - ret = of_property_read_u32(dev->of_node, "csi_id", - &(adv7180_data.sen.csi)); - if (ret) { - dev_err(dev, "csi_id invalid\n"); - return ret; - } - - clk_prepare_enable(adv7180_data.sen.sensor_clk); - - dev_dbg(&adv7180_data.sen.i2c_client->dev, - "%s:adv7180 probe i2c address is 0x%02X\n", - __func__, adv7180_data.sen.i2c_client->addr); - - /*! Read the revision ID of the tvin chip */ - rev_id = adv7180_read(ADV7180_IDENT); - dev_dbg(dev, - "%s:Analog Device adv7%2X0 detected!\n", __func__, - rev_id); - - ret = of_property_read_u32(dev->of_node, "cvbs", &(cvbs)); - if (ret) { - dev_err(dev, "cvbs setting is not found\n"); - cvbs = true; - } - - /*! ADV7180 initialization. */ - adv7180_hard_reset(cvbs); - - pr_debug(" type is %d (expect %d)\n", - adv7180_int_device.type, v4l2_int_type_slave); - pr_debug(" num ioctls is %d\n", - adv7180_int_device.u.slave->num_ioctls); - - /* This function attaches this structure to the /dev/video0 device. - * The pointer in priv points to the adv7180_data structure here.*/ - adv7180_int_device.priv = &adv7180_data; - ret = v4l2_int_device_register(&adv7180_int_device); - - clk_disable_unprepare(adv7180_data.sen.sensor_clk); - - return ret; -} - -/*! - * ADV7180 I2C detach function. - * Called on rmmod. - * - * @param *client struct i2c_client*. - * - * @return Error code indicating success or failure. - */ -static int adv7180_detach(struct i2c_client *client) -{ - dev_dbg(&adv7180_data.sen.i2c_client->dev, - "%s:Removing %s video decoder @ 0x%02X from adapter %s\n", - __func__, IF_NAME, client->addr << 1, client->adapter->name); - - /* Power down via i2c */ - adv7180_write_reg(ADV7180_PWR_MNG, 0x24); - - if (dvddio_regulator) - regulator_disable(dvddio_regulator); - - if (dvdd_regulator) - regulator_disable(dvdd_regulator); - - if (avdd_regulator) - regulator_disable(avdd_regulator); - - if (pvdd_regulator) - regulator_disable(pvdd_regulator); - - v4l2_int_device_unregister(&adv7180_int_device); - - return 0; -} - -/*! - * ADV7180 init function. - * Called on insmod. - * - * @return Error code indicating success or failure. - */ -static __init int adv7180_init(void) -{ - u8 err = 0; - - pr_debug("In adv7180_init\n"); - - /* Tells the i2c driver what functions to call for this driver. */ - err = i2c_add_driver(&adv7180_i2c_driver); - if (err != 0) - pr_err("%s:driver registration failed, error=%d\n", - __func__, err); - - return err; -} - -/*! - * ADV7180 cleanup function. - * Called on rmmod. - * - * @return Error code indicating success or failure. - */ -static void __exit adv7180_clean(void) -{ - dev_dbg(&adv7180_data.sen.i2c_client->dev, "In adv7180_clean\n"); - i2c_del_driver(&adv7180_i2c_driver); -} - -module_init(adv7180_init); -module_exit(adv7180_clean); - -MODULE_AUTHOR("Freescale Semiconductor"); -MODULE_DESCRIPTION("Anolog Device ADV7180 video decoder driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/ipu_bg_overlay_sdc.c b/drivers/media/platform/mxc/capture/ipu_bg_overlay_sdc.c deleted file mode 100644 index 193cbd5ec0f763aa25d85e635971887946b1f128..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_bg_overlay_sdc.c +++ /dev/null @@ -1,552 +0,0 @@ - -/* - * Copyright 2004-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_bg_overlay_sdc_bg.c - * - * @brief IPU Use case for PRP-VF back-ground - * - * @ingroup IPU - */ -#include -#include -#include -#include -#include -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -static int csi_buffer_num; -static u32 bpp, csi_mem_bufsize = 3; -static u32 out_format; -static struct ipu_soc *disp_ipu; -static u32 offset; - -static void csi_buf_work_func(struct work_struct *work) -{ - int err = 0; - cam_data *cam = - container_of(work, struct _cam_data, csi_work_struct); - - struct ipu_task task; - memset(&task, 0, sizeof(task)); - - if (csi_buffer_num) - task.input.paddr = cam->vf_bufs[0]; - else - task.input.paddr = cam->vf_bufs[1]; - task.input.width = cam->crop_current.width; - task.input.height = cam->crop_current.height; - task.input.format = IPU_PIX_FMT_UYVY; - - task.output.paddr = offset; - task.output.width = cam->overlay_fb->var.xres; - task.output.height = cam->overlay_fb->var.yres; - task.output.format = out_format; - task.output.rotate = cam->rotation; - task.output.crop.pos.x = cam->win.w.left; - task.output.crop.pos.y = cam->win.w.top; - if (cam->win.w.width > 1024 || cam->win.w.height > 1024) { - task.output.crop.w = cam->overlay_fb->var.xres; - task.output.crop.h = cam->overlay_fb->var.yres; - } else { - task.output.crop.w = cam->win.w.width; - task.output.crop.h = cam->win.w.height; - } -again: - err = ipu_check_task(&task); - if (err != IPU_CHECK_OK) { - if (err > IPU_CHECK_ERR_MIN) { - if (err == IPU_CHECK_ERR_SPLIT_INPUTW_OVER) { - task.input.crop.w -= 8; - goto again; - } - if (err == IPU_CHECK_ERR_SPLIT_INPUTH_OVER) { - task.input.crop.h -= 8; - goto again; - } - if (err == IPU_CHECK_ERR_SPLIT_OUTPUTW_OVER) { - task.output.width -= 8; - task.output.crop.w = task.output.width; - goto again; - } - if (err == IPU_CHECK_ERR_SPLIT_OUTPUTH_OVER) { - task.output.height -= 8; - task.output.crop.h = task.output.height; - goto again; - } - printk(KERN_ERR "check ipu taks fail\n"); - return; - } - printk(KERN_ERR "check ipu taks fail\n"); - return; - } - err = ipu_queue_task(&task); - if (err < 0) - printk(KERN_ERR "queue ipu task error\n"); -} - -static void get_disp_ipu(cam_data *cam) -{ - if (cam->output > 2) - disp_ipu = ipu_get_soc(1); /* using DISP4 */ - else - disp_ipu = ipu_get_soc(0); -} - - -/*! - * csi ENC callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t csi_enc_callback(int irq, void *dev_id) -{ - cam_data *cam = (cam_data *) dev_id; - ipu_channel_t chan = (irq == IPU_IRQ_CSI0_OUT_EOF) ? - CSI_MEM0 : CSI_MEM1; - - ipu_select_buffer(cam->ipu, chan, - IPU_OUTPUT_BUFFER, csi_buffer_num); - schedule_work(&cam->csi_work_struct); - csi_buffer_num = (csi_buffer_num == 0) ? 1 : 0; - return IRQ_HANDLED; -} - -static int csi_enc_setup(cam_data *cam) -{ - ipu_channel_params_t params; - u32 pixel_fmt; - int err = 0, sensor_protocol = 0; - ipu_channel_t chan = (cam->csi == 0) ? CSI_MEM0 : CSI_MEM1; - -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (!cam) { - printk(KERN_ERR "cam private is NULL\n"); - return -ENXIO; - } - - memset(¶ms, 0, sizeof(ipu_channel_params_t)); - params.csi_mem.csi = cam->csi; - - sensor_protocol = ipu_csi_get_sensor_protocol(cam->ipu, cam->csi); - switch (sensor_protocol) { - case IPU_CSI_CLK_MODE_GATED_CLK: - case IPU_CSI_CLK_MODE_NONGATED_CLK: - case IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE: - case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR: - case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR: - params.csi_mem.interlaced = false; - break; - case IPU_CSI_CLK_MODE_CCIR656_INTERLACED: - case IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_DDR: - case IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_SDR: - params.csi_mem.interlaced = true; - break; - default: - printk(KERN_ERR "sensor protocol unsupported\n"); - return -EINVAL; - } - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) { - params.csi_mem.mipi_en = true; - params.csi_mem.mipi_vc = - mipi_csi2_get_virtual_channel(mipi_csi2_info); - params.csi_mem.mipi_id = - mipi_csi2_get_datatype(mipi_csi2_info); - - mipi_csi2_pixelclk_enable(mipi_csi2_info); - } else { - params.csi_mem.mipi_en = false; - params.csi_mem.mipi_vc = 0; - params.csi_mem.mipi_id = 0; - } - } else { - params.csi_mem.mipi_en = false; - params.csi_mem.mipi_vc = 0; - params.csi_mem.mipi_id = 0; - } - } -#endif - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - } - csi_mem_bufsize = - cam->crop_current.width * cam->crop_current.height * 2; - cam->vf_bufs_size[0] = PAGE_ALIGN(csi_mem_bufsize); - cam->vf_bufs_vaddr[0] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[0], - (dma_addr_t *) & - cam->vf_bufs[0], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[0] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_2; - } - cam->vf_bufs_size[1] = PAGE_ALIGN(csi_mem_bufsize); - cam->vf_bufs_vaddr[1] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[1], - (dma_addr_t *) & - cam->vf_bufs[1], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[1] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_1; - } - pr_debug("vf_bufs %x %x\n", cam->vf_bufs[0], cam->vf_bufs[1]); - - err = ipu_init_channel(cam->ipu, chan, ¶ms); - if (err != 0) { - printk(KERN_ERR "ipu_init_channel %d\n", err); - goto out_1; - } - - pixel_fmt = IPU_PIX_FMT_UYVY; - err = ipu_init_channel_buffer( - cam->ipu, chan, IPU_OUTPUT_BUFFER, pixel_fmt, - cam->crop_current.width, cam->crop_current.height, - cam->crop_current.width, IPU_ROTATE_NONE, - cam->vf_bufs[0], cam->vf_bufs[1], 0, - cam->offset.u_offset, cam->offset.u_offset); - if (err != 0) { - printk(KERN_ERR "CSI_MEM output buffer\n"); - goto out_1; - } - err = ipu_enable_channel(cam->ipu, chan); - if (err < 0) { - printk(KERN_ERR "ipu_enable_channel CSI_MEM\n"); - goto out_1; - } - - csi_buffer_num = 0; - - ipu_select_buffer(cam->ipu, chan, IPU_OUTPUT_BUFFER, 0); - ipu_select_buffer(cam->ipu, chan, IPU_OUTPUT_BUFFER, 1); - return err; -out_1: - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } -out_2: - return err; -} - -/*! - * Enable encoder task - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int csi_enc_enabling_tasks(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - - ipu_clear_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi); - err = ipu_request_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi, - csi_enc_callback, 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR "Error registering CSI_OUT_EOF irq\n"); - return err; - } - - INIT_WORK(&cam->csi_work_struct, csi_buf_work_func); - - err = csi_enc_setup(cam); - if (err != 0) { - printk(KERN_ERR "csi_enc_setup %d\n", err); - goto out1; - } - - return err; -out1: - ipu_free_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi, cam); - return err; -} - -/*! - * bg_overlay_start - start the overlay task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int bg_overlay_start(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - - if (!cam) { - printk(KERN_ERR "private is NULL\n"); - return -EIO; - } - - if (cam->overlay_active == true) { - pr_debug("already start.\n"); - return 0; - } - - get_disp_ipu(cam); - - out_format = cam->v4l2_fb.fmt.pixelformat; - if (cam->v4l2_fb.fmt.pixelformat == IPU_PIX_FMT_BGR24) { - bpp = 3, csi_mem_bufsize = 3; - pr_info("BGR24\n"); - } else if (cam->v4l2_fb.fmt.pixelformat == IPU_PIX_FMT_RGB565) { - bpp = 2, csi_mem_bufsize = 2; - pr_info("RGB565\n"); - } else if (cam->v4l2_fb.fmt.pixelformat == IPU_PIX_FMT_BGR32) { - bpp = 4, csi_mem_bufsize = 4; - pr_info("BGR32\n"); - } else { - printk(KERN_ERR - "unsupported fix format from the framebuffer.\n"); - return -EINVAL; - } - - offset = cam->v4l2_fb.fmt.bytesperline * cam->win.w.top + - csi_mem_bufsize * cam->win.w.left; - - if (cam->v4l2_fb.base == 0) - printk(KERN_ERR "invalid frame buffer address.\n"); - else - offset += (u32) cam->v4l2_fb.base; - - csi_mem_bufsize = cam->win.w.width * cam->win.w.height - * csi_mem_bufsize; - - err = csi_enc_enabling_tasks(cam); - if (err != 0) { - printk(KERN_ERR "Error csi enc enable fail\n"); - return err; - } - - cam->overlay_active = true; - return err; -} - -/*! - * bg_overlay_stop - stop the overlay task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int bg_overlay_stop(void *private) -{ - int err = 0; - cam_data *cam = (cam_data *) private; - ipu_channel_t chan = (cam->csi == 0) ? CSI_MEM0 : CSI_MEM1; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (cam->overlay_active == false) - return 0; - - err = ipu_disable_channel(cam->ipu, chan, true); - - ipu_uninit_channel(cam->ipu, chan); - - csi_buffer_num = 0; - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) - mipi_csi2_pixelclk_disable(mipi_csi2_info); - } - } -#endif - - flush_work(&cam->csi_work_struct); - cancel_work_sync(&cam->csi_work_struct); - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } - if (cam->rot_vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->rot_vf_buf_size[0], - cam->rot_vf_bufs_vaddr[0], - cam->rot_vf_bufs[0]); - cam->rot_vf_bufs_vaddr[0] = NULL; - cam->rot_vf_bufs[0] = 0; - } - if (cam->rot_vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->rot_vf_buf_size[1], - cam->rot_vf_bufs_vaddr[1], - cam->rot_vf_bufs[1]); - cam->rot_vf_bufs_vaddr[1] = NULL; - cam->rot_vf_bufs[1] = 0; - } - - cam->overlay_active = false; - return err; -} - -/*! - * Enable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int bg_overlay_enable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - return ipu_enable_csi(cam->ipu, cam->csi); -} - -/*! - * Disable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int bg_overlay_disable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - /* free csi eof irq firstly. - * when disable csi, wait for idmac eof. - * it requests eof irq again */ - ipu_free_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi, cam); - - return ipu_disable_csi(cam->ipu, cam->csi); -} - -/*! - * function to select bg as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return status - */ -int bg_overlay_sdc_select(void *private) -{ - cam_data *cam = (cam_data *) private; - - if (cam) { - cam->vf_start_sdc = bg_overlay_start; - cam->vf_stop_sdc = bg_overlay_stop; - cam->vf_enable_csi = bg_overlay_enable_csi; - cam->vf_disable_csi = bg_overlay_disable_csi; - cam->overlay_active = false; - } - - return 0; -} -EXPORT_SYMBOL(bg_overlay_sdc_select); - -/*! - * function to de-select bg as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return status - */ -int bg_overlay_sdc_deselect(void *private) -{ - cam_data *cam = (cam_data *) private; - - if (cam) { - cam->vf_start_sdc = NULL; - cam->vf_stop_sdc = NULL; - cam->vf_enable_csi = NULL; - cam->vf_disable_csi = NULL; - } - return 0; -} -EXPORT_SYMBOL(bg_overlay_sdc_deselect); - -/*! - * Init background overlay task. - * - * @return Error code indicating success or failure - */ -__init int bg_overlay_sdc_init(void) -{ - return 0; -} - -/*! - * Deinit background overlay task. - * - * @return Error code indicating success or failure - */ -void __exit bg_overlay_sdc_exit(void) -{ -} - -module_init(bg_overlay_sdc_init); -module_exit(bg_overlay_sdc_exit); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("IPU PRP VF SDC Backgroud Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/ipu_csi_enc.c b/drivers/media/platform/mxc/capture/ipu_csi_enc.c deleted file mode 100644 index 3a824a9659e7b4c75dd3d8ce8423f0a2d200bb48..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_csi_enc.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Copyright 2009-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_csi_enc.c - * - * @brief CSI Use case for video capture - * - * @ingroup IPU - */ - -#include -#include -#include -#include -#include -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -#ifdef CAMERA_DBG - #define CAMERA_TRACE(x) (printk)x -#else - #define CAMERA_TRACE(x) -#endif - -/* - * Function definitions - */ - -/*! - * csi ENC callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t csi_enc_callback(int irq, void *dev_id) -{ - cam_data *cam = (cam_data *) dev_id; - - if (cam->enc_callback == NULL) - return IRQ_HANDLED; - - cam->enc_callback(irq, dev_id); - return IRQ_HANDLED; -} - -/*! - * CSI ENC enable channel setup function - * - * @param cam struct cam_data * mxc capture instance - * - * @return status - */ -static int csi_enc_setup(cam_data *cam) -{ - ipu_channel_params_t params; - u32 pixel_fmt; - int err = 0, sensor_protocol = 0; - dma_addr_t dummy = cam->dummy_frame.buffer.m.offset; - ipu_channel_t chan = (cam->csi == 0) ? CSI_MEM0 : CSI_MEM1; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - CAMERA_TRACE("In csi_enc_setup\n"); - if (!cam) { - printk(KERN_ERR "cam private is NULL\n"); - return -ENXIO; - } - - memset(¶ms, 0, sizeof(ipu_channel_params_t)); - params.csi_mem.csi = cam->csi; - - sensor_protocol = ipu_csi_get_sensor_protocol(cam->ipu, cam->csi); - switch (sensor_protocol) { - case IPU_CSI_CLK_MODE_GATED_CLK: - case IPU_CSI_CLK_MODE_NONGATED_CLK: - case IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE: - case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR: - case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR: - params.csi_mem.interlaced = false; - break; - case IPU_CSI_CLK_MODE_CCIR656_INTERLACED: - case IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_DDR: - case IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_SDR: - params.csi_mem.interlaced = true; - break; - default: - printk(KERN_ERR "sensor protocol unsupported\n"); - return -EINVAL; - } - - if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420) - pixel_fmt = IPU_PIX_FMT_YUV420P; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YVU420) - pixel_fmt = IPU_PIX_FMT_YVU420P; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV422P) - pixel_fmt = IPU_PIX_FMT_YUV422P; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_UYVY) - pixel_fmt = IPU_PIX_FMT_UYVY; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) - pixel_fmt = IPU_PIX_FMT_YUYV; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_NV12) - pixel_fmt = IPU_PIX_FMT_NV12; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) - pixel_fmt = IPU_PIX_FMT_BGR24; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB24) - pixel_fmt = IPU_PIX_FMT_RGB24; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB565) - pixel_fmt = IPU_PIX_FMT_RGB565; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_BGR32) - pixel_fmt = IPU_PIX_FMT_BGR32; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB32) - pixel_fmt = IPU_PIX_FMT_RGB32; - else { - printk(KERN_ERR "format not supported\n"); - return -EINVAL; - } - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) { - params.csi_mem.mipi_en = true; - params.csi_mem.mipi_vc = - mipi_csi2_get_virtual_channel(mipi_csi2_info); - params.csi_mem.mipi_id = - mipi_csi2_get_datatype(mipi_csi2_info); - - mipi_csi2_pixelclk_enable(mipi_csi2_info); - } else { - params.csi_mem.mipi_en = false; - params.csi_mem.mipi_vc = 0; - params.csi_mem.mipi_id = 0; - } - } else { - params.csi_mem.mipi_en = false; - params.csi_mem.mipi_vc = 0; - params.csi_mem.mipi_id = 0; - } - } -#endif - - err = ipu_init_channel(cam->ipu, chan, ¶ms); - if (err != 0) { - printk(KERN_ERR "ipu_init_channel %d\n", err); - return err; - } - - err = ipu_init_channel_buffer(cam->ipu, - chan, - IPU_OUTPUT_BUFFER, - pixel_fmt, cam->v2f.fmt.pix.width, - cam->v2f.fmt.pix.height, - cam->v2f.fmt.pix.bytesperline, - IPU_ROTATE_NONE, - dummy, dummy, 0, - cam->offset.u_offset, - cam->offset.v_offset); - if (err != 0) { - printk(KERN_ERR "CSI_MEM output buffer\n"); - return err; - } - err = ipu_enable_channel(cam->ipu, chan); - if (err < 0) { - printk(KERN_ERR "ipu_enable_channel CSI_MEM\n"); - return err; - } - - return err; -} - -/*! - * function to update physical buffer address for encorder IDMA channel - * - * @param *private pointer to the cam_data structure - * @param eba physical buffer address for encorder IDMA channel - * - * @return status - */ -static int csi_enc_eba_update(void *private, dma_addr_t eba) -{ - int err = 0; - cam_data *cam = (cam_data *) private; - struct ipu_soc *ipu = cam->ipu; - int *buffer_num = &cam->ping_pong_csi; - ipu_channel_t chan = (cam->csi == 0) ? CSI_MEM0 : CSI_MEM1; - - pr_debug("eba %x\n", eba); - err = ipu_update_channel_buffer(ipu, chan, IPU_OUTPUT_BUFFER, - *buffer_num, eba); - if (err != 0) { - ipu_clear_buffer_ready(ipu, chan, IPU_OUTPUT_BUFFER, - *buffer_num); - - err = ipu_update_channel_buffer(ipu, chan, - IPU_OUTPUT_BUFFER, *buffer_num, eba); - if (err != 0) { - pr_err("ERROR: v4l2 capture: fail to update " - "buf%d\n", *buffer_num); - return err; - } - } - - ipu_select_buffer(ipu, chan, IPU_OUTPUT_BUFFER, *buffer_num); - - *buffer_num = (*buffer_num == 0) ? 1 : 0; - - return 0; -} - -/*! - * Enable encoder task - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int csi_enc_enabling_tasks(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - uint32_t irq = (cam->csi == 0) ? - IPU_IRQ_CSI0_OUT_EOF : IPU_IRQ_CSI1_OUT_EOF; - - CAMERA_TRACE("IPU:In csi_enc_enabling_tasks\n"); - - cam->dummy_frame.vaddress = dma_alloc_coherent(0, - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage), - &cam->dummy_frame.paddress, - GFP_DMA | GFP_KERNEL); - if (cam->dummy_frame.vaddress == 0) { - pr_err("ERROR: v4l2 capture: Allocate dummy frame " - "failed.\n"); - return -ENOBUFS; - } - cam->dummy_frame.buffer.type = V4L2_BUF_TYPE_PRIVATE; - cam->dummy_frame.buffer.length = - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage); - cam->dummy_frame.buffer.m.offset = cam->dummy_frame.paddress; - - ipu_clear_irq(cam->ipu, irq); - err = ipu_request_irq( - cam->ipu, irq, csi_enc_callback, 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR "Error registering rot irq\n"); - return err; - } - - err = csi_enc_setup(cam); - if (err != 0) { - printk(KERN_ERR "csi_enc_setup %d\n", err); - return err; - } - - return err; -} - -/*! - * Disable encoder task - * @param private struct cam_data * mxc capture instance - * - * @return int - */ -static int csi_enc_disabling_tasks(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - ipu_channel_t chan = (cam->csi == 0) ? CSI_MEM0 : CSI_MEM1; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - err = ipu_disable_channel(cam->ipu, chan, true); - - ipu_uninit_channel(cam->ipu, chan); - - if (cam->dummy_frame.vaddress != 0) { - dma_free_coherent(0, cam->dummy_frame.buffer.length, - cam->dummy_frame.vaddress, - cam->dummy_frame.paddress); - cam->dummy_frame.vaddress = 0; - } - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) - mipi_csi2_pixelclk_disable(mipi_csi2_info); - } - } -#endif - - return err; -} - -/*! - * Enable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int csi_enc_enable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - return ipu_enable_csi(cam->ipu, cam->csi); -} - -/*! - * Disable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int csi_enc_disable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - uint32_t irq = (cam->csi == 0) ? - IPU_IRQ_CSI0_OUT_EOF : IPU_IRQ_CSI1_OUT_EOF; - - /* free csi eof irq firstly. - * when disable csi, wait for idmac eof. - * it requests eof irq again */ - ipu_free_irq(cam->ipu, irq, cam); - - return ipu_disable_csi(cam->ipu, cam->csi); -} - -/*! - * function to select CSI ENC as the working path - * - * @param private struct cam_data * mxc capture instance - * - * @return int - */ -int csi_enc_select(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - - if (cam) { - cam->enc_update_eba = csi_enc_eba_update; - cam->enc_enable = csi_enc_enabling_tasks; - cam->enc_disable = csi_enc_disabling_tasks; - cam->enc_enable_csi = csi_enc_enable_csi; - cam->enc_disable_csi = csi_enc_disable_csi; - } else { - err = -EIO; - } - - return err; -} -EXPORT_SYMBOL(csi_enc_select); - -/*! - * function to de-select CSI ENC as the working path - * - * @param private struct cam_data * mxc capture instance - * - * @return int - */ -int csi_enc_deselect(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - - if (cam) { - cam->enc_update_eba = NULL; - cam->enc_enable = NULL; - cam->enc_disable = NULL; - cam->enc_enable_csi = NULL; - cam->enc_disable_csi = NULL; - } - - return err; -} -EXPORT_SYMBOL(csi_enc_deselect); - -/*! - * Init the Encorder channels - * - * @return Error code indicating success or failure - */ -__init int csi_enc_init(void) -{ - return 0; -} - -/*! - * Deinit the Encorder channels - * - */ -void __exit csi_enc_exit(void) -{ -} - -module_init(csi_enc_init); -module_exit(csi_enc_exit); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("CSI ENC Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/ipu_fg_overlay_sdc.c b/drivers/media/platform/mxc/capture/ipu_fg_overlay_sdc.c deleted file mode 100644 index 4d6b1365bb0dd5d1903dfd3320d9470fbd6cb361..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_fg_overlay_sdc.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - * Copyright 2004-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ -/* * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_foreground_sdc.c - * - * @brief IPU Use case for PRP-VF - * - * @ingroup IPU - */ - -#include -#include -#include -#include -#include -#include - -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -#ifdef CAMERA_DBG - #define CAMERA_TRACE(x) (printk)x -#else - #define CAMERA_TRACE(x) -#endif - -static int csi_buffer_num, buffer_num; -static u32 csi_mem_bufsize; -static struct ipu_soc *disp_ipu; -static struct fb_info *fbi; -static struct fb_var_screeninfo fbvar; -static u32 vf_out_format; -static void csi_buf_work_func(struct work_struct *work) -{ - int err = 0; - cam_data *cam = - container_of(work, struct _cam_data, csi_work_struct); - - struct ipu_task task; - memset(&task, 0, sizeof(task)); - - if (csi_buffer_num) - task.input.paddr = cam->vf_bufs[0]; - else - task.input.paddr = cam->vf_bufs[1]; - task.input.width = cam->crop_current.width; - task.input.height = cam->crop_current.height; - task.input.format = IPU_PIX_FMT_NV12; - - if (buffer_num == 0) - task.output.paddr = fbi->fix.smem_start + - (fbi->fix.line_length * fbvar.yres); - else - task.output.paddr = fbi->fix.smem_start; - task.output.width = cam->win.w.width; - task.output.height = cam->win.w.height; - task.output.format = vf_out_format; - task.output.rotate = cam->rotation; -again: - err = ipu_check_task(&task); - if (err != IPU_CHECK_OK) { - if (err > IPU_CHECK_ERR_MIN) { - if (err == IPU_CHECK_ERR_SPLIT_INPUTW_OVER) { - task.input.crop.w -= 8; - goto again; - } - if (err == IPU_CHECK_ERR_SPLIT_INPUTH_OVER) { - task.input.crop.h -= 8; - goto again; - } - if (err == IPU_CHECK_ERR_SPLIT_OUTPUTW_OVER) { - task.output.width -= 8; - task.output.crop.w = task.output.width; - goto again; - } - if (err == IPU_CHECK_ERR_SPLIT_OUTPUTH_OVER) { - task.output.height -= 8; - task.output.crop.h = task.output.height; - goto again; - } - printk(KERN_ERR "check ipu taks fail\n"); - return; - } - printk(KERN_ERR "check ipu taks fail\n"); - return; - } - err = ipu_queue_task(&task); - if (err < 0) - printk(KERN_ERR "queue ipu task error\n"); - ipu_select_buffer(disp_ipu, MEM_FG_SYNC, IPU_INPUT_BUFFER, buffer_num); - buffer_num = (buffer_num == 0) ? 1 : 0; -} - -static void get_disp_ipu(cam_data *cam) -{ - if (cam->output > 2) - disp_ipu = ipu_get_soc(1); /* using DISP4 */ - else - disp_ipu = ipu_get_soc(0); -} - -/*! - * csi ENC callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t csi_enc_callback(int irq, void *dev_id) -{ - cam_data *cam = (cam_data *) dev_id; - ipu_channel_t chan = (irq == IPU_IRQ_CSI0_OUT_EOF) ? - CSI_MEM0 : CSI_MEM1; - - ipu_select_buffer(cam->ipu, chan, - IPU_OUTPUT_BUFFER, csi_buffer_num); - - if ((cam->crop_current.width != cam->win.w.width) || - (cam->crop_current.height != cam->win.w.height) || - (vf_out_format != IPU_PIX_FMT_NV12) || - (cam->rotation >= IPU_ROTATE_VERT_FLIP)) - schedule_work(&cam->csi_work_struct); - csi_buffer_num = (csi_buffer_num == 0) ? 1 : 0; - return IRQ_HANDLED; -} - -static int csi_enc_setup(cam_data *cam) -{ - ipu_channel_params_t params; - int err = 0, sensor_protocol = 0; - ipu_channel_t chan = (cam->csi == 0) ? CSI_MEM0 : CSI_MEM1; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - CAMERA_TRACE("In csi_enc_setup\n"); - if (!cam) { - printk(KERN_ERR "cam private is NULL\n"); - return -ENXIO; - } - - memset(¶ms, 0, sizeof(ipu_channel_params_t)); - params.csi_mem.csi = cam->csi; - - sensor_protocol = ipu_csi_get_sensor_protocol(cam->ipu, cam->csi); - switch (sensor_protocol) { - case IPU_CSI_CLK_MODE_GATED_CLK: - case IPU_CSI_CLK_MODE_NONGATED_CLK: - case IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE: - case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR: - case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR: - params.csi_mem.interlaced = false; - break; - case IPU_CSI_CLK_MODE_CCIR656_INTERLACED: - case IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_DDR: - case IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_SDR: - params.csi_mem.interlaced = true; - break; - default: - printk(KERN_ERR "sensor protocol unsupported\n"); - return -EINVAL; - } - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) { - params.csi_mem.mipi_en = true; - params.csi_mem.mipi_vc = - mipi_csi2_get_virtual_channel(mipi_csi2_info); - params.csi_mem.mipi_id = - mipi_csi2_get_datatype(mipi_csi2_info); - - mipi_csi2_pixelclk_enable(mipi_csi2_info); - } else { - params.csi_mem.mipi_en = false; - params.csi_mem.mipi_vc = 0; - params.csi_mem.mipi_id = 0; - } - } else { - params.csi_mem.mipi_en = false; - params.csi_mem.mipi_vc = 0; - params.csi_mem.mipi_id = 0; - } - } -#endif - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - } - csi_mem_bufsize = cam->crop_current.width * - cam->crop_current.height * 3/2; - cam->vf_bufs_size[0] = PAGE_ALIGN(csi_mem_bufsize); - cam->vf_bufs_vaddr[0] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[0], - (dma_addr_t *) & - cam->vf_bufs[0], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[0] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_2; - } - cam->vf_bufs_size[1] = PAGE_ALIGN(csi_mem_bufsize); - cam->vf_bufs_vaddr[1] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[1], - (dma_addr_t *) & - cam->vf_bufs[1], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[1] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_1; - } - pr_debug("vf_bufs %x %x\n", cam->vf_bufs[0], cam->vf_bufs[1]); - - err = ipu_init_channel(cam->ipu, chan, ¶ms); - if (err != 0) { - printk(KERN_ERR "ipu_init_channel %d\n", err); - goto out_1; - } - - if ((cam->crop_current.width == cam->win.w.width) && - (cam->crop_current.height == cam->win.w.height) && - (vf_out_format == IPU_PIX_FMT_NV12) && - (cam->rotation < IPU_ROTATE_VERT_FLIP)) { - err = ipu_init_channel_buffer(cam->ipu, chan, - IPU_OUTPUT_BUFFER, IPU_PIX_FMT_NV12, - cam->crop_current.width, - cam->crop_current.height, - cam->crop_current.width, IPU_ROTATE_NONE, - fbi->fix.smem_start + - (fbi->fix.line_length * fbvar.yres), - fbi->fix.smem_start, 0, - cam->offset.u_offset, cam->offset.u_offset); - } else { - err = ipu_init_channel_buffer(cam->ipu, chan, - IPU_OUTPUT_BUFFER, IPU_PIX_FMT_NV12, - cam->crop_current.width, - cam->crop_current.height, - cam->crop_current.width, IPU_ROTATE_NONE, - cam->vf_bufs[0], cam->vf_bufs[1], 0, - cam->offset.u_offset, cam->offset.u_offset); - } - if (err != 0) { - printk(KERN_ERR "CSI_MEM output buffer\n"); - goto out_1; - } - err = ipu_enable_channel(cam->ipu, chan); - if (err < 0) { - printk(KERN_ERR "ipu_enable_channel CSI_MEM\n"); - goto out_1; - } - - csi_buffer_num = 0; - - ipu_select_buffer(cam->ipu, chan, IPU_OUTPUT_BUFFER, 0); - ipu_select_buffer(cam->ipu, chan, IPU_OUTPUT_BUFFER, 1); - return err; -out_1: - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } -out_2: - return err; -} - -/*! - * Enable encoder task - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int csi_enc_enabling_tasks(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - CAMERA_TRACE("IPU:In csi_enc_enabling_tasks\n"); - - ipu_clear_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi); - err = ipu_request_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi, - csi_enc_callback, 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR "Error registering CSI_OUT_EOF irq\n"); - return err; - } - - INIT_WORK(&cam->csi_work_struct, csi_buf_work_func); - - err = csi_enc_setup(cam); - if (err != 0) { - printk(KERN_ERR "csi_enc_setup %d\n", err); - goto out1; - } - - return err; -out1: - ipu_free_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi, cam); - return err; -} - -/* - * Function definitions - */ - -/*! - * foreground_start - start the vf task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int foreground_start(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0, i = 0, screen_size; - char *base; - - if (!cam) { - printk(KERN_ERR "private is NULL\n"); - return -EIO; - } - - if (cam->overlay_active == true) { - pr_debug("already started.\n"); - return 0; - } - - get_disp_ipu(cam); - - for (i = 0; i < num_registered_fb; i++) { - char *idstr = registered_fb[i]->fix.id; - if (((strcmp(idstr, "DISP3 FG") == 0) && (cam->output < 3)) || - ((strcmp(idstr, "DISP4 FG") == 0) && (cam->output >= 3))) { - fbi = registered_fb[i]; - break; - } - } - - if (fbi == NULL) { - printk(KERN_ERR "DISP FG fb not found\n"); - return -EPERM; - } - - fbvar = fbi->var; - - /* Store the overlay frame buffer's original std */ - cam->fb_origin_std = fbvar.nonstd; - - if (cam->devtype == IMX5_V4L2 || cam->devtype == IMX6_V4L2) { - /* Use DP to do CSC so that we can get better performance */ - vf_out_format = IPU_PIX_FMT_NV12; - fbvar.nonstd = vf_out_format; - } else { - vf_out_format = IPU_PIX_FMT_RGB565; - fbvar.nonstd = 0; - } - - fbvar.bits_per_pixel = 16; - fbvar.xres = fbvar.xres_virtual = cam->win.w.width; - fbvar.yres = cam->win.w.height; - fbvar.yres_virtual = cam->win.w.height * 2; - fbvar.yoffset = 0; - fbvar.vmode &= ~FB_VMODE_YWRAP; - fbvar.accel_flags = FB_ACCEL_DOUBLE_FLAG; - fbvar.activate |= FB_ACTIVATE_FORCE; - fb_set_var(fbi, &fbvar); - - ipu_disp_set_window_pos(disp_ipu, MEM_FG_SYNC, cam->win.w.left, - cam->win.w.top); - - /* Fill black color for framebuffer */ - base = (char *) fbi->screen_base; - screen_size = fbi->var.xres * fbi->var.yres; - if (cam->devtype == IMX5_V4L2 || cam->devtype == IMX6_V4L2) { - memset(base, 0, screen_size); - base += screen_size; - for (i = 0; i < screen_size / 2; i++, base++) - *base = 0x80; - } else { - for (i = 0; i < screen_size * 2; i++, base++) - *base = 0x00; - } - - console_lock(); - fb_blank(fbi, FB_BLANK_UNBLANK); - console_unlock(); - - /* correct display ch buffer address */ - ipu_update_channel_buffer(disp_ipu, MEM_FG_SYNC, IPU_INPUT_BUFFER, - 0, fbi->fix.smem_start + - (fbi->fix.line_length * fbvar.yres)); - ipu_update_channel_buffer(disp_ipu, MEM_FG_SYNC, IPU_INPUT_BUFFER, - 1, fbi->fix.smem_start); - - err = csi_enc_enabling_tasks(cam); - if (err != 0) { - printk(KERN_ERR "Error csi enc enable fail\n"); - return err; - } - - cam->overlay_active = true; - return err; - -} - -/*! - * foreground_stop - stop the vf task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int foreground_stop(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0, i = 0; - struct fb_info *fbi = NULL; - struct fb_var_screeninfo fbvar; - ipu_channel_t chan = (cam->csi == 0) ? CSI_MEM0 : CSI_MEM1; - -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (cam->overlay_active == false) - return 0; - - err = ipu_disable_channel(cam->ipu, chan, true); - - ipu_uninit_channel(cam->ipu, chan); - - csi_buffer_num = 0; - buffer_num = 0; - - for (i = 0; i < num_registered_fb; i++) { - char *idstr = registered_fb[i]->fix.id; - if (((strcmp(idstr, "DISP3 FG") == 0) && (cam->output < 3)) || - ((strcmp(idstr, "DISP4 FG") == 0) && (cam->output >= 3))) { - fbi = registered_fb[i]; - break; - } - } - - if (fbi == NULL) { - printk(KERN_ERR "DISP FG fb not found\n"); - return -EPERM; - } - - console_lock(); - fb_blank(fbi, FB_BLANK_POWERDOWN); - console_unlock(); - - /* Set the overlay frame buffer std to what it is used to be */ - fbvar = fbi->var; - fbvar.accel_flags = FB_ACCEL_TRIPLE_FLAG; - fbvar.nonstd = cam->fb_origin_std; - fbvar.activate |= FB_ACTIVATE_FORCE; - fb_set_var(fbi, &fbvar); - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) - mipi_csi2_pixelclk_disable(mipi_csi2_info); - } - } -#endif - - flush_work(&cam->csi_work_struct); - cancel_work_sync(&cam->csi_work_struct); - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } - - cam->overlay_active = false; - return err; -} - -/*! - * Enable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int foreground_enable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - return ipu_enable_csi(cam->ipu, cam->csi); -} - -/*! - * Disable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int foreground_disable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - /* free csi eof irq firstly. - * when disable csi, wait for idmac eof. - * it requests eof irq again */ - ipu_free_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF + cam->csi, cam); - - return ipu_disable_csi(cam->ipu, cam->csi); -} - -/*! - * function to select foreground as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return status - */ -int foreground_sdc_select(void *private) -{ - cam_data *cam; - int err = 0; - if (private) { - cam = (cam_data *) private; - cam->vf_start_sdc = foreground_start; - cam->vf_stop_sdc = foreground_stop; - cam->vf_enable_csi = foreground_enable_csi; - cam->vf_disable_csi = foreground_disable_csi; - cam->overlay_active = false; - } else - err = -EIO; - - return err; -} -EXPORT_SYMBOL(foreground_sdc_select); - -/*! - * function to de-select foreground as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return int - */ -int foreground_sdc_deselect(void *private) -{ - cam_data *cam; - - if (private) { - cam = (cam_data *) private; - cam->vf_start_sdc = NULL; - cam->vf_stop_sdc = NULL; - cam->vf_enable_csi = NULL; - cam->vf_disable_csi = NULL; - } - return 0; -} -EXPORT_SYMBOL(foreground_sdc_deselect); - -/*! - * Init viewfinder task. - * - * @return Error code indicating success or failure - */ -__init int foreground_sdc_init(void) -{ - return 0; -} - -/*! - * Deinit viewfinder task. - * - * @return Error code indicating success or failure - */ -void __exit foreground_sdc_exit(void) -{ -} - -module_init(foreground_sdc_init); -module_exit(foreground_sdc_exit); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("IPU PRP VF SDC Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/ipu_prp_enc.c b/drivers/media/platform/mxc/capture/ipu_prp_enc.c deleted file mode 100644 index 1e4420b952f84f817aa808646d14edffac224b3f..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_prp_enc.c +++ /dev/null @@ -1,597 +0,0 @@ -/* - * Copyright 2004-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_prp_enc.c - * - * @brief IPU Use case for PRP-ENC - * - * @ingroup IPU - */ - -#include -#include -#include -#include -#include -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -#ifdef CAMERA_DBG - #define CAMERA_TRACE(x) (printk)x -#else - #define CAMERA_TRACE(x) -#endif - -static ipu_rotate_mode_t grotation = IPU_ROTATE_NONE; - -/* - * Function definitions - */ - -/*! - * IPU ENC callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t prp_enc_callback(int irq, void *dev_id) -{ - cam_data *cam = (cam_data *) dev_id; - - if (cam->enc_callback == NULL) - return IRQ_HANDLED; - - cam->enc_callback(irq, dev_id); - - return IRQ_HANDLED; -} - -/*! - * PrpENC enable channel setup function - * - * @param cam struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_enc_setup(cam_data *cam) -{ - ipu_channel_params_t enc; - int err = 0; - dma_addr_t dummy = cam->dummy_frame.buffer.m.offset; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - CAMERA_TRACE("In prp_enc_setup\n"); - if (!cam) { - printk(KERN_ERR "cam private is NULL\n"); - return -ENXIO; - } - memset(&enc, 0, sizeof(ipu_channel_params_t)); - - ipu_csi_get_window_size(cam->ipu, &enc.csi_prp_enc_mem.in_width, - &enc.csi_prp_enc_mem.in_height, cam->csi); - - enc.csi_prp_enc_mem.in_pixel_fmt = IPU_PIX_FMT_UYVY; - enc.csi_prp_enc_mem.out_width = cam->v2f.fmt.pix.width; - enc.csi_prp_enc_mem.out_height = cam->v2f.fmt.pix.height; - enc.csi_prp_enc_mem.csi = cam->csi; - if (cam->rotation >= IPU_ROTATE_90_RIGHT) { - enc.csi_prp_enc_mem.out_width = cam->v2f.fmt.pix.height; - enc.csi_prp_enc_mem.out_height = cam->v2f.fmt.pix.width; - } - - if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_YUV420P; - pr_info("YUV420\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YVU420) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_YVU420P; - pr_info("YVU420\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV422P) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_YUV422P; - pr_info("YUV422P\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_YUYV; - pr_info("YUYV\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_UYVY) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_UYVY; - pr_info("UYVY\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_NV12) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_NV12; - pr_info("NV12\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_BGR24; - pr_info("BGR24\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB24) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_RGB24; - pr_info("RGB24\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB565) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_RGB565; - pr_info("RGB565\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_BGR32) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_BGR32; - pr_info("BGR32\n"); - } else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB32) { - enc.csi_prp_enc_mem.out_pixel_fmt = IPU_PIX_FMT_RGB32; - pr_info("RGB32\n"); - } else { - printk(KERN_ERR "format not supported\n"); - return -EINVAL; - } - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) { - enc.csi_prp_enc_mem.mipi_en = true; - enc.csi_prp_enc_mem.mipi_vc = - mipi_csi2_get_virtual_channel(mipi_csi2_info); - enc.csi_prp_enc_mem.mipi_id = - mipi_csi2_get_datatype(mipi_csi2_info); - - mipi_csi2_pixelclk_enable(mipi_csi2_info); - } else { - enc.csi_prp_enc_mem.mipi_en = false; - enc.csi_prp_enc_mem.mipi_vc = 0; - enc.csi_prp_enc_mem.mipi_id = 0; - } - } else { - enc.csi_prp_enc_mem.mipi_en = false; - enc.csi_prp_enc_mem.mipi_vc = 0; - enc.csi_prp_enc_mem.mipi_id = 0; - } - } -#endif - - err = ipu_init_channel(cam->ipu, CSI_PRP_ENC_MEM, &enc); - if (err != 0) { - printk(KERN_ERR "ipu_init_channel %d\n", err); - return err; - } - - grotation = cam->rotation; - if (cam->rotation >= IPU_ROTATE_90_RIGHT) { - if (cam->rot_enc_bufs_vaddr[0]) { - dma_free_coherent(0, cam->rot_enc_buf_size[0], - cam->rot_enc_bufs_vaddr[0], - cam->rot_enc_bufs[0]); - } - if (cam->rot_enc_bufs_vaddr[1]) { - dma_free_coherent(0, cam->rot_enc_buf_size[1], - cam->rot_enc_bufs_vaddr[1], - cam->rot_enc_bufs[1]); - } - cam->rot_enc_buf_size[0] = - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage); - cam->rot_enc_bufs_vaddr[0] = - (void *)dma_alloc_coherent(0, cam->rot_enc_buf_size[0], - &cam->rot_enc_bufs[0], - GFP_DMA | GFP_KERNEL); - if (!cam->rot_enc_bufs_vaddr[0]) { - printk(KERN_ERR "alloc enc_bufs0\n"); - return -ENOMEM; - } - cam->rot_enc_buf_size[1] = - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage); - cam->rot_enc_bufs_vaddr[1] = - (void *)dma_alloc_coherent(0, cam->rot_enc_buf_size[1], - &cam->rot_enc_bufs[1], - GFP_DMA | GFP_KERNEL); - if (!cam->rot_enc_bufs_vaddr[1]) { - dma_free_coherent(0, cam->rot_enc_buf_size[0], - cam->rot_enc_bufs_vaddr[0], - cam->rot_enc_bufs[0]); - cam->rot_enc_bufs_vaddr[0] = NULL; - cam->rot_enc_bufs[0] = 0; - printk(KERN_ERR "alloc enc_bufs1\n"); - return -ENOMEM; - } - - err = ipu_init_channel_buffer(cam->ipu, CSI_PRP_ENC_MEM, - IPU_OUTPUT_BUFFER, - enc.csi_prp_enc_mem.out_pixel_fmt, - enc.csi_prp_enc_mem.out_width, - enc.csi_prp_enc_mem.out_height, - enc.csi_prp_enc_mem.out_width, - IPU_ROTATE_NONE, - cam->rot_enc_bufs[0], - cam->rot_enc_bufs[1], 0, 0, 0); - if (err != 0) { - printk(KERN_ERR "CSI_PRP_ENC_MEM err\n"); - return err; - } - - err = ipu_init_channel(cam->ipu, MEM_ROT_ENC_MEM, NULL); - if (err != 0) { - printk(KERN_ERR "MEM_ROT_ENC_MEM channel err\n"); - return err; - } - - err = ipu_init_channel_buffer(cam->ipu, MEM_ROT_ENC_MEM, - IPU_INPUT_BUFFER, - enc.csi_prp_enc_mem.out_pixel_fmt, - enc.csi_prp_enc_mem.out_width, - enc.csi_prp_enc_mem.out_height, - enc.csi_prp_enc_mem.out_width, - cam->rotation, - cam->rot_enc_bufs[0], - cam->rot_enc_bufs[1], 0, 0, 0); - if (err != 0) { - printk(KERN_ERR "MEM_ROT_ENC_MEM input buffer\n"); - return err; - } - - err = - ipu_init_channel_buffer(cam->ipu, MEM_ROT_ENC_MEM, - IPU_OUTPUT_BUFFER, - enc.csi_prp_enc_mem.out_pixel_fmt, - enc.csi_prp_enc_mem.out_height, - enc.csi_prp_enc_mem.out_width, - cam->v2f.fmt.pix.bytesperline / - bytes_per_pixel(enc.csi_prp_enc_mem. - out_pixel_fmt), - IPU_ROTATE_NONE, - dummy, dummy, 0, - cam->offset.u_offset, - cam->offset.v_offset); - if (err != 0) { - printk(KERN_ERR "MEM_ROT_ENC_MEM output buffer\n"); - return err; - } - - err = ipu_link_channels(cam->ipu, - CSI_PRP_ENC_MEM, MEM_ROT_ENC_MEM); - if (err < 0) { - printk(KERN_ERR - "link CSI_PRP_ENC_MEM-MEM_ROT_ENC_MEM\n"); - return err; - } - - err = ipu_enable_channel(cam->ipu, CSI_PRP_ENC_MEM); - if (err < 0) { - printk(KERN_ERR "ipu_enable_channel CSI_PRP_ENC_MEM\n"); - return err; - } - err = ipu_enable_channel(cam->ipu, MEM_ROT_ENC_MEM); - if (err < 0) { - printk(KERN_ERR "ipu_enable_channel MEM_ROT_ENC_MEM\n"); - return err; - } - - ipu_select_buffer(cam->ipu, CSI_PRP_ENC_MEM, - IPU_OUTPUT_BUFFER, 0); - ipu_select_buffer(cam->ipu, CSI_PRP_ENC_MEM, - IPU_OUTPUT_BUFFER, 1); - } else { - err = - ipu_init_channel_buffer(cam->ipu, CSI_PRP_ENC_MEM, - IPU_OUTPUT_BUFFER, - enc.csi_prp_enc_mem.out_pixel_fmt, - enc.csi_prp_enc_mem.out_width, - enc.csi_prp_enc_mem.out_height, - cam->v2f.fmt.pix.bytesperline / - bytes_per_pixel(enc.csi_prp_enc_mem. - out_pixel_fmt), - cam->rotation, - dummy, dummy, 0, - cam->offset.u_offset, - cam->offset.v_offset); - if (err != 0) { - printk(KERN_ERR "CSI_PRP_ENC_MEM output buffer\n"); - return err; - } - err = ipu_enable_channel(cam->ipu, CSI_PRP_ENC_MEM); - if (err < 0) { - printk(KERN_ERR "ipu_enable_channel CSI_PRP_ENC_MEM\n"); - return err; - } - } - - return err; -} - -/*! - * function to update physical buffer address for encorder IDMA channel - * - * @param private pointer to cam_data structure - * @param eba physical buffer address for encorder IDMA channel - * - * @return status - */ -static int prp_enc_eba_update(void *private, dma_addr_t eba) -{ - int err = 0; - cam_data *cam = (cam_data *) private; - struct ipu_soc *ipu = cam->ipu; - int *buffer_num = &cam->ping_pong_csi; - - pr_debug("eba %x\n", eba); - if (grotation >= IPU_ROTATE_90_RIGHT) { - err = ipu_update_channel_buffer(ipu, MEM_ROT_ENC_MEM, - IPU_OUTPUT_BUFFER, *buffer_num, - eba); - } else { - err = ipu_update_channel_buffer(ipu, CSI_PRP_ENC_MEM, - IPU_OUTPUT_BUFFER, *buffer_num, - eba); - } - if (err != 0) { - if (grotation >= IPU_ROTATE_90_RIGHT) { - ipu_clear_buffer_ready(ipu, MEM_ROT_ENC_MEM, - IPU_OUTPUT_BUFFER, - *buffer_num); - err = ipu_update_channel_buffer(ipu, MEM_ROT_ENC_MEM, - IPU_OUTPUT_BUFFER, - *buffer_num, - eba); - } else { - ipu_clear_buffer_ready(ipu, CSI_PRP_ENC_MEM, - IPU_OUTPUT_BUFFER, - *buffer_num); - err = ipu_update_channel_buffer(ipu, CSI_PRP_ENC_MEM, - IPU_OUTPUT_BUFFER, - *buffer_num, - eba); - } - - if (err != 0) { - pr_err("ERROR: v4l2 capture: fail to update " - "buf%d\n", *buffer_num); - return err; - } - } - - if (grotation >= IPU_ROTATE_90_RIGHT) { - ipu_select_buffer(ipu, MEM_ROT_ENC_MEM, IPU_OUTPUT_BUFFER, - *buffer_num); - } else { - ipu_select_buffer(ipu, CSI_PRP_ENC_MEM, IPU_OUTPUT_BUFFER, - *buffer_num); - } - - *buffer_num = (*buffer_num == 0) ? 1 : 0; - return 0; -} - -/*! - * Enable encoder task - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_enc_enabling_tasks(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - CAMERA_TRACE("IPU:In prp_enc_enabling_tasks\n"); - - cam->dummy_frame.vaddress = dma_alloc_coherent(0, - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage), - &cam->dummy_frame.paddress, - GFP_DMA | GFP_KERNEL); - if (cam->dummy_frame.vaddress == 0) { - pr_err("ERROR: v4l2 capture: Allocate dummy frame " - "failed.\n"); - return -ENOBUFS; - } - cam->dummy_frame.buffer.type = V4L2_BUF_TYPE_PRIVATE; - cam->dummy_frame.buffer.length = - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage); - cam->dummy_frame.buffer.m.offset = cam->dummy_frame.paddress; - - if (cam->rotation >= IPU_ROTATE_90_RIGHT) { - err = ipu_request_irq(cam->ipu, IPU_IRQ_PRP_ENC_ROT_OUT_EOF, - prp_enc_callback, 0, "Mxc Camera", cam); - } else { - err = ipu_request_irq(cam->ipu, IPU_IRQ_PRP_ENC_OUT_EOF, - prp_enc_callback, 0, "Mxc Camera", cam); - } - if (err != 0) { - printk(KERN_ERR "Error registering rot irq\n"); - return err; - } - - err = prp_enc_setup(cam); - if (err != 0) { - printk(KERN_ERR "prp_enc_setup %d\n", err); - return err; - } - - return err; -} - -/*! - * Disable encoder task - * @param private struct cam_data * mxc capture instance - * - * @return int - */ -static int prp_enc_disabling_tasks(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (cam->rotation >= IPU_ROTATE_90_RIGHT) { - ipu_free_irq(cam->ipu, IPU_IRQ_PRP_ENC_ROT_OUT_EOF, cam); - ipu_unlink_channels(cam->ipu, CSI_PRP_ENC_MEM, MEM_ROT_ENC_MEM); - } - - err = ipu_disable_channel(cam->ipu, CSI_PRP_ENC_MEM, true); - if (cam->rotation >= IPU_ROTATE_90_RIGHT) - err |= ipu_disable_channel(cam->ipu, MEM_ROT_ENC_MEM, true); - - ipu_uninit_channel(cam->ipu, CSI_PRP_ENC_MEM); - if (cam->rotation >= IPU_ROTATE_90_RIGHT) - ipu_uninit_channel(cam->ipu, MEM_ROT_ENC_MEM); - - if (cam->dummy_frame.vaddress != 0) { - dma_free_coherent(0, cam->dummy_frame.buffer.length, - cam->dummy_frame.vaddress, - cam->dummy_frame.paddress); - cam->dummy_frame.vaddress = 0; - } - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) - mipi_csi2_pixelclk_disable(mipi_csi2_info); - } - } -#endif - - return err; -} - -/*! - * Enable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_enc_enable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - return ipu_enable_csi(cam->ipu, cam->csi); -} - -/*! - * Disable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_enc_disable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - /* free csi eof irq firstly. - * when disable csi, wait for idmac eof. - * it requests eof irq again */ - if (cam->rotation < IPU_ROTATE_90_RIGHT) - ipu_free_irq(cam->ipu, IPU_IRQ_PRP_ENC_OUT_EOF, cam); - - return ipu_disable_csi(cam->ipu, cam->csi); -} - -/*! - * function to select PRP-ENC as the working path - * - * @param private struct cam_data * mxc capture instance - * - * @return int - */ -int prp_enc_select(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - - if (cam) { - cam->enc_update_eba = prp_enc_eba_update; - cam->enc_enable = prp_enc_enabling_tasks; - cam->enc_disable = prp_enc_disabling_tasks; - cam->enc_enable_csi = prp_enc_enable_csi; - cam->enc_disable_csi = prp_enc_disable_csi; - } else { - err = -EIO; - } - - return err; -} -EXPORT_SYMBOL(prp_enc_select); - -/*! - * function to de-select PRP-ENC as the working path - * - * @param private struct cam_data * mxc capture instance - * - * @return int - */ -int prp_enc_deselect(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - - if (cam) { - cam->enc_update_eba = NULL; - cam->enc_enable = NULL; - cam->enc_disable = NULL; - cam->enc_enable_csi = NULL; - cam->enc_disable_csi = NULL; - if (cam->rot_enc_bufs_vaddr[0]) { - dma_free_coherent(0, cam->rot_enc_buf_size[0], - cam->rot_enc_bufs_vaddr[0], - cam->rot_enc_bufs[0]); - cam->rot_enc_bufs_vaddr[0] = NULL; - cam->rot_enc_bufs[0] = 0; - } - if (cam->rot_enc_bufs_vaddr[1]) { - dma_free_coherent(0, cam->rot_enc_buf_size[1], - cam->rot_enc_bufs_vaddr[1], - cam->rot_enc_bufs[1]); - cam->rot_enc_bufs_vaddr[1] = NULL; - cam->rot_enc_bufs[1] = 0; - } - } - - return err; -} -EXPORT_SYMBOL(prp_enc_deselect); - -/*! - * Init the Encorder channels - * - * @return Error code indicating success or failure - */ -__init int prp_enc_init(void) -{ - return 0; -} - -/*! - * Deinit the Encorder channels - * - */ -void __exit prp_enc_exit(void) -{ -} - -module_init(prp_enc_init); -module_exit(prp_enc_exit); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("IPU PRP ENC Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/ipu_prp_sw.h b/drivers/media/platform/mxc/capture/ipu_prp_sw.h deleted file mode 100644 index be02ab061e20fc038df4f42440ce51732be6e7b9..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_prp_sw.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2004-2014 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_prp_sw.h - * - * @brief This file contains the IPU PRP use case driver header. - * - * @ingroup IPU - */ - -#ifndef _INCLUDE_IPU__PRP_SW_H_ -#define _INCLUDE_IPU__PRP_SW_H_ - -int csi_enc_select(void *private); -int csi_enc_deselect(void *private); -int prp_enc_select(void *private); -int prp_enc_deselect(void *private); -#ifdef CONFIG_MXC_IPU_PRP_VF_SDC -int prp_vf_sdc_select(void *private); -int prp_vf_sdc_deselect(void *private); -int prp_vf_sdc_select_bg(void *private); -int prp_vf_sdc_deselect_bg(void *private); -#else -int foreground_sdc_select(void *private); -int foreground_sdc_deselect(void *private); -int bg_overlay_sdc_select(void *private); -int bg_overlay_sdc_deselect(void *private); -#endif -int prp_still_select(void *private); -int prp_still_deselect(void *private); - -#endif diff --git a/drivers/media/platform/mxc/capture/ipu_prp_vf_sdc.c b/drivers/media/platform/mxc/capture/ipu_prp_vf_sdc.c deleted file mode 100644 index b9610f1ed820ae3907b1aec48fdbdae514fef48b..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_prp_vf_sdc.c +++ /dev/null @@ -1,582 +0,0 @@ -/* - * Copyright 2004-2014 Freescale Semiconductor, Inc. All Rights Reserved. - */ -/* * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_prp_vf_sdc.c - * - * @brief IPU Use case for PRP-VF - * - * @ingroup IPU - */ - -#include -#include -#include -#include -#include -#include -#include -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -static int buffer_num; -static struct ipu_soc *disp_ipu; - -static void get_disp_ipu(cam_data *cam) -{ - if (cam->output > 2) - disp_ipu = ipu_get_soc(1); /* using DISP4 */ - else - disp_ipu = ipu_get_soc(0); -} - -static irqreturn_t prpvf_rot_eof_callback(int irq, void *dev_id) -{ - cam_data *cam = dev_id; - pr_debug("buffer_num %d\n", buffer_num); - - if (cam->vf_rotation >= IPU_ROTATE_VERT_FLIP) { - ipu_select_buffer(disp_ipu, MEM_FG_SYNC, - IPU_INPUT_BUFFER, buffer_num); - buffer_num = (buffer_num == 0) ? 1 : 0; - ipu_select_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_OUTPUT_BUFFER, buffer_num); - } else { - ipu_select_buffer(disp_ipu, MEM_FG_SYNC, - IPU_INPUT_BUFFER, buffer_num); - buffer_num = (buffer_num == 0) ? 1 : 0; - ipu_select_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, buffer_num); - } - return IRQ_HANDLED; -} -/* - * Function definitions - */ - -/*! - * prpvf_start - start the vf task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int prpvf_start(void *private) -{ - struct fb_var_screeninfo fbvar; - struct fb_info *fbi = NULL; - cam_data *cam = (cam_data *) private; - ipu_channel_params_t vf; - u32 vf_out_format = 0; - u32 size = 2, temp = 0; - int err = 0, i = 0; - short *tmp, color; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (!cam) { - printk(KERN_ERR "private is NULL\n"); - return -EIO; - } - - if (cam->overlay_active == true) { - pr_debug("already started.\n"); - return 0; - } - - get_disp_ipu(cam); - - for (i = 0; i < num_registered_fb; i++) { - char *idstr = registered_fb[i]->fix.id; - if (((strcmp(idstr, "DISP3 FG") == 0) && (cam->output < 3)) || - ((strcmp(idstr, "DISP4 FG") == 0) && (cam->output >= 3))) { - fbi = registered_fb[i]; - break; - } - } - - if (fbi == NULL) { - printk(KERN_ERR "DISP FG fb not found\n"); - return -EPERM; - } - - fbvar = fbi->var; - - /* Store the overlay frame buffer's original std */ - cam->fb_origin_std = fbvar.nonstd; - - if (cam->devtype == IMX5_V4L2 || cam->devtype == IMX6_V4L2) { - /* Use DP to do CSC so that we can get better performance */ - vf_out_format = IPU_PIX_FMT_UYVY; - fbvar.nonstd = vf_out_format; - color = 0x80; - } else { - vf_out_format = IPU_PIX_FMT_RGB565; - fbvar.nonstd = 0; - color = 0x0; - } - - fbvar.bits_per_pixel = 16; - fbvar.xres = fbvar.xres_virtual = cam->win.w.width; - fbvar.yres = cam->win.w.height; - fbvar.yres_virtual = cam->win.w.height * 2; - fbvar.yoffset = 0; - fbvar.accel_flags = FB_ACCEL_DOUBLE_FLAG; - fbvar.activate |= FB_ACTIVATE_FORCE; - fb_set_var(fbi, &fbvar); - - ipu_disp_set_window_pos(disp_ipu, MEM_FG_SYNC, cam->win.w.left, - cam->win.w.top); - - /* Fill black color for framebuffer */ - tmp = (short *) fbi->screen_base; - for (i = 0; i < (fbi->fix.line_length * fbi->var.yres)/2; - i++, tmp++) - *tmp = color; - - console_lock(); - fb_blank(fbi, FB_BLANK_UNBLANK); - console_unlock(); - - /* correct display ch buffer address */ - ipu_update_channel_buffer(disp_ipu, MEM_FG_SYNC, IPU_INPUT_BUFFER, - 0, fbi->fix.smem_start + - (fbi->fix.line_length * fbvar.yres)); - ipu_update_channel_buffer(disp_ipu, MEM_FG_SYNC, IPU_INPUT_BUFFER, - 1, fbi->fix.smem_start); - - memset(&vf, 0, sizeof(ipu_channel_params_t)); - ipu_csi_get_window_size(cam->ipu, &vf.csi_prp_vf_mem.in_width, - &vf.csi_prp_vf_mem.in_height, cam->csi); - vf.csi_prp_vf_mem.in_pixel_fmt = IPU_PIX_FMT_UYVY; - vf.csi_prp_vf_mem.out_width = cam->win.w.width; - vf.csi_prp_vf_mem.out_height = cam->win.w.height; - vf.csi_prp_vf_mem.csi = cam->csi; - if (cam->vf_rotation >= IPU_ROTATE_90_RIGHT) { - vf.csi_prp_vf_mem.out_width = cam->win.w.height; - vf.csi_prp_vf_mem.out_height = cam->win.w.width; - } - vf.csi_prp_vf_mem.out_pixel_fmt = vf_out_format; - size = cam->win.w.width * cam->win.w.height * size; - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) { - vf.csi_prp_vf_mem.mipi_en = true; - vf.csi_prp_vf_mem.mipi_vc = - mipi_csi2_get_virtual_channel(mipi_csi2_info); - vf.csi_prp_vf_mem.mipi_id = - mipi_csi2_get_datatype(mipi_csi2_info); - - mipi_csi2_pixelclk_enable(mipi_csi2_info); - } else { - vf.csi_prp_vf_mem.mipi_en = false; - vf.csi_prp_vf_mem.mipi_vc = 0; - vf.csi_prp_vf_mem.mipi_id = 0; - } - } else { - vf.csi_prp_vf_mem.mipi_en = false; - vf.csi_prp_vf_mem.mipi_vc = 0; - vf.csi_prp_vf_mem.mipi_id = 0; - } - } -#endif - - err = ipu_init_channel(cam->ipu, CSI_PRP_VF_MEM, &vf); - if (err != 0) - goto out_5; - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - } - cam->vf_bufs_size[0] = PAGE_ALIGN(size); - cam->vf_bufs_vaddr[0] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[0], - (dma_addr_t *) & - cam->vf_bufs[0], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[0] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_4; - } - cam->vf_bufs_size[1] = PAGE_ALIGN(size); - cam->vf_bufs_vaddr[1] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[1], - (dma_addr_t *) & - cam->vf_bufs[1], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[1] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_3; - } - pr_debug("vf_bufs %x %x\n", cam->vf_bufs[0], cam->vf_bufs[1]); - - if (cam->vf_rotation >= IPU_ROTATE_VERT_FLIP) { - err = ipu_init_channel_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, - vf_out_format, - vf.csi_prp_vf_mem.out_width, - vf.csi_prp_vf_mem.out_height, - vf.csi_prp_vf_mem.out_width, - IPU_ROTATE_NONE, - cam->vf_bufs[0], cam->vf_bufs[1], - 0, 0, 0); - if (err != 0) - goto out_3; - - err = ipu_init_channel(cam->ipu, MEM_ROT_VF_MEM, NULL); - if (err != 0) { - printk(KERN_ERR "Error MEM_ROT_VF_MEM channel\n"); - goto out_3; - } - - err = ipu_init_channel_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_INPUT_BUFFER, - vf_out_format, - vf.csi_prp_vf_mem.out_width, - vf.csi_prp_vf_mem.out_height, - vf.csi_prp_vf_mem.out_width, - cam->vf_rotation, - cam->vf_bufs[0], - cam->vf_bufs[1], - 0, 0, 0); - if (err != 0) { - printk(KERN_ERR "Error MEM_ROT_VF_MEM input buffer\n"); - goto out_2; - } - - if (cam->vf_rotation < IPU_ROTATE_90_RIGHT) { - temp = vf.csi_prp_vf_mem.out_width; - vf.csi_prp_vf_mem.out_width = - vf.csi_prp_vf_mem.out_height; - vf.csi_prp_vf_mem.out_height = temp; - } - - err = ipu_init_channel_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_OUTPUT_BUFFER, - vf_out_format, - vf.csi_prp_vf_mem.out_height, - vf.csi_prp_vf_mem.out_width, - vf.csi_prp_vf_mem.out_height, - IPU_ROTATE_NONE, - fbi->fix.smem_start + - (fbi->fix.line_length * - fbi->var.yres), - fbi->fix.smem_start, 0, 0, 0); - - if (err != 0) { - printk(KERN_ERR "Error MEM_ROT_VF_MEM output buffer\n"); - goto out_2; - } - - ipu_clear_irq(cam->ipu, IPU_IRQ_PRP_VF_ROT_OUT_EOF); - err = ipu_request_irq(cam->ipu, IPU_IRQ_PRP_VF_ROT_OUT_EOF, - prpvf_rot_eof_callback, - 0, "Mxc Camera", cam); - if (err < 0) { - printk(KERN_ERR "Error request irq:IPU_IRQ_PRP_VF_ROT_OUT_EOF\n"); - goto out_2; - } - - err = ipu_link_channels(cam->ipu, - CSI_PRP_VF_MEM, MEM_ROT_VF_MEM); - if (err < 0) { - printk(KERN_ERR - "Error link CSI_PRP_VF_MEM-MEM_ROT_VF_MEM\n"); - goto out_1; - } - - ipu_enable_channel(cam->ipu, CSI_PRP_VF_MEM); - ipu_enable_channel(cam->ipu, MEM_ROT_VF_MEM); - - ipu_select_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, 0); - ipu_select_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, 1); - ipu_select_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_OUTPUT_BUFFER, 0); - } else { - err = ipu_init_channel_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, - vf_out_format, cam->win.w.width, - cam->win.w.height, - cam->win.w.width, - cam->vf_rotation, - fbi->fix.smem_start + - (fbi->fix.line_length * - fbi->var.yres), - fbi->fix.smem_start, 0, 0, 0); - if (err != 0) { - printk(KERN_ERR "Error initializing CSI_PRP_VF_MEM\n"); - goto out_4; - } - ipu_clear_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF); - err = ipu_request_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF, - prpvf_rot_eof_callback, - 0, "Mxc Camera", cam); - if (err < 0) { - printk(KERN_ERR "Error request irq:IPU_IRQ_PRP_VF_OUT_EOF\n"); - goto out_4; - } - - ipu_enable_channel(cam->ipu, CSI_PRP_VF_MEM); - - ipu_select_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, 0); - } - - cam->overlay_active = true; - return err; - -out_1: - ipu_free_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF, NULL); -out_2: - if (cam->vf_rotation >= IPU_ROTATE_VERT_FLIP) - ipu_uninit_channel(cam->ipu, MEM_ROT_VF_MEM); -out_3: - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } -out_4: - ipu_uninit_channel(cam->ipu, CSI_PRP_VF_MEM); -out_5: - return err; -} - -/*! - * prpvf_stop - stop the vf task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int prpvf_stop(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0, i = 0; - struct fb_info *fbi = NULL; - struct fb_var_screeninfo fbvar; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (cam->overlay_active == false) - return 0; - - for (i = 0; i < num_registered_fb; i++) { - char *idstr = registered_fb[i]->fix.id; - if (((strcmp(idstr, "DISP3 FG") == 0) && (cam->output < 3)) || - ((strcmp(idstr, "DISP4 FG") == 0) && (cam->output >= 3))) { - fbi = registered_fb[i]; - break; - } - } - - if (fbi == NULL) { - printk(KERN_ERR "DISP FG fb not found\n"); - return -EPERM; - } - - if (cam->vf_rotation >= IPU_ROTATE_VERT_FLIP) { - ipu_unlink_channels(cam->ipu, CSI_PRP_VF_MEM, MEM_ROT_VF_MEM); - ipu_free_irq(cam->ipu, IPU_IRQ_PRP_VF_ROT_OUT_EOF, cam); - } - buffer_num = 0; - - ipu_disable_channel(cam->ipu, CSI_PRP_VF_MEM, true); - - if (cam->vf_rotation >= IPU_ROTATE_VERT_FLIP) { - ipu_disable_channel(cam->ipu, MEM_ROT_VF_MEM, true); - ipu_uninit_channel(cam->ipu, MEM_ROT_VF_MEM); - } - ipu_uninit_channel(cam->ipu, CSI_PRP_VF_MEM); - - console_lock(); - fb_blank(fbi, FB_BLANK_POWERDOWN); - console_unlock(); - - /* Set the overlay frame buffer std to what it is used to be */ - fbvar = fbi->var; - fbvar.accel_flags = FB_ACCEL_TRIPLE_FLAG; - fbvar.nonstd = cam->fb_origin_std; - fbvar.activate |= FB_ACTIVATE_FORCE; - fb_set_var(fbi, &fbvar); - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) - mipi_csi2_pixelclk_disable(mipi_csi2_info); - } - } -#endif - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], - (dma_addr_t) cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], - (dma_addr_t) cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } - - cam->overlay_active = false; - return err; -} - -/*! - * Enable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_vf_enable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - return ipu_enable_csi(cam->ipu, cam->csi); -} - -/*! - * Disable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_vf_disable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - /* free csi eof irq firstly. - * when disable csi, wait for idmac eof. - * it requests eof irq again */ - if (cam->vf_rotation < IPU_ROTATE_VERT_FLIP) - ipu_free_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF, cam); - - return ipu_disable_csi(cam->ipu, cam->csi); -} - -/*! - * function to select PRP-VF as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return status - */ -int prp_vf_sdc_select(void *private) -{ - cam_data *cam; - int err = 0; - if (private) { - cam = (cam_data *) private; - cam->vf_start_sdc = prpvf_start; - cam->vf_stop_sdc = prpvf_stop; - cam->vf_enable_csi = prp_vf_enable_csi; - cam->vf_disable_csi = prp_vf_disable_csi; - cam->overlay_active = false; - } else - err = -EIO; - - return err; -} -EXPORT_SYMBOL(prp_vf_sdc_select); - -/*! - * function to de-select PRP-VF as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return int - */ -int prp_vf_sdc_deselect(void *private) -{ - cam_data *cam; - - if (private) { - cam = (cam_data *) private; - cam->vf_start_sdc = NULL; - cam->vf_stop_sdc = NULL; - cam->vf_enable_csi = NULL; - cam->vf_disable_csi = NULL; - } - return 0; -} -EXPORT_SYMBOL(prp_vf_sdc_deselect); - -/*! - * Init viewfinder task. - * - * @return Error code indicating success or failure - */ -__init int prp_vf_sdc_init(void) -{ - return 0; -} - -/*! - * Deinit viewfinder task. - * - * @return Error code indicating success or failure - */ -void __exit prp_vf_sdc_exit(void) -{ -} - -module_init(prp_vf_sdc_init); -module_exit(prp_vf_sdc_exit); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("IPU PRP VF SDC Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/ipu_prp_vf_sdc_bg.c b/drivers/media/platform/mxc/capture/ipu_prp_vf_sdc_bg.c deleted file mode 100644 index a24d82dfca638b10bb1ff4dae100973082e78a94..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_prp_vf_sdc_bg.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * Copyright 2004-2014 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_prp_vf_sdc_bg.c - * - * @brief IPU Use case for PRP-VF back-ground - * - * @ingroup IPU - */ -#include -#include -#include -#include -#include -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -static int buffer_num; -static int buffer_ready; -static struct ipu_soc *disp_ipu; - -static void get_disp_ipu(cam_data *cam) -{ - if (cam->output > 2) - disp_ipu = ipu_get_soc(1); /* using DISP4 */ - else - disp_ipu = ipu_get_soc(0); -} - -/* - * Function definitions - */ - -/*! - * SDC V-Sync callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t prpvf_sdc_vsync_callback(int irq, void *dev_id) -{ - cam_data *cam = dev_id; - if (buffer_ready > 0) { - ipu_select_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_OUTPUT_BUFFER, 0); - buffer_ready--; - } - - return IRQ_HANDLED; -} - -/*! - * VF EOF callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t prpvf_vf_eof_callback(int irq, void *dev_id) -{ - cam_data *cam = dev_id; - pr_debug("buffer_ready %d buffer_num %d\n", buffer_ready, buffer_num); - - ipu_select_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_INPUT_BUFFER, buffer_num); - buffer_num = (buffer_num == 0) ? 1 : 0; - ipu_select_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, buffer_num); - buffer_ready++; - return IRQ_HANDLED; -} - -/*! - * prpvf_start - start the vf task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int prpvf_start(void *private) -{ - cam_data *cam = (cam_data *) private; - ipu_channel_params_t vf; - u32 format; - u32 offset; - u32 bpp, size = 3; - int err = 0; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (!cam) { - printk(KERN_ERR "private is NULL\n"); - return -EIO; - } - - if (cam->overlay_active == true) { - pr_debug("already start.\n"); - return 0; - } - - get_disp_ipu(cam); - - format = cam->v4l2_fb.fmt.pixelformat; - if (cam->v4l2_fb.fmt.pixelformat == IPU_PIX_FMT_BGR24) { - bpp = 3, size = 3; - pr_info("BGR24\n"); - } else if (cam->v4l2_fb.fmt.pixelformat == IPU_PIX_FMT_RGB565) { - bpp = 2, size = 2; - pr_info("RGB565\n"); - } else if (cam->v4l2_fb.fmt.pixelformat == IPU_PIX_FMT_BGR32) { - bpp = 4, size = 4; - pr_info("BGR32\n"); - } else { - printk(KERN_ERR - "unsupported fix format from the framebuffer.\n"); - return -EINVAL; - } - - offset = cam->v4l2_fb.fmt.bytesperline * cam->win.w.top + - size * cam->win.w.left; - - if (cam->v4l2_fb.base == 0) - printk(KERN_ERR "invalid frame buffer address.\n"); - else - offset += (u32) cam->v4l2_fb.base; - - memset(&vf, 0, sizeof(ipu_channel_params_t)); - ipu_csi_get_window_size(cam->ipu, &vf.csi_prp_vf_mem.in_width, - &vf.csi_prp_vf_mem.in_height, cam->csi); - vf.csi_prp_vf_mem.in_pixel_fmt = IPU_PIX_FMT_UYVY; - vf.csi_prp_vf_mem.out_width = cam->win.w.width; - vf.csi_prp_vf_mem.out_height = cam->win.w.height; - vf.csi_prp_vf_mem.csi = cam->csi; - if (cam->vf_rotation >= IPU_ROTATE_90_RIGHT) { - vf.csi_prp_vf_mem.out_width = cam->win.w.height; - vf.csi_prp_vf_mem.out_height = cam->win.w.width; - } - vf.csi_prp_vf_mem.out_pixel_fmt = format; - size = cam->win.w.width * cam->win.w.height * size; - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) { - vf.csi_prp_vf_mem.mipi_en = true; - vf.csi_prp_vf_mem.mipi_vc = - mipi_csi2_get_virtual_channel(mipi_csi2_info); - vf.csi_prp_vf_mem.mipi_id = - mipi_csi2_get_datatype(mipi_csi2_info); - - mipi_csi2_pixelclk_enable(mipi_csi2_info); - } else { - vf.csi_prp_vf_mem.mipi_en = false; - vf.csi_prp_vf_mem.mipi_vc = 0; - vf.csi_prp_vf_mem.mipi_id = 0; - } - } else { - vf.csi_prp_vf_mem.mipi_en = false; - vf.csi_prp_vf_mem.mipi_vc = 0; - vf.csi_prp_vf_mem.mipi_id = 0; - } - } -#endif - - err = ipu_init_channel(cam->ipu, CSI_PRP_VF_MEM, &vf); - if (err != 0) - goto out_4; - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], cam->vf_bufs[0]); - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], cam->vf_bufs[1]); - } - cam->vf_bufs_size[0] = PAGE_ALIGN(size); - cam->vf_bufs_vaddr[0] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[0], - &cam->vf_bufs[0], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[0] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_3; - } - cam->vf_bufs_size[1] = PAGE_ALIGN(size); - cam->vf_bufs_vaddr[1] = (void *)dma_alloc_coherent(0, - cam->vf_bufs_size[1], - &cam->vf_bufs[1], - GFP_DMA | - GFP_KERNEL); - if (cam->vf_bufs_vaddr[1] == NULL) { - printk(KERN_ERR "Error to allocate vf buffer\n"); - err = -ENOMEM; - goto out_3; - } - - err = ipu_init_channel_buffer(cam->ipu, CSI_PRP_VF_MEM, - IPU_OUTPUT_BUFFER, - format, vf.csi_prp_vf_mem.out_width, - vf.csi_prp_vf_mem.out_height, - vf.csi_prp_vf_mem.out_width, - IPU_ROTATE_NONE, - cam->vf_bufs[0], - cam->vf_bufs[1], - 0, 0, 0); - if (err != 0) { - printk(KERN_ERR "Error initializing CSI_PRP_VF_MEM\n"); - goto out_3; - } - err = ipu_init_channel(cam->ipu, MEM_ROT_VF_MEM, NULL); - if (err != 0) { - printk(KERN_ERR "Error MEM_ROT_VF_MEM channel\n"); - goto out_3; - } - - err = ipu_init_channel_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_INPUT_BUFFER, - format, vf.csi_prp_vf_mem.out_width, - vf.csi_prp_vf_mem.out_height, - vf.csi_prp_vf_mem.out_width, - cam->vf_rotation, - cam->vf_bufs[0], - cam->vf_bufs[1], - 0, 0, 0); - if (err != 0) { - printk(KERN_ERR "Error MEM_ROT_VF_MEM input buffer\n"); - goto out_2; - } - - if (cam->vf_rotation >= IPU_ROTATE_90_RIGHT) { - err = ipu_init_channel_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_OUTPUT_BUFFER, - format, - vf.csi_prp_vf_mem.out_height, - vf.csi_prp_vf_mem.out_width, - cam->overlay_fb->var.xres * bpp, - IPU_ROTATE_NONE, - offset, 0, 0, 0, 0); - - if (err != 0) { - printk(KERN_ERR "Error MEM_ROT_VF_MEM output buffer\n"); - goto out_2; - } - } else { - err = ipu_init_channel_buffer(cam->ipu, MEM_ROT_VF_MEM, - IPU_OUTPUT_BUFFER, - format, - vf.csi_prp_vf_mem.out_width, - vf.csi_prp_vf_mem.out_height, - cam->overlay_fb->var.xres * bpp, - IPU_ROTATE_NONE, - offset, 0, 0, 0, 0); - if (err != 0) { - printk(KERN_ERR "Error MEM_ROT_VF_MEM output buffer\n"); - goto out_2; - } - } - - ipu_clear_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF); - err = ipu_request_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF, - prpvf_vf_eof_callback, - 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR - "Error registering IPU_IRQ_PRP_VF_OUT_EOF irq.\n"); - goto out_2; - } - - ipu_clear_irq(disp_ipu, IPU_IRQ_BG_SF_END); - err = ipu_request_irq(disp_ipu, IPU_IRQ_BG_SF_END, - prpvf_sdc_vsync_callback, - 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR "Error registering IPU_IRQ_BG_SF_END irq.\n"); - goto out_1; - } - - ipu_enable_channel(cam->ipu, CSI_PRP_VF_MEM); - ipu_enable_channel(cam->ipu, MEM_ROT_VF_MEM); - - buffer_num = 0; - buffer_ready = 0; - ipu_select_buffer(cam->ipu, CSI_PRP_VF_MEM, IPU_OUTPUT_BUFFER, 0); - - cam->overlay_active = true; - return err; - -out_1: - ipu_free_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF, NULL); -out_2: - ipu_uninit_channel(cam->ipu, MEM_ROT_VF_MEM); -out_3: - ipu_uninit_channel(cam->ipu, CSI_PRP_VF_MEM); -out_4: - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } - if (cam->rot_vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->rot_vf_buf_size[0], - cam->rot_vf_bufs_vaddr[0], - cam->rot_vf_bufs[0]); - cam->rot_vf_bufs_vaddr[0] = NULL; - cam->rot_vf_bufs[0] = 0; - } - if (cam->rot_vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->rot_vf_buf_size[1], - cam->rot_vf_bufs_vaddr[1], - cam->rot_vf_bufs[1]); - cam->rot_vf_bufs_vaddr[1] = NULL; - cam->rot_vf_bufs[1] = 0; - } - return err; -} - -/*! - * prpvf_stop - stop the vf task - * - * @param private cam_data * mxc v4l2 main structure - * - */ -static int prpvf_stop(void *private) -{ - cam_data *cam = (cam_data *) private; -#ifdef CONFIG_MXC_MIPI_CSI2 - void *mipi_csi2_info; - int ipu_id; - int csi_id; -#endif - - if (cam->overlay_active == false) - return 0; - - ipu_free_irq(disp_ipu, IPU_IRQ_BG_SF_END, cam); - - ipu_disable_channel(cam->ipu, CSI_PRP_VF_MEM, true); - ipu_disable_channel(cam->ipu, MEM_ROT_VF_MEM, true); - ipu_uninit_channel(cam->ipu, CSI_PRP_VF_MEM); - ipu_uninit_channel(cam->ipu, MEM_ROT_VF_MEM); - -#ifdef CONFIG_MXC_MIPI_CSI2 - mipi_csi2_info = mipi_csi2_get_info(); - - if (mipi_csi2_info) { - if (mipi_csi2_get_status(mipi_csi2_info)) { - ipu_id = mipi_csi2_get_bind_ipu(mipi_csi2_info); - csi_id = mipi_csi2_get_bind_csi(mipi_csi2_info); - - if (cam->ipu == ipu_get_soc(ipu_id) - && cam->csi == csi_id) - mipi_csi2_pixelclk_disable(mipi_csi2_info); - } - } -#endif - - if (cam->vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->vf_bufs_size[0], - cam->vf_bufs_vaddr[0], cam->vf_bufs[0]); - cam->vf_bufs_vaddr[0] = NULL; - cam->vf_bufs[0] = 0; - } - if (cam->vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->vf_bufs_size[1], - cam->vf_bufs_vaddr[1], cam->vf_bufs[1]); - cam->vf_bufs_vaddr[1] = NULL; - cam->vf_bufs[1] = 0; - } - if (cam->rot_vf_bufs_vaddr[0]) { - dma_free_coherent(0, cam->rot_vf_buf_size[0], - cam->rot_vf_bufs_vaddr[0], - cam->rot_vf_bufs[0]); - cam->rot_vf_bufs_vaddr[0] = NULL; - cam->rot_vf_bufs[0] = 0; - } - if (cam->rot_vf_bufs_vaddr[1]) { - dma_free_coherent(0, cam->rot_vf_buf_size[1], - cam->rot_vf_bufs_vaddr[1], - cam->rot_vf_bufs[1]); - cam->rot_vf_bufs_vaddr[1] = NULL; - cam->rot_vf_bufs[1] = 0; - } - - buffer_num = 0; - buffer_ready = 0; - cam->overlay_active = false; - return 0; -} - -/*! - * Enable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_vf_enable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - return ipu_enable_csi(cam->ipu, cam->csi); -} - -/*! - * Disable csi - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_vf_disable_csi(void *private) -{ - cam_data *cam = (cam_data *) private; - - /* free csi eof irq firstly. - * when disable csi, wait for idmac eof. - * it requests eof irq again */ - ipu_free_irq(cam->ipu, IPU_IRQ_PRP_VF_OUT_EOF, cam); - - return ipu_disable_csi(cam->ipu, cam->csi); -} - -/*! - * function to select PRP-VF as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return status - */ -int prp_vf_sdc_select_bg(void *private) -{ - cam_data *cam = (cam_data *) private; - - if (cam) { - cam->vf_start_sdc = prpvf_start; - cam->vf_stop_sdc = prpvf_stop; - cam->vf_enable_csi = prp_vf_enable_csi; - cam->vf_disable_csi = prp_vf_disable_csi; - cam->overlay_active = false; - } - - return 0; -} -EXPORT_SYMBOL(prp_vf_sdc_select_bg); - -/*! - * function to de-select PRP-VF as the working path - * - * @param private cam_data * mxc v4l2 main structure - * - * @return status - */ -int prp_vf_sdc_deselect_bg(void *private) -{ - cam_data *cam = (cam_data *) private; - - if (cam) { - cam->vf_start_sdc = NULL; - cam->vf_stop_sdc = NULL; - cam->vf_enable_csi = NULL; - cam->vf_disable_csi = NULL; - } - return 0; -} -EXPORT_SYMBOL(prp_vf_sdc_deselect_bg); - -/*! - * Init viewfinder task. - * - * @return Error code indicating success or failure - */ -__init int prp_vf_sdc_init_bg(void) -{ - return 0; -} - -/*! - * Deinit viewfinder task. - * - * @return Error code indicating success or failure - */ -void __exit prp_vf_sdc_exit_bg(void) -{ -} - -module_init(prp_vf_sdc_init_bg); -module_exit(prp_vf_sdc_exit_bg); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("IPU PRP VF SDC Backgroud Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/ipu_still.c b/drivers/media/platform/mxc/capture/ipu_still.c deleted file mode 100644 index b18c3cf873cc7015c136c567e3b5fed9b3e014d8..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ipu_still.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2004-2014 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file ipu_still.c - * - * @brief IPU Use case for still image capture - * - * @ingroup IPU - */ - -#include -#include -#include -#include -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -static int callback_eof_flag; -#ifndef CONFIG_MXC_IPU_V1 -static int buffer_num; -#endif - -#ifdef CONFIG_MXC_IPU_V1 -static int callback_flag; -/* - * Function definitions - */ -/*! - * CSI EOF callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t prp_csi_eof_callback(int irq, void *dev_id) -{ - cam_data *cam = devid; - ipu_select_buffer(cam->ipu, CSI_MEM, IPU_OUTPUT_BUFFER, - callback_flag%2 ? 1 : 0); - if (callback_flag == 0) - ipu_enable_channel(cam->ipu, CSI_MEM); - - callback_flag++; - return IRQ_HANDLED; -} -#endif - -/*! - * CSI callback function. - * - * @param irq int irq line - * @param dev_id void * device id - * - * @return status IRQ_HANDLED for handled - */ -static irqreturn_t prp_still_callback(int irq, void *dev_id) -{ - cam_data *cam = (cam_data *) dev_id; - - callback_eof_flag++; - if (callback_eof_flag < 5) { -#ifndef CONFIG_MXC_IPU_V1 - buffer_num = (buffer_num == 0) ? 1 : 0; - ipu_select_buffer(cam->ipu, CSI_MEM, - IPU_OUTPUT_BUFFER, buffer_num); -#endif - } else { - cam->still_counter++; - wake_up_interruptible(&cam->still_queue); - } - - return IRQ_HANDLED; -} - -/*! - * start csi->mem task - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_still_start(void *private) -{ - cam_data *cam = (cam_data *) private; - u32 pixel_fmt; - int err; - ipu_channel_params_t params; - - if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420) - pixel_fmt = IPU_PIX_FMT_YUV420P; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_NV12) - pixel_fmt = IPU_PIX_FMT_NV12; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV422P) - pixel_fmt = IPU_PIX_FMT_YUV422P; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_UYVY) - pixel_fmt = IPU_PIX_FMT_UYVY; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) - pixel_fmt = IPU_PIX_FMT_YUYV; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) - pixel_fmt = IPU_PIX_FMT_BGR24; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB24) - pixel_fmt = IPU_PIX_FMT_RGB24; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB565) - pixel_fmt = IPU_PIX_FMT_RGB565; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_BGR32) - pixel_fmt = IPU_PIX_FMT_BGR32; - else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_RGB32) - pixel_fmt = IPU_PIX_FMT_RGB32; - else { - printk(KERN_ERR "format not supported\n"); - return -EINVAL; - } - - memset(¶ms, 0, sizeof(params)); - err = ipu_init_channel(cam->ipu, CSI_MEM, ¶ms); - if (err != 0) - return err; - - err = ipu_init_channel_buffer(cam->ipu, CSI_MEM, IPU_OUTPUT_BUFFER, - pixel_fmt, cam->v2f.fmt.pix.width, - cam->v2f.fmt.pix.height, - cam->v2f.fmt.pix.width, IPU_ROTATE_NONE, - cam->still_buf[0], cam->still_buf[1], 0, - 0, 0); - if (err != 0) - return err; - -#ifdef CONFIG_MXC_IPU_V1 - ipu_clear_irq(IPU_IRQ_SENSOR_OUT_EOF); - err = ipu_request_irq(IPU_IRQ_SENSOR_OUT_EOF, prp_still_callback, - 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR "Error registering irq.\n"); - return err; - } - callback_flag = 0; - callback_eof_flag = 0; - ipu_clear_irq(IPU_IRQ_SENSOR_EOF); - err = ipu_request_irq(IPU_IRQ_SENSOR_EOF, prp_csi_eof_callback, - 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR "Error IPU_IRQ_SENSOR_EOF\n"); - return err; - } -#else - callback_eof_flag = 0; - buffer_num = 0; - - ipu_clear_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF); - err = ipu_request_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF, - prp_still_callback, - 0, "Mxc Camera", cam); - if (err != 0) { - printk(KERN_ERR "Error registering irq.\n"); - return err; - } - - ipu_select_buffer(cam->ipu, CSI_MEM, IPU_OUTPUT_BUFFER, 0); - ipu_enable_channel(cam->ipu, CSI_MEM); - ipu_enable_csi(cam->ipu, cam->csi); -#endif - - return err; -} - -/*! - * stop csi->mem encoder task - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -static int prp_still_stop(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - -#ifdef CONFIG_MXC_IPU_V1 - ipu_free_irq(IPU_IRQ_SENSOR_EOF, NULL); - ipu_free_irq(IPU_IRQ_SENSOR_OUT_EOF, cam); -#else - ipu_free_irq(cam->ipu, IPU_IRQ_CSI0_OUT_EOF, cam); -#endif - - ipu_disable_csi(cam->ipu, cam->csi); - ipu_disable_channel(cam->ipu, CSI_MEM, true); - ipu_uninit_channel(cam->ipu, CSI_MEM); - - return err; -} - -/*! - * function to select CSI_MEM as the working path - * - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -int prp_still_select(void *private) -{ - cam_data *cam = (cam_data *) private; - - if (cam) { - cam->csi_start = prp_still_start; - cam->csi_stop = prp_still_stop; - } - - return 0; -} -EXPORT_SYMBOL(prp_still_select); - -/*! - * function to de-select CSI_MEM as the working path - * - * @param private struct cam_data * mxc capture instance - * - * @return status - */ -int prp_still_deselect(void *private) -{ - cam_data *cam = (cam_data *) private; - int err = 0; - - err = prp_still_stop(cam); - - if (cam) { - cam->csi_start = NULL; - cam->csi_stop = NULL; - } - - return err; -} -EXPORT_SYMBOL(prp_still_deselect); - -/*! - * Init the Encorder channels - * - * @return Error code indicating success or failure - */ -__init int prp_still_init(void) -{ - return 0; -} - -/*! - * Deinit the Encorder channels - * - */ -void __exit prp_still_exit(void) -{ -} - -module_init(prp_still_init); -module_exit(prp_still_exit); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("IPU PRP STILL IMAGE Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/mx6s_capture.c b/drivers/media/platform/mxc/capture/mx6s_capture.c index 2dc58fe525102e80046c27dcf20eca205214841d..eec2d6f1669c1175c70c24a1d73e78edc83b2134 100644 --- a/drivers/media/platform/mxc/capture/mx6s_capture.c +++ b/drivers/media/platform/mxc/capture/mx6s_capture.c @@ -1491,6 +1491,17 @@ static int mx6s_vidioc_querycap(struct file *file, void *priv, return 0; } +static int mx6s_vidioc_expbuf(struct file *file, void *priv, + struct v4l2_exportbuffer *eb) +{ + struct mx6s_csi_dev *csi_dev = video_drvdata(file); + + if (eb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) + return vb2_expbuf(&csi_dev->vb2_vidq, eb); + + return -EINVAL; +} + static int mx6s_vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) { @@ -1673,6 +1684,7 @@ static const struct v4l2_ioctl_ops mx6s_csi_ioctl_ops = { .vidioc_enum_input = mx6s_vidioc_enum_input, .vidioc_g_input = mx6s_vidioc_g_input, .vidioc_s_input = mx6s_vidioc_s_input, + .vidioc_expbuf = mx6s_vidioc_expbuf, .vidioc_streamon = mx6s_vidioc_streamon, .vidioc_streamoff = mx6s_vidioc_streamoff, .vidioc_g_parm = mx6s_vidioc_g_parm, diff --git a/drivers/media/platform/mxc/capture/mxc_mipi_csi.c b/drivers/media/platform/mxc/capture/mxc_mipi_csi.c deleted file mode 100644 index 72e4ecb13b8936de790b7ee43b3048dce3d25761..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/mxc_mipi_csi.c +++ /dev/null @@ -1,1252 +0,0 @@ -/* - * Freescale i.MX7 SoC series MIPI-CSI V3.3 receiver driver - * - * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ -/* - * Samsung S5P/EXYNOS SoC series MIPI-CSI receiver driver - * - * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. - * Author: Sylwester Nawrocki - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static int debug; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Debug level (0-2)"); - -#define CSIS_DRIVER_NAME "mxc_mipi-csi" -#define CSIS_SUBDEV_NAME CSIS_DRIVER_NAME -#define CSIS_MAX_ENTITIES 2 -#define CSIS0_MAX_LANES 4 -#define CSIS1_MAX_LANES 2 - -#define MIPI_CSIS_DEF_PIX_WIDTH 640 -#define MIPI_CSIS_DEF_PIX_HEIGHT 480 - -/* Register map definition */ - -/* CSIS version */ -#define MIPI_CSIS_VERSION 0x00 - -/* CSIS common control */ -#define MIPI_CSIS_CMN_CTRL 0x04 -#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW (1 << 16) -#define MIPI_CSIS_CMN_CTRL_INTER_MODE (1 << 10) -#define MIPI_CSIS_CMN_CTRL_LANE_NR_OFFSET 8 -#define MIPI_CSIS_CMN_CTRL_LANE_NR_MASK (3 << 8) -#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW_CTRL (1 << 2) -#define MIPI_CSIS_CMN_CTRL_RESET (1 << 1) -#define MIPI_CSIS_CMN_CTRL_ENABLE (1 << 0) - -/* CSIS clock control */ -#define MIPI_CSIS_CLK_CTRL 0x08 -#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH3(x) (x << 28) -#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH2(x) (x << 24) -#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH1(x) (x << 20) -#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH0(x) (x << 16) -#define MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK (0xf << 4) -#define MIPI_CSIS_CLK_CTRL_WCLK_SRC (1 << 0) - -/* CSIS Interrupt mask */ -#define MIPI_CSIS_INTMSK 0x10 -#define MIPI_CSIS_INTMSK_EVEN_BEFORE (1 << 31) -#define MIPI_CSIS_INTMSK_EVEN_AFTER (1 << 30) -#define MIPI_CSIS_INTMSK_ODD_BEFORE (1 << 29) -#define MIPI_CSIS_INTMSK_ODD_AFTER (1 << 28) -#define MIPI_CSIS_INTMSK_FRAME_START (1 << 24) -#define MIPI_CSIS_INTMSK_FRAME_END (1 << 20) -#define MIPI_CSIS_INTMSK_ERR_SOT_HS (1 << 16) -#define MIPI_CSIS_INTMSK_ERR_LOST_FS (1 << 12) -#define MIPI_CSIS_INTMSK_ERR_LOST_FE (1 << 8) -#define MIPI_CSIS_INTMSK_ERR_OVER (1 << 4) -#define MIPI_CSIS_INTMSK_ERR_WRONG_CFG (1 << 3) -#define MIPI_CSIS_INTMSK_ERR_ECC (1 << 2) -#define MIPI_CSIS_INTMSK_ERR_CRC (1 << 1) -#define MIPI_CSIS_INTMSK_ERR_UNKNOWN (1 << 0) - -/* CSIS Interrupt source */ -#define MIPI_CSIS_INTSRC 0x14 -#define MIPI_CSIS_INTSRC_EVEN_BEFORE (1 << 31) -#define MIPI_CSIS_INTSRC_EVEN_AFTER (1 << 30) -#define MIPI_CSIS_INTSRC_EVEN (0x3 << 30) -#define MIPI_CSIS_INTSRC_ODD_BEFORE (1 << 29) -#define MIPI_CSIS_INTSRC_ODD_AFTER (1 << 28) -#define MIPI_CSIS_INTSRC_ODD (0x3 << 28) -#define MIPI_CSIS_INTSRC_NON_IMAGE_DATA (0xf << 28) -#define MIPI_CSIS_INTSRC_FRAME_START (1 << 24) -#define MIPI_CSIS_INTSRC_FRAME_END (1 << 20) -#define MIPI_CSIS_INTSRC_ERR_SOT_HS (1 << 16) -#define MIPI_CSIS_INTSRC_ERR_LOST_FS (1 << 12) -#define MIPI_CSIS_INTSRC_ERR_LOST_FE (1 << 8) -#define MIPI_CSIS_INTSRC_ERR_OVER (1 << 4) -#define MIPI_CSIS_INTSRC_ERR_WRONG_CFG (1 << 3) -#define MIPI_CSIS_INTSRC_ERR_ECC (1 << 2) -#define MIPI_CSIS_INTSRC_ERR_CRC (1 << 1) -#define MIPI_CSIS_INTSRC_ERR_UNKNOWN (1 << 0) -#define MIPI_CSIS_INTSRC_ERRORS 0xfffff - -/* D-PHY status control */ -#define MIPI_CSIS_DPHYSTATUS 0x20 -#define MIPI_CSIS_DPHYSTATUS_ULPS_DAT (1 << 8) -#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_DAT (1 << 4) -#define MIPI_CSIS_DPHYSTATUS_ULPS_CLK (1 << 1) -#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_CLK (1 << 0) - -/* D-PHY common control */ -#define MIPI_CSIS_DPHYCTRL 0x24 -#define MIPI_CSIS_DPHYCTRL_HSS_MASK (0xff << 24) -#define MIPI_CSIS_DPHYCTRL_HSS_OFFSET 24 -#define MIPI_CSIS_DPHYCTRL_SCLKS_MASK (0x3 << 22) -#define MIPI_CSIS_DPHYCTRL_SCLKS_OFFSET 22 -#define MIPI_CSIS_DPHYCTRL_DPDN_SWAP_CLK (1 << 6) -#define MIPI_CSIS_DPHYCTRL_DPDN_SWAP_DAT (1 << 5) -#define MIPI_CSIS_DPHYCTRL_ENABLE_DAT (1 << 1) -#define MIPI_CSIS_DPHYCTRL_ENABLE_CLK (1 << 0) -#define MIPI_CSIS_DPHYCTRL_ENABLE (0x1f << 0) - -/* D-PHY Master and Slave Control register Low */ -#define MIPI_CSIS_DPHYBCTRL_L 0x30 -/* D-PHY Master and Slave Control register High */ -#define MIPI_CSIS_DPHYBCTRL_H 0x34 -/* D-PHY Slave Control register Low */ -#define MIPI_CSIS_DPHYSCTRL_L 0x38 -/* D-PHY Slave Control register High */ -#define MIPI_CSIS_DPHYSCTRL_H 0x3c - - -/* ISP Configuration register */ -#define MIPI_CSIS_ISPCONFIG_CH0 0x40 -#define MIPI_CSIS_ISPCONFIG_CH1 0x50 -#define MIPI_CSIS_ISPCONFIG_CH2 0x60 -#define MIPI_CSIS_ISPCONFIG_CH3 0x70 - -#define MIPI_CSIS_ISPCFG_MEM_FULL_GAP_MSK (0xff << 24) -#define MIPI_CSIS_ISPCFG_MEM_FULL_GAP(x) (x << 24) -#define MIPI_CSIS_ISPCFG_DOUBLE_CMPNT (1 << 12) -#define MIPI_CSIS_ISPCFG_ALIGN_32BIT (1 << 11) -#define MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT (0x1e << 2) -#define MIPI_CSIS_ISPCFG_FMT_RAW8 (0x2a << 2) -#define MIPI_CSIS_ISPCFG_FMT_RAW10 (0x2b << 2) -#define MIPI_CSIS_ISPCFG_FMT_RAW12 (0x2c << 2) -/* User defined formats, x = 1...4 */ -#define MIPI_CSIS_ISPCFG_FMT_USER(x) ((0x30 + x - 1) << 2) -#define MIPI_CSIS_ISPCFG_FMT_MASK (0x3f << 2) - -/* ISP Image Resolution register */ -#define MIPI_CSIS_ISPRESOL_CH0 0x44 -#define MIPI_CSIS_ISPRESOL_CH1 0x54 -#define MIPI_CSIS_ISPRESOL_CH2 0x64 -#define MIPI_CSIS_ISPRESOL_CH3 0x74 -#define CSIS_MAX_PIX_WIDTH 0xffff -#define CSIS_MAX_PIX_HEIGHT 0xffff - -/* ISP SYNC register */ -#define MIPI_CSIS_ISPSYNC_CH0 0x48 -#define MIPI_CSIS_ISPSYNC_CH1 0x58 -#define MIPI_CSIS_ISPSYNC_CH2 0x68 -#define MIPI_CSIS_ISPSYNC_CH3 0x78 - -#define MIPI_CSIS_ISPSYNC_HSYNC_LINTV_OFFSET 18 -#define MIPI_CSIS_ISPSYNC_VSYNC_SINTV_OFFSET 12 -#define MIPI_CSIS_ISPSYNC_VSYNC_EINTV_OFFSET 0 - -/* Non-image packet data buffers */ -#define MIPI_CSIS_PKTDATA_ODD 0x2000 -#define MIPI_CSIS_PKTDATA_EVEN 0x3000 -#define MIPI_CSIS_PKTDATA_SIZE SZ_4K - -#define DEFAULT_SCLK_CSIS_FREQ 166000000UL - -enum { - ST_POWERED = 1, - ST_STREAMING = 2, - ST_SUSPENDED = 4, -}; - -struct mipi_csis_event { - u32 mask; - const char * const name; - unsigned int counter; -}; - -static const struct mipi_csis_event mipi_csis_events[] = { - /* Errors */ - { MIPI_CSIS_INTSRC_ERR_SOT_HS, "SOT Error" }, - { MIPI_CSIS_INTSRC_ERR_LOST_FS, "Lost Frame Start Error" }, - { MIPI_CSIS_INTSRC_ERR_LOST_FE, "Lost Frame End Error" }, - { MIPI_CSIS_INTSRC_ERR_OVER, "FIFO Overflow Error" }, - { MIPI_CSIS_INTSRC_ERR_ECC, "ECC Error" }, - { MIPI_CSIS_INTSRC_ERR_CRC, "CRC Error" }, - { MIPI_CSIS_INTSRC_ERR_UNKNOWN, "Unknown Error" }, - /* Non-image data receive events */ - { MIPI_CSIS_INTSRC_EVEN_BEFORE, "Non-image data before even frame" }, - { MIPI_CSIS_INTSRC_EVEN_AFTER, "Non-image data after even frame" }, - { MIPI_CSIS_INTSRC_ODD_BEFORE, "Non-image data before odd frame" }, - { MIPI_CSIS_INTSRC_ODD_AFTER, "Non-image data after odd frame" }, - /* Frame start/end */ - { MIPI_CSIS_INTSRC_FRAME_START, "Frame Start" }, - { MIPI_CSIS_INTSRC_FRAME_END, "Frame End" }, -}; -#define MIPI_CSIS_NUM_EVENTS ARRAY_SIZE(mipi_csis_events) - -struct csis_pktbuf { - u32 *data; - unsigned int len; -}; - -struct csis_hw_reset { - struct regmap *src; - u8 req_src; - u8 rst_bit; -}; - -/** - * struct csi_state - the driver's internal state data structure - * @lock: mutex serializing the subdev and power management operations, - * protecting @format and @flags members - * @sd: v4l2_subdev associated with CSIS device instance - * @index: the hardware instance index - * @pdev: CSIS platform device - * @phy: pointer to the CSIS generic PHY - * @regs: mmaped I/O registers memory - * @supplies: CSIS regulator supplies - * @clock: CSIS clocks - * @irq: requested s5p-mipi-csis irq number - * @flags: the state variable for power and streaming control - * @clock_frequency: device bus clock frequency - * @hs_settle: HS-RX settle time - * @clk_settle: Clk settle time - * @num_lanes: number of MIPI-CSI data lanes used - * @max_num_lanes: maximum number of MIPI-CSI data lanes supported - * @wclk_ext: CSI wrapper clock: 0 - bus clock, 1 - external SCLK_CAM - * @csis_fmt: current CSIS pixel format - * @format: common media bus format for the source and sink pad - * @slock: spinlock protecting structure members below - * @pkt_buf: the frame embedded (non-image) data buffer - * @events: MIPI-CSIS event (error) counters - */ -struct csi_state { - struct mutex lock; - struct device *dev; - struct v4l2_subdev mipi_sd; - struct v4l2_subdev *sensor_sd; - struct v4l2_device v4l2_dev; - - u8 index; - struct platform_device *pdev; - struct phy *phy; - void __iomem *regs; - struct clk *mipi_clk; - struct clk *phy_clk; - int irq; - u32 flags; - - u32 clk_frequency; - u32 hs_settle; - u32 clk_settle; - u32 num_lanes; - u32 max_num_lanes; - u8 wclk_ext; - - const struct csis_pix_format *csis_fmt; - struct v4l2_mbus_framefmt format; - - spinlock_t slock; - struct csis_pktbuf pkt_buf; - struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS]; - - struct v4l2_async_subdev asd; - struct v4l2_async_notifier subdev_notifier; - struct v4l2_async_subdev *async_subdevs[2]; - - struct csis_hw_reset hw_reset; - struct regulator *mipi_phy_regulator; -}; - -/** - * struct csis_pix_format - CSIS pixel format description - * @pix_width_alignment: horizontal pixel alignment, width will be - * multiple of 2^pix_width_alignment - * @code: corresponding media bus code - * @fmt_reg: MIPI_CSIS_CONFIG register value - * @data_alignment: MIPI-CSI data alignment in bits - */ -struct csis_pix_format { - unsigned int pix_width_alignment; - u32 code; - u32 fmt_reg; - u8 data_alignment; -}; - -static const struct csis_pix_format mipi_csis_formats[] = { - { - .code = MEDIA_BUS_FMT_YUYV8_2X8, - .fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT, - .data_alignment = 16, - }, { - .code = MEDIA_BUS_FMT_VYUY8_2X8, - .fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT, - .data_alignment = 16, - }, { - .code = MEDIA_BUS_FMT_SBGGR8_1X8, - .fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8, - .data_alignment = 8, - } -}; - -#define mipi_csis_write(__csis, __r, __v) writel(__v, __csis->regs + __r) -#define mipi_csis_read(__csis, __r) readl(__csis->regs + __r) - -static struct csi_state *mipi_sd_to_csi_state(struct v4l2_subdev *sdev) -{ - return container_of(sdev, struct csi_state, mipi_sd); -} - -static inline struct csi_state - *notifier_to_mipi_dev(struct v4l2_async_notifier *n) -{ - return container_of(n, struct csi_state, subdev_notifier); -} - -static const struct csis_pix_format *find_csis_format(u32 code) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(mipi_csis_formats); i++) - if (code == mipi_csis_formats[i].code) - return &mipi_csis_formats[i]; - return NULL; -} - -static void mipi_csis_enable_interrupts(struct csi_state *state, bool on) -{ - u32 val = mipi_csis_read(state, MIPI_CSIS_INTMSK); - if (on) - val |= 0xf00fffff; - else - val &= ~0xf00fffff; - mipi_csis_write(state, MIPI_CSIS_INTMSK, val); -} - -static void mipi_csis_sw_reset(struct csi_state *state) -{ - u32 val = mipi_csis_read(state, MIPI_CSIS_CMN_CTRL); - - mipi_csis_write(state, MIPI_CSIS_CMN_CTRL, val | MIPI_CSIS_CMN_CTRL_RESET); - udelay(10); -} - -static int mipi_csis_phy_init(struct csi_state *state) -{ - int ret; - - state->mipi_phy_regulator = devm_regulator_get(state->dev, - "mipi-phy"); - - ret = regulator_set_voltage(state->mipi_phy_regulator, - 1000000, 1000000); - - return ret; -} - -static int mipi_csis_phy_reset(struct csi_state *state) -{ - struct device_node *np = state->dev->of_node; - struct device_node *node; - phandle phandle; - u32 out_val[3]; - int ret; - - ret = of_property_read_u32_array(np, "csis-phy-reset", out_val, 3); - if (ret) { - dev_dbg(state->dev, "no csis-hw-reset property found\n"); - } else { - phandle = *out_val; - - node = of_find_node_by_phandle(phandle); - if (!node) { - dev_dbg(state->dev, "not find src node by phandle\n"); - ret = PTR_ERR(node); - } - state->hw_reset.src = syscon_node_to_regmap(node); - if (IS_ERR(state->hw_reset.src)) { - dev_err(state->dev, "failed to get src regmap\n"); - ret = PTR_ERR(state->hw_reset.src); - } - of_node_put(node); - if (ret < 0) - return ret; - - state->hw_reset.req_src = out_val[1]; - state->hw_reset.rst_bit = out_val[2]; - - /* reset mipi phy */ - regmap_update_bits(state->hw_reset.src, state->hw_reset.req_src, - 1 << state->hw_reset.rst_bit, 1 << state->hw_reset.rst_bit); - msleep(20); - regmap_update_bits(state->hw_reset.src, state->hw_reset.req_src, - 1 << state->hw_reset.rst_bit, 0); - - } - return ret; -} - -static void mipi_csis_system_enable(struct csi_state *state, int on) -{ - u32 val, mask; - - val = mipi_csis_read(state, MIPI_CSIS_CMN_CTRL); - if (on) - val |= MIPI_CSIS_CMN_CTRL_ENABLE; - else - val &= ~MIPI_CSIS_CMN_CTRL_ENABLE; - mipi_csis_write(state, MIPI_CSIS_CMN_CTRL, val); - - val = mipi_csis_read(state, MIPI_CSIS_DPHYCTRL); - val &= ~MIPI_CSIS_DPHYCTRL_ENABLE; - if (on) { - mask = (1 << (state->num_lanes + 1)) - 1; - val |= (mask & MIPI_CSIS_DPHYCTRL_ENABLE); - } - mipi_csis_write(state, MIPI_CSIS_DPHYCTRL, val); -} - -/* Called with the state.lock mutex held */ -static void __mipi_csis_set_format(struct csi_state *state) -{ - struct v4l2_mbus_framefmt *mf = &state->format; - u32 val; - - v4l2_dbg(1, debug, &state->mipi_sd, "fmt: %#x, %d x %d\n", - mf->code, mf->width, mf->height); - - /* Color format */ - val = mipi_csis_read(state, MIPI_CSIS_ISPCONFIG_CH0); - val = (val & ~MIPI_CSIS_ISPCFG_FMT_MASK) | state->csis_fmt->fmt_reg; - mipi_csis_write(state, MIPI_CSIS_ISPCONFIG_CH0, val); - - /* Pixel resolution */ - val = mf->width | (mf->height << 16); - mipi_csis_write(state, MIPI_CSIS_ISPRESOL_CH0, val); -} - -static void mipi_csis_set_hsync_settle(struct csi_state *state, - int hs_settle, int clk_settle) -{ - u32 val = mipi_csis_read(state, MIPI_CSIS_DPHYCTRL); - - val = (val & ~MIPI_CSIS_DPHYCTRL_HSS_MASK) | - (hs_settle << 24) | (clk_settle << 22); - - mipi_csis_write(state, MIPI_CSIS_DPHYCTRL, val); -} - -static void mipi_csis_set_params(struct csi_state *state) -{ - u32 val; - - val = mipi_csis_read(state, MIPI_CSIS_CMN_CTRL); - val &= ~MIPI_CSIS_CMN_CTRL_LANE_NR_MASK; - val |= (state->num_lanes - 1) << MIPI_CSIS_CMN_CTRL_LANE_NR_OFFSET; - mipi_csis_write(state, MIPI_CSIS_CMN_CTRL, val); - - __mipi_csis_set_format(state); - - mipi_csis_set_hsync_settle(state, state->hs_settle, state->clk_settle); - - val = mipi_csis_read(state, MIPI_CSIS_ISPCONFIG_CH0); - if (state->csis_fmt->data_alignment == 32) - val |= MIPI_CSIS_ISPCFG_ALIGN_32BIT; - else /* Normal output */ - val &= ~MIPI_CSIS_ISPCFG_ALIGN_32BIT; - mipi_csis_write(state, MIPI_CSIS_ISPCONFIG_CH0, val); - - val = (0 << MIPI_CSIS_ISPSYNC_HSYNC_LINTV_OFFSET) | - (0 << MIPI_CSIS_ISPSYNC_VSYNC_SINTV_OFFSET) | - (0 << MIPI_CSIS_ISPSYNC_VSYNC_EINTV_OFFSET); - mipi_csis_write(state, MIPI_CSIS_ISPSYNC_CH0, val); - - val = mipi_csis_read(state, MIPI_CSIS_CLK_CTRL); - val &= ~MIPI_CSIS_CLK_CTRL_WCLK_SRC; - if (state->wclk_ext) - val |= MIPI_CSIS_CLK_CTRL_WCLK_SRC; - val |= MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH0(15); - val &= ~MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK; - mipi_csis_write(state, MIPI_CSIS_CLK_CTRL, val); - - mipi_csis_write(state, MIPI_CSIS_DPHYBCTRL_L, 0x1f4); - mipi_csis_write(state, MIPI_CSIS_DPHYBCTRL_H, 0); - - /* Update the shadow register. */ - val = mipi_csis_read(state, MIPI_CSIS_CMN_CTRL); - mipi_csis_write(state, MIPI_CSIS_CMN_CTRL, val | MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW | - MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW_CTRL); -} - -static void mipi_csis_clk_enable(struct csi_state *state) -{ - clk_prepare_enable(state->mipi_clk); - clk_prepare_enable(state->phy_clk); -} - -static void mipi_csis_clk_disable(struct csi_state *state) -{ - clk_disable_unprepare(state->mipi_clk); - clk_disable_unprepare(state->phy_clk); -} - -static int mipi_csis_clk_get(struct csi_state *state) -{ - struct device *dev = &state->pdev->dev; - int ret = true; - - state->mipi_clk = devm_clk_get(dev, "mipi_clk"); - if (IS_ERR(state->mipi_clk)) { - dev_err(dev, "Could not get mipi csi clock\n"); - return -ENODEV; - } - - state->phy_clk = devm_clk_get(dev, "phy_clk"); - if (IS_ERR(state->phy_clk)) { - dev_err(dev, "Could not get mipi phy clock\n"); - return -ENODEV; - } - - /* Set clock rate */ - if (state->clk_frequency) - ret = clk_set_rate(state->mipi_clk, - state->clk_frequency); - else - dev_WARN(dev, "No clock frequency specified!\n"); - if (ret < 0) { - dev_err(dev, "set rate filed, rate=%d\n", state->clk_frequency); - return -EINVAL; - } - - return ret; -} - -static void dump_regs(struct csi_state *state, const char *label) -{ - struct { - u32 offset; - const char * const name; - } registers[] = { - { 0x00, "CTRL" }, - { 0x04, "DPHYCTRL" }, - { 0x08, "CONFIG" }, - { 0x0c, "DPHYSTS" }, - { 0x10, "INTMSK" }, - { 0x2c, "RESOL" }, - { 0x38, "SDW_CONFIG" }, - }; - u32 i; - - v4l2_info(&state->mipi_sd, "--- %s ---\n", label); - - for (i = 0; i < ARRAY_SIZE(registers); i++) { - u32 cfg = mipi_csis_read(state, registers[i].offset); - v4l2_info(&state->mipi_sd, "%10s: 0x%08x\n", registers[i].name, cfg); - } -} - -static void mipi_csis_start_stream(struct csi_state *state) -{ - mipi_csis_sw_reset(state); - mipi_csis_set_params(state); - mipi_csis_system_enable(state, true); - mipi_csis_enable_interrupts(state, true); -} - -static void mipi_csis_stop_stream(struct csi_state *state) -{ - mipi_csis_enable_interrupts(state, false); - mipi_csis_system_enable(state, false); -} - -static void mipi_csis_clear_counters(struct csi_state *state) -{ - unsigned long flags; - int i; - - spin_lock_irqsave(&state->slock, flags); - for (i = 0; i < MIPI_CSIS_NUM_EVENTS; i++) - state->events[i].counter = 0; - spin_unlock_irqrestore(&state->slock, flags); -} - -static void mipi_csis_log_counters(struct csi_state *state, bool non_errors) -{ - int i = non_errors ? MIPI_CSIS_NUM_EVENTS : MIPI_CSIS_NUM_EVENTS - 4; - unsigned long flags; - - spin_lock_irqsave(&state->slock, flags); - - for (i--; i >= 0; i--) { - if (state->events[i].counter > 0 || debug) - v4l2_info(&state->mipi_sd, "%s events: %d\n", - state->events[i].name, - state->events[i].counter); - } - spin_unlock_irqrestore(&state->slock, flags); -} - -/* - * V4L2 subdev operations - */ -static int mipi_csis_s_power(struct v4l2_subdev *mipi_sd, int on) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct device *dev = &state->pdev->dev; - - v4l2_subdev_call(state->sensor_sd, core, s_power, on); - - if (on) - return pm_runtime_get_sync(dev); - - return pm_runtime_put_sync(dev); -} - -static int mipi_csis_s_stream(struct v4l2_subdev *mipi_sd, int enable) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - int ret = 0; - - v4l2_dbg(1, debug, mipi_sd, "%s: %d, state: 0x%x\n", - __func__, enable, state->flags); - - if (enable) { - mipi_csis_clear_counters(state); - ret = pm_runtime_get_sync(&state->pdev->dev); - if (ret && ret != 1) - return ret; - } - - mutex_lock(&state->lock); - if (enable) { - if (state->flags & ST_SUSPENDED) { - ret = -EBUSY; - goto unlock; - } - mipi_csis_start_stream(state); - v4l2_subdev_call(state->sensor_sd, video, s_stream, true); - state->flags |= ST_STREAMING; - } else { - v4l2_subdev_call(state->sensor_sd, video, s_stream, false); - mipi_csis_stop_stream(state); - state->flags &= ~ST_STREAMING; - if (debug > 0) - mipi_csis_log_counters(state, true); - } -unlock: - mutex_unlock(&state->lock); - if (!enable) - pm_runtime_put(&state->pdev->dev); - - return ret == 1 ? 0 : ret; -} - -static int mipi_csis_enum_mbus_code(struct v4l2_subdev *mipi_sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct v4l2_subdev *sensor_sd = state->sensor_sd; - struct csis_pix_format const *csis_fmt; - int ret; - - ret = v4l2_subdev_call(sensor_sd, pad, enum_mbus_code, NULL, code); - if (ret < 0) - return -EINVAL; - - csis_fmt = find_csis_format(code->code); - if (csis_fmt == NULL) { - dev_err(state->dev, "format not match\n"); - return -EINVAL; - } - - return ret; -} - -static int mipi_csis_set_fmt(struct v4l2_subdev *mipi_sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *format) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct v4l2_subdev *sensor_sd = state->sensor_sd; - struct csis_pix_format const *csis_fmt; - struct v4l2_mbus_framefmt *mf = &format->format; - - if (format->pad) - return -EINVAL; - - csis_fmt = find_csis_format(mf->code); - if (csis_fmt == NULL) - csis_fmt = &mipi_csis_formats[0]; - - v4l2_subdev_call(sensor_sd, pad, set_fmt, NULL, format); - - mf->code = csis_fmt->code; - v4l_bound_align_image(&mf->width, 1, CSIS_MAX_PIX_WIDTH, - csis_fmt->pix_width_alignment, - &mf->height, 1, CSIS_MAX_PIX_HEIGHT, 1, - 0); - - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - return 0; - - state->format.code = mf->code; - state->format.width = mf->width; - state->format.height = mf->height; - - mutex_lock(&state->lock); - state->csis_fmt = csis_fmt; - mutex_unlock(&state->lock); - - return 0; -} - -static int mipi_csis_get_fmt(struct v4l2_subdev *mipi_sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *format) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct v4l2_subdev *sensor_sd = state->sensor_sd; - - if (format->pad) - return -EINVAL; - - return v4l2_subdev_call(sensor_sd, pad, get_fmt, NULL, format); -} - -static int mipi_csis_s_rx_buffer(struct v4l2_subdev *mipi_sd, void *buf, - unsigned int *size) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - unsigned long flags; - - *size = min_t(unsigned int, *size, MIPI_CSIS_PKTDATA_SIZE); - - spin_lock_irqsave(&state->slock, flags); - state->pkt_buf.data = buf; - state->pkt_buf.len = *size; - spin_unlock_irqrestore(&state->slock, flags); - - return 0; -} - -static int mipi_csis_s_parm(struct v4l2_subdev *mipi_sd, struct v4l2_streamparm *a) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct v4l2_subdev *sensor_sd = state->sensor_sd; - - return v4l2_subdev_call(sensor_sd, video, s_parm, a); -} - -static int mipi_csis_g_parm(struct v4l2_subdev *mipi_sd, struct v4l2_streamparm *a) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct v4l2_subdev *sensor_sd = state->sensor_sd; - - return v4l2_subdev_call(sensor_sd, video, g_parm, a); -} - -static int mipi_csis_enum_framesizes(struct v4l2_subdev *mipi_sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct v4l2_subdev *sensor_sd = state->sensor_sd; - - return v4l2_subdev_call(sensor_sd, pad, enum_frame_size, NULL, fse); -} - -static int mipi_csis_enum_frameintervals(struct v4l2_subdev *mipi_sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_interval_enum *fie) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - struct v4l2_subdev *sensor_sd = state->sensor_sd; - - return v4l2_subdev_call(sensor_sd, pad, enum_frame_interval, NULL, fie); -} - -static int mipi_csis_log_status(struct v4l2_subdev *mipi_sd) -{ - struct csi_state *state = mipi_sd_to_csi_state(mipi_sd); - - mutex_lock(&state->lock); - mipi_csis_log_counters(state, true); - if (debug && (state->flags & ST_POWERED)) - dump_regs(state, __func__); - mutex_unlock(&state->lock); - return 0; -} - -static struct v4l2_subdev_core_ops mipi_csis_core_ops = { - .s_power = mipi_csis_s_power, - .log_status = mipi_csis_log_status, -}; - -static struct v4l2_subdev_video_ops mipi_csis_video_ops = { - .s_rx_buffer = mipi_csis_s_rx_buffer, - .s_stream = mipi_csis_s_stream, - - .s_parm = mipi_csis_s_parm, - .g_parm = mipi_csis_g_parm, -}; - -static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = { - .enum_frame_size = mipi_csis_enum_framesizes, - .enum_frame_interval = mipi_csis_enum_frameintervals, - .enum_mbus_code = mipi_csis_enum_mbus_code, - .get_fmt = mipi_csis_get_fmt, - .set_fmt = mipi_csis_set_fmt, -}; - -static struct v4l2_subdev_ops mipi_csis_subdev_ops = { - .core = &mipi_csis_core_ops, - .video = &mipi_csis_video_ops, - .pad = &mipi_csis_pad_ops, -}; - -static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id) -{ - struct csi_state *state = dev_id; - struct csis_pktbuf *pktbuf = &state->pkt_buf; - unsigned long flags; - u32 status; - - status = mipi_csis_read(state, MIPI_CSIS_INTSRC); - - spin_lock_irqsave(&state->slock, flags); - - if ((status & MIPI_CSIS_INTSRC_NON_IMAGE_DATA) && pktbuf->data) { - u32 offset; - - if (status & MIPI_CSIS_INTSRC_EVEN) - offset = MIPI_CSIS_PKTDATA_EVEN; - else - offset = MIPI_CSIS_PKTDATA_ODD; - - memcpy(pktbuf->data, state->regs + offset, pktbuf->len); - pktbuf->data = NULL; - rmb(); - } - - /* Update the event/error counters */ - if ((status & MIPI_CSIS_INTSRC_ERRORS) || debug) { - int i; - for (i = 0; i < MIPI_CSIS_NUM_EVENTS; i++) { - if (!(status & state->events[i].mask)) - continue; - state->events[i].counter++; - v4l2_dbg(2, debug, &state->mipi_sd, "%s: %d\n", - state->events[i].name, - state->events[i].counter); - } - v4l2_dbg(2, debug, &state->mipi_sd, "status: %08x\n", status); - } - spin_unlock_irqrestore(&state->slock, flags); - - mipi_csis_write(state, MIPI_CSIS_INTSRC, status); - return IRQ_HANDLED; -} - -static int subdev_notifier_bound(struct v4l2_async_notifier *notifier, - struct v4l2_subdev *subdev, - struct v4l2_async_subdev *asd) -{ - struct csi_state *state = notifier_to_mipi_dev(notifier); - - /* Find platform data for this sensor subdev */ - if (state->asd.match.fwnode == of_fwnode_handle(subdev->dev->of_node)) - state->sensor_sd = subdev; - - if (subdev == NULL) - return -EINVAL; - - v4l2_info(&state->v4l2_dev, "Registered sensor subdevice: %s\n", - subdev->name); - - return 0; -} - -static int mipi_csis_parse_dt(struct platform_device *pdev, - struct csi_state *state) -{ - struct device_node *node = pdev->dev.of_node; - - if (of_property_read_u32(node, "clock-frequency", - &state->clk_frequency)) - state->clk_frequency = DEFAULT_SCLK_CSIS_FREQ; - if (of_property_read_u32(node, "bus-width", - &state->max_num_lanes)) - return -EINVAL; - - node = of_graph_get_next_endpoint(node, NULL); - if (!node) { - dev_err(&pdev->dev, "No port node at %s\n", - pdev->dev.of_node->full_name); - return -EINVAL; - } - - /* Get MIPI CSI-2 bus configration from the endpoint node. */ - of_property_read_u32(node, "csis-hs-settle", - &state->hs_settle); - - of_property_read_u32(node, "csis-clk-settle", - &state->clk_settle); - state->wclk_ext = of_property_read_bool(node, - "csis-wclk"); - - of_property_read_u32(node, "data-lanes", - &state->num_lanes); - of_node_put(node); - - return 0; -} - -static int mipi_csis_pm_resume(struct device *dev, bool runtime); -static const struct of_device_id mipi_csis_of_match[]; - -static const struct v4l2_async_notifier_operations subdev_notifier_ops = { - .bound = subdev_notifier_bound, -}; - -/* register parent dev */ -static int mipi_csis_subdev_host(struct csi_state *state) -{ - struct device_node *parent = state->dev->of_node; - struct device_node *node, *port, *rem; - int ret; - - /* Attach sensors linked to csi receivers */ - for_each_available_child_of_node(parent, node) { - if (of_node_cmp(node->name, "port")) - continue; - - /* The csi node can have only port subnode. */ - port = of_get_next_child(node, NULL); - if (!port) - continue; - rem = of_graph_get_remote_port_parent(port); - of_node_put(port); - if (rem == NULL) { - v4l2_info(&state->v4l2_dev, - "Remote device at %s not found\n", - port->full_name); - return -1; - } - - state->asd.match_type = V4L2_ASYNC_MATCH_FWNODE; - state->asd.match.fwnode = of_fwnode_handle(rem); - state->async_subdevs[0] = &state->asd; - - of_node_put(rem); - break; - } - - state->subdev_notifier.subdevs = state->async_subdevs; - state->subdev_notifier.num_subdevs = 1; - state->subdev_notifier.ops = &subdev_notifier_ops; - - ret = v4l2_async_notifier_register(&state->v4l2_dev, - &state->subdev_notifier); - if (ret) - dev_err(state->dev, - "Error register async notifier regoster\n"); - - return ret; -} - -/* init subdev */ -static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, - struct platform_device *pdev, - const struct v4l2_subdev_ops *ops) -{ - struct csi_state *state = platform_get_drvdata(pdev); - int ret = 0; - - v4l2_subdev_init(mipi_sd, ops); - mipi_sd->owner = THIS_MODULE; - snprintf(mipi_sd->name, sizeof(mipi_sd->name), "%s.%d", - CSIS_SUBDEV_NAME, state->index); - mipi_sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - mipi_sd->dev = &pdev->dev; - - state->csis_fmt = &mipi_csis_formats[0]; - state->format.code = mipi_csis_formats[0].code; - state->format.width = MIPI_CSIS_DEF_PIX_WIDTH; - state->format.height = MIPI_CSIS_DEF_PIX_HEIGHT; - - /* This allows to retrieve the platform device id by the host driver */ - v4l2_set_subdevdata(mipi_sd, pdev); - - ret = v4l2_async_register_subdev(mipi_sd); - if (ret < 0) - dev_err(&pdev->dev, "%s--Async register faialed, ret=%d\n", __func__, ret); - - return ret; -} - -static int mipi_csis_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct v4l2_subdev *mipi_sd; - struct resource *mem_res; - struct csi_state *state; - int ret = -ENOMEM; - - state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); - if (!state) - return -ENOMEM; - - mutex_init(&state->lock); - spin_lock_init(&state->slock); - - state->pdev = pdev; - mipi_sd = &state->mipi_sd; - state->dev = dev; - - ret = mipi_csis_parse_dt(pdev, state); - if (ret < 0) - return ret; - - if (state->num_lanes == 0 || state->num_lanes > state->max_num_lanes) { - dev_err(dev, "Unsupported number of data lanes: %d (max. %d)\n", - state->num_lanes, state->max_num_lanes); - return -EINVAL; - } - - mipi_csis_phy_init(state); - mipi_csis_phy_reset(state); - - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - state->regs = devm_ioremap_resource(dev, mem_res); - if (IS_ERR(state->regs)) - return PTR_ERR(state->regs); - - state->irq = platform_get_irq(pdev, 0); - if (state->irq < 0) { - dev_err(dev, "Failed to get irq\n"); - return state->irq; - } - - ret = mipi_csis_clk_get(state); - if (ret < 0) - return ret; - - mipi_csis_clk_enable(state); - - ret = devm_request_irq(dev, state->irq, mipi_csis_irq_handler, - 0, dev_name(dev), state); - if (ret) { - dev_err(dev, "Interrupt request failed\n"); - goto e_clkdis; - } - - /* First register a v4l2 device */ - ret = v4l2_device_register(dev, &state->v4l2_dev); - if (ret) { - v4l2_err(dev->driver, - "Unable to register v4l2 device.\n"); - goto e_clkdis; - } - v4l2_info(&state->v4l2_dev, "mipi csi v4l2 device registered\n"); - - /* .. and a pointer to the subdev. */ - platform_set_drvdata(pdev, state); - - ret = mipi_csis_subdev_init(&state->mipi_sd, pdev, &mipi_csis_subdev_ops); - if (ret < 0) - goto e_sd_mipi; - - memcpy(state->events, mipi_csis_events, sizeof(state->events)); - - /* subdev host register */ - ret = mipi_csis_subdev_host(state); - if (ret < 0) - goto e_sd_host; - - pm_runtime_enable(dev); - if (!pm_runtime_enabled(dev)) { - ret = mipi_csis_pm_resume(dev, true); - if (ret < 0) - goto e_sd_host; - } - - dev_info(&pdev->dev, - "lanes: %d, hs_settle: %d, clk_settle: %d, wclk: %d, freq: %u\n", - state->num_lanes, state->hs_settle, state->clk_settle, - state->wclk_ext, state->clk_frequency); - return 0; - -e_sd_host: - v4l2_async_notifier_unregister(&state->subdev_notifier); - v4l2_device_unregister(&state->v4l2_dev); -e_sd_mipi: - v4l2_async_unregister_subdev(&state->mipi_sd); -e_clkdis: - mipi_csis_clk_disable(state); - return ret; -} - -static int mipi_csis_pm_suspend(struct device *dev, bool runtime) -{ - struct platform_device *pdev = to_platform_device(dev); - struct csi_state *state = platform_get_drvdata(pdev); - struct v4l2_subdev *mipi_sd = &state->mipi_sd; - int ret = 0; - - v4l2_dbg(1, debug, mipi_sd, "%s: flags: 0x%x\n", - __func__, state->flags); - - mutex_lock(&state->lock); - if (state->flags & ST_POWERED) { - mipi_csis_stop_stream(state); - ret = regulator_disable(state->mipi_phy_regulator); - if (ret) - goto unlock; - mipi_csis_clk_disable(state); - state->flags &= ~ST_POWERED; - if (!runtime) - state->flags |= ST_SUSPENDED; - } - unlock: - mutex_unlock(&state->lock); - return ret ? -EAGAIN : 0; -} - -static int mipi_csis_pm_resume(struct device *dev, bool runtime) -{ - struct platform_device *pdev = to_platform_device(dev); - struct csi_state *state = platform_get_drvdata(pdev); - struct v4l2_subdev *mipi_sd = &state->mipi_sd; - int ret = 0; - - v4l2_dbg(1, debug, mipi_sd, "%s: flags: 0x%x\n", - __func__, state->flags); - - mutex_lock(&state->lock); - if (!runtime && !(state->flags & ST_SUSPENDED)) - goto unlock; - - if (!(state->flags & ST_POWERED)) { - ret = regulator_enable(state->mipi_phy_regulator); - if (!ret) { - state->flags |= ST_POWERED; - } else { - goto unlock; - } - mipi_csis_clk_enable(state); - } - if (state->flags & ST_STREAMING) - mipi_csis_start_stream(state); - - state->flags &= ~ST_SUSPENDED; - unlock: - mutex_unlock(&state->lock); - return ret ? -EAGAIN : 0; -} - -#ifdef CONFIG_PM_SLEEP -static int mipi_csis_suspend(struct device *dev) -{ - return mipi_csis_pm_suspend(dev, false); -} - -static int mipi_csis_resume(struct device *dev) -{ - return mipi_csis_pm_resume(dev, false); -} -#endif - -static int mipi_csis_runtime_suspend(struct device *dev) -{ - return mipi_csis_pm_suspend(dev, true); -} - -static int mipi_csis_runtime_resume(struct device *dev) -{ - return mipi_csis_pm_resume(dev, true); -} - -static int mipi_csis_remove(struct platform_device *pdev) -{ - struct csi_state *state = platform_get_drvdata(pdev); - - v4l2_async_unregister_subdev(&state->mipi_sd); - v4l2_async_notifier_unregister(&state->subdev_notifier); - v4l2_device_unregister(&state->v4l2_dev); - - pm_runtime_disable(&pdev->dev); - mipi_csis_pm_suspend(&pdev->dev, true); - mipi_csis_clk_disable(state); - pm_runtime_set_suspended(&pdev->dev); - - return 0; -} - -static const struct dev_pm_ops mipi_csis_pm_ops = { - SET_RUNTIME_PM_OPS(mipi_csis_runtime_suspend, mipi_csis_runtime_resume, - NULL) - SET_SYSTEM_SLEEP_PM_OPS(mipi_csis_suspend, mipi_csis_resume) -}; - -static const struct of_device_id mipi_csis_of_match[] = { - { .compatible = "fsl,imx7d-mipi-csi",}, - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(of, mipi_csis_of_match); - -static struct platform_driver mipi_csis_driver = { - .probe = mipi_csis_probe, - .remove = mipi_csis_remove, - .driver = { - .of_match_table = mipi_csis_of_match, - .name = CSIS_DRIVER_NAME, - .owner = THIS_MODULE, - .pm = &mipi_csis_pm_ops, - }, -}; - -module_platform_driver(mipi_csis_driver); - -MODULE_DESCRIPTION("Freescale MIPI-CSI2 receiver driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/mxc_v4l2_capture.c b/drivers/media/platform/mxc/capture/mxc_v4l2_capture.c deleted file mode 100644 index 3d7adecaa32519c17a00222a2a451e99b60cb2eb..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/mxc_v4l2_capture.c +++ /dev/null @@ -1,3148 +0,0 @@ -/* - * Copyright 2004-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @file drivers/media/video/mxc/capture/mxc_v4l2_capture.c - * - * @brief Mxc Video For Linux 2 driver - * - * @ingroup MXC_V4L2_CAPTURE - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "v4l2-int-device.h" -#include -#include "mxc_v4l2_capture.h" -#include "ipu_prp_sw.h" - -#define init_MUTEX(sem) sema_init(sem, 1) - -static struct platform_device_id imx_v4l2_devtype[] = { - { - .name = "v4l2-capture-imx5", - .driver_data = IMX5_V4L2, - }, { - .name = "v4l2-capture-imx6", - .driver_data = IMX6_V4L2, - }, { - /* sentinel */ - } -}; -MODULE_DEVICE_TABLE(platform, imx_v4l2_devtype); - -static const struct of_device_id mxc_v4l2_dt_ids[] = { - { - .compatible = "fsl,imx6q-v4l2-capture", - .data = &imx_v4l2_devtype[IMX6_V4L2], - }, { - /* sentinel */ - } -}; -MODULE_DEVICE_TABLE(of, mxc_v4l2_dt_ids); - -static int video_nr = -1; - -/*! This data is used for the output to the display. */ -#define MXC_V4L2_CAPTURE_NUM_OUTPUTS 6 -#define MXC_V4L2_CAPTURE_NUM_INPUTS 2 -static struct v4l2_output mxc_capture_outputs[MXC_V4L2_CAPTURE_NUM_OUTPUTS] = { - { - .index = 0, - .name = "DISP3 BG", - .type = V4L2_OUTPUT_TYPE_ANALOG, - .audioset = 0, - .modulator = 0, - .std = V4L2_STD_UNKNOWN, - }, - { - .index = 1, - .name = "DISP3 BG - DI1", - .type = V4L2_OUTPUT_TYPE_ANALOG, - .audioset = 0, - .modulator = 0, - .std = V4L2_STD_UNKNOWN, - }, - { - .index = 2, - .name = "DISP3 FG", - .type = V4L2_OUTPUT_TYPE_ANALOG, - .audioset = 0, - .modulator = 0, - .std = V4L2_STD_UNKNOWN, - }, - { - .index = 3, - .name = "DISP4 BG", - .type = V4L2_OUTPUT_TYPE_ANALOG, - .audioset = 0, - .modulator = 0, - .std = V4L2_STD_UNKNOWN, - }, - { - .index = 4, - .name = "DISP4 BG - DI1", - .type = V4L2_OUTPUT_TYPE_ANALOG, - .audioset = 0, - .modulator = 0, - .std = V4L2_STD_UNKNOWN, - }, - { - .index = 5, - .name = "DISP4 FG", - .type = V4L2_OUTPUT_TYPE_ANALOG, - .audioset = 0, - .modulator = 0, - .std = V4L2_STD_UNKNOWN, - }, -}; - -static struct v4l2_input mxc_capture_inputs[MXC_V4L2_CAPTURE_NUM_INPUTS] = { - { - .index = 0, - .name = "CSI IC MEM", - .type = V4L2_INPUT_TYPE_CAMERA, - .audioset = 0, - .tuner = 0, - .std = V4L2_STD_UNKNOWN, - .status = 0, - }, - { - .index = 1, - .name = "CSI MEM", - .type = V4L2_INPUT_TYPE_CAMERA, - .audioset = 0, - .tuner = 0, - .std = V4L2_STD_UNKNOWN, - .status = V4L2_IN_ST_NO_POWER, - }, -}; - -/*! List of TV input video formats supported. The video formats is corresponding - * to the v4l2_id in video_fmt_t. - * Currently, only PAL and NTSC is supported. Needs to be expanded in the - * future. - */ -typedef enum { - TV_NTSC = 0, /*!< Locked on (M) NTSC video signal. */ - TV_PAL, /*!< (B, G, H, I, N)PAL video signal. */ - TV_NOT_LOCKED, /*!< Not locked on a signal. */ -} video_fmt_idx; - -/*! Number of video standards supported (including 'not locked' signal). */ -#define TV_STD_MAX (TV_NOT_LOCKED + 1) - -/*! Video format structure. */ -typedef struct { - int v4l2_id; /*!< Video for linux ID. */ - char name[16]; /*!< Name (e.g., "NTSC", "PAL", etc.) */ - u16 raw_width; /*!< Raw width. */ - u16 raw_height; /*!< Raw height. */ - u16 active_width; /*!< Active width. */ - u16 active_height; /*!< Active height. */ - u16 active_top; /*!< Active top. */ - u16 active_left; /*!< Active left. */ -} video_fmt_t; - -/*! - * Description of video formats supported. - * - * PAL: raw=720x625, active=720x576. - * NTSC: raw=720x525, active=720x480. - */ -static video_fmt_t video_fmts[] = { - { /*! NTSC */ - .v4l2_id = V4L2_STD_NTSC, - .name = "NTSC", - .raw_width = 720, /* SENS_FRM_WIDTH */ - .raw_height = 525, /* SENS_FRM_HEIGHT */ - .active_width = 720, /* ACT_FRM_WIDTH */ - .active_height = 480, /* ACT_FRM_HEIGHT */ - .active_top = 13, - .active_left = 0, - }, - { /*! (B, G, H, I, N) PAL */ - .v4l2_id = V4L2_STD_PAL, - .name = "PAL", - .raw_width = 720, - .raw_height = 625, - .active_width = 720, - .active_height = 576, - .active_top = 0, - .active_left = 0, - }, - { /*! Unlocked standard */ - .v4l2_id = V4L2_STD_ALL, - .name = "Autodetect", - .raw_width = 720, - .raw_height = 625, - .active_width = 720, - .active_height = 576, - .active_top = 0, - .active_left = 0, - }, -}; - -/*!* Standard index of TV. */ -static video_fmt_idx video_index = TV_NOT_LOCKED; - -static int mxc_v4l2_master_attach(struct v4l2_int_device *slave); -static void mxc_v4l2_master_detach(struct v4l2_int_device *slave); -static int start_preview(cam_data *cam); -static int stop_preview(cam_data *cam); - -/*! Information about this driver. */ -static struct v4l2_int_master mxc_v4l2_master = { - .attach = mxc_v4l2_master_attach, - .detach = mxc_v4l2_master_detach, -}; - -/*************************************************************************** - * Functions for handling Frame buffers. - **************************************************************************/ - -/*! - * Free frame buffers - * - * @param cam Structure cam_data * - * - * @return status 0 success. - */ -static int mxc_free_frame_buf(cam_data *cam) -{ - int i; - - pr_debug("MVC: In mxc_free_frame_buf\n"); - - for (i = 0; i < FRAME_NUM; i++) { - if (cam->frame[i].vaddress != 0) { - dma_free_coherent(0, cam->frame[i].buffer.length, - cam->frame[i].vaddress, - cam->frame[i].paddress); - cam->frame[i].vaddress = 0; - } - } - - return 0; -} - -/*! - * Allocate frame buffers - * - * @param cam Structure cam_data* - * @param count int number of buffer need to allocated - * - * @return status -0 Successfully allocated a buffer, -ENOBUFS failed. - */ -static int mxc_allocate_frame_buf(cam_data *cam, int count) -{ - int i; - - pr_debug("In MVC:mxc_allocate_frame_buf - size=%d\n", - cam->v2f.fmt.pix.sizeimage); - - for (i = 0; i < count; i++) { - cam->frame[i].vaddress = - dma_alloc_coherent(0, - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage), - &cam->frame[i].paddress, - GFP_DMA | GFP_KERNEL); - if (cam->frame[i].vaddress == 0) { - pr_err("ERROR: v4l2 capture: " - "mxc_allocate_frame_buf failed.\n"); - mxc_free_frame_buf(cam); - return -ENOBUFS; - } - cam->frame[i].buffer.index = i; - cam->frame[i].buffer.flags = V4L2_BUF_FLAG_MAPPED; - cam->frame[i].buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cam->frame[i].buffer.length = - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage); - cam->frame[i].buffer.memory = V4L2_MEMORY_MMAP; - cam->frame[i].buffer.m.offset = cam->frame[i].paddress; - cam->frame[i].index = i; - } - - return 0; -} - -/*! - * Free frame buffers status - * - * @param cam Structure cam_data * - * - * @return none - */ -static void mxc_free_frames(cam_data *cam) -{ - int i; - - pr_debug("In MVC:mxc_free_frames\n"); - - for (i = 0; i < FRAME_NUM; i++) - cam->frame[i].buffer.flags = V4L2_BUF_FLAG_MAPPED; - - cam->enc_counter = 0; - INIT_LIST_HEAD(&cam->ready_q); - INIT_LIST_HEAD(&cam->working_q); - INIT_LIST_HEAD(&cam->done_q); -} - -/*! - * Return the buffer status - * - * @param cam Structure cam_data * - * @param buf Structure v4l2_buffer * - * - * @return status 0 success, EINVAL failed. - */ -static int mxc_v4l2_buffer_status(cam_data *cam, struct v4l2_buffer *buf) -{ - pr_debug("In MVC:mxc_v4l2_buffer_status\n"); - - if (buf->index < 0 || buf->index >= FRAME_NUM) { - pr_err("ERROR: v4l2 capture: mxc_v4l2_buffer_status buffers " - "not allocated\n"); - return -EINVAL; - } - - memcpy(buf, &(cam->frame[buf->index].buffer), sizeof(*buf)); - return 0; -} - -static int mxc_v4l2_release_bufs(cam_data *cam) -{ - pr_debug("In MVC:mxc_v4l2_release_bufs\n"); - return 0; -} - -static int mxc_v4l2_prepare_bufs(cam_data *cam, struct v4l2_buffer *buf) -{ - pr_debug("In MVC:mxc_v4l2_prepare_bufs\n"); - - if (buf->index < 0 || buf->index >= FRAME_NUM || buf->length < - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage)) { - pr_err("ERROR: v4l2 capture: mxc_v4l2_prepare_bufs buffers " - "not allocated,index=%d, length=%d\n", buf->index, - buf->length); - return -EINVAL; - } - - cam->frame[buf->index].buffer.index = buf->index; - cam->frame[buf->index].buffer.flags = V4L2_BUF_FLAG_MAPPED; - cam->frame[buf->index].buffer.length = buf->length; - cam->frame[buf->index].buffer.m.offset = cam->frame[buf->index].paddress - = buf->m.offset; - cam->frame[buf->index].buffer.type = buf->type; - cam->frame[buf->index].buffer.memory = V4L2_MEMORY_USERPTR; - cam->frame[buf->index].index = buf->index; - - return 0; -} - -/*************************************************************************** - * Functions for handling the video stream. - **************************************************************************/ - -/*! - * Indicates whether the palette is supported. - * - * @param palette V4L2_PIX_FMT_RGB565, V4L2_PIX_FMT_BGR24 or V4L2_PIX_FMT_BGR32 - * - * @return 0 if failed - */ -static inline int valid_mode(u32 palette) -{ - return ((palette == V4L2_PIX_FMT_RGB565) || - (palette == V4L2_PIX_FMT_BGR24) || - (palette == V4L2_PIX_FMT_RGB24) || - (palette == V4L2_PIX_FMT_BGR32) || - (palette == V4L2_PIX_FMT_RGB32) || - (palette == V4L2_PIX_FMT_YUV422P) || - (palette == V4L2_PIX_FMT_UYVY) || - (palette == V4L2_PIX_FMT_YUYV) || - (palette == V4L2_PIX_FMT_YUV420) || - (palette == V4L2_PIX_FMT_YVU420) || - (palette == V4L2_PIX_FMT_NV12)); -} - -/*! - * Start the encoder job - * - * @param cam structure cam_data * - * - * @return status 0 Success - */ -static int mxc_streamon(cam_data *cam) -{ - struct mxc_v4l_frame *frame; - unsigned long lock_flags; - int err = 0; - - pr_debug("In MVC:mxc_streamon\n"); - - if (NULL == cam) { - pr_err("ERROR! cam parameter is NULL\n"); - return -1; - } - - if (cam->capture_on) { - pr_err("ERROR: v4l2 capture: Capture stream has been turned " - " on\n"); - return -1; - } - - if (list_empty(&cam->ready_q)) { - pr_err("ERROR: v4l2 capture: mxc_streamon buffer has not been " - "queued yet\n"); - return -EINVAL; - } - if (cam->enc_update_eba && - cam->ready_q.prev == cam->ready_q.next) { - pr_err("ERROR: v4l2 capture: mxc_streamon buffer need " - "ping pong at least two buffers\n"); - return -EINVAL; - } - - cam->capture_pid = current->pid; - - if (cam->overlay_on == true) - stop_preview(cam); - - if (cam->enc_enable) { - err = cam->enc_enable(cam); - if (err != 0) - return err; - } - - spin_lock_irqsave(&cam->queue_int_lock, lock_flags); - cam->ping_pong_csi = 0; - cam->local_buf_num = 0; - if (cam->enc_update_eba) { - frame = - list_entry(cam->ready_q.next, struct mxc_v4l_frame, queue); - list_del(cam->ready_q.next); - list_add_tail(&frame->queue, &cam->working_q); - frame->ipu_buf_num = cam->ping_pong_csi; - err = cam->enc_update_eba(cam, frame->buffer.m.offset); - - frame = - list_entry(cam->ready_q.next, struct mxc_v4l_frame, queue); - list_del(cam->ready_q.next); - list_add_tail(&frame->queue, &cam->working_q); - frame->ipu_buf_num = cam->ping_pong_csi; - err |= cam->enc_update_eba(cam, frame->buffer.m.offset); - spin_unlock_irqrestore(&cam->queue_int_lock, lock_flags); - } else { - spin_unlock_irqrestore(&cam->queue_int_lock, lock_flags); - return -EINVAL; - } - - if (cam->overlay_on == true) - start_preview(cam); - - if (cam->enc_enable_csi) { - err = cam->enc_enable_csi(cam); - if (err != 0) - return err; - } - - cam->capture_on = true; - - return err; -} - -/*! - * Shut down the encoder job - * - * @param cam structure cam_data * - * - * @return status 0 Success - */ -static int mxc_streamoff(cam_data *cam) -{ - int err = 0; - - pr_debug("In MVC:mxc_streamoff\n"); - - if (cam->capture_on == false) - return 0; - - /* For both CSI--MEM and CSI--IC--MEM - * 1. wait for idmac eof - * 2. disable csi first - * 3. disable idmac - * 4. disable smfc (CSI--MEM channel) - */ - if (mxc_capture_inputs[cam->current_input].name != NULL) { - if (cam->enc_disable_csi) { - err = cam->enc_disable_csi(cam); - if (err != 0) - return err; - } - if (cam->enc_disable) { - err = cam->enc_disable(cam); - if (err != 0) - return err; - } - } - - mxc_free_frames(cam); - mxc_capture_inputs[cam->current_input].status |= V4L2_IN_ST_NO_POWER; - cam->capture_on = false; - return err; -} - -/*! - * Valid and adjust the overlay window size, position - * - * @param cam structure cam_data * - * @param win struct v4l2_window * - * - * @return 0 - */ -static int verify_preview(cam_data *cam, struct v4l2_window *win) -{ - int i = 0, width_bound = 0, height_bound = 0; - int *width, *height; - unsigned int ipu_ch = CHAN_NONE; - struct fb_info *bg_fbi = NULL, *fbi = NULL; - bool foregound_fb = false; - mm_segment_t old_fs; - - pr_debug("In MVC: verify_preview\n"); - - do { - fbi = (struct fb_info *)registered_fb[i]; - if (fbi == NULL) { - pr_err("ERROR: verify_preview frame buffer NULL.\n"); - return -1; - } - - /* Which DI supports 2 layers? */ - if (((strncmp(fbi->fix.id, "DISP3 BG", 8) == 0) && - (cam->output < 3)) || - ((strncmp(fbi->fix.id, "DISP4 BG", 8) == 0) && - (cam->output >= 3))) { - if (fbi->fbops->fb_ioctl) { - old_fs = get_fs(); - set_fs(KERNEL_DS); - fbi->fbops->fb_ioctl(fbi, MXCFB_GET_FB_IPU_CHAN, - (unsigned long)&ipu_ch); - set_fs(old_fs); - } - if (ipu_ch == MEM_BG_SYNC) { - bg_fbi = fbi; - pr_debug("Found background frame buffer.\n"); - } - } - - /* Found the frame buffer to preview on. */ - if (strcmp(fbi->fix.id, - mxc_capture_outputs[cam->output].name) == 0) { - if (((strcmp(fbi->fix.id, "DISP3 FG") == 0) && - (cam->output < 3)) || - ((strcmp(fbi->fix.id, "DISP4 FG") == 0) && - (cam->output >= 3))) - foregound_fb = true; - - cam->overlay_fb = fbi; - break; - } - } while (++i < FB_MAX); - - if (foregound_fb) { - width_bound = bg_fbi->var.xres; - height_bound = bg_fbi->var.yres; - - if (win->w.width + win->w.left > bg_fbi->var.xres || - win->w.height + win->w.top > bg_fbi->var.yres) { - pr_err("ERROR: FG window position exceeds.\n"); - return -1; - } - } else { - /* 4 bytes alignment for BG */ - width_bound = cam->overlay_fb->var.xres; - height_bound = cam->overlay_fb->var.yres; - - if (cam->overlay_fb->var.bits_per_pixel == 24) - win->w.left -= win->w.left % 4; - else if (cam->overlay_fb->var.bits_per_pixel == 16) - win->w.left -= win->w.left % 2; - - if (win->w.width + win->w.left > cam->overlay_fb->var.xres) - win->w.width = cam->overlay_fb->var.xres - win->w.left; - if (win->w.height + win->w.top > cam->overlay_fb->var.yres) - win->w.height = cam->overlay_fb->var.yres - win->w.top; - } - - /* stride line limitation */ - win->w.height -= win->w.height % 8; - win->w.width -= win->w.width % 8; - - if (cam->rotation >= IPU_ROTATE_90_RIGHT) { - height = &win->w.width; - width = &win->w.height; - } else { - width = &win->w.width; - height = &win->w.height; - } - - if (*width == 0 || *height == 0) { - pr_err("ERROR: v4l2 capture: width or height" - " too small.\n"); - return -EINVAL; - } - - if ((cam->crop_bounds.width / *width > 8) || - ((cam->crop_bounds.width / *width == 8) && - (cam->crop_bounds.width % *width))) { - *width = cam->crop_bounds.width / 8; - if (*width % 8) - *width += 8 - *width % 8; - if (*width + win->w.left > width_bound) { - pr_err("ERROR: v4l2 capture: width exceeds " - "resize limit.\n"); - return -1; - } - pr_err("ERROR: v4l2 capture: width exceeds limit. " - "Resize to %d.\n", - *width); - } - - if ((cam->crop_bounds.height / *height > 8) || - ((cam->crop_bounds.height / *height == 8) && - (cam->crop_bounds.height % *height))) { - *height = cam->crop_bounds.height / 8; - if (*height % 8) - *height += 8 - *height % 8; - if (*height + win->w.top > height_bound) { - pr_err("ERROR: v4l2 capture: height exceeds " - "resize limit.\n"); - return -1; - } - pr_err("ERROR: v4l2 capture: height exceeds limit " - "resize to %d.\n", - *height); - } - - return 0; -} - -/*! - * start the viewfinder job - * - * @param cam structure cam_data * - * - * @return status 0 Success - */ -static int start_preview(cam_data *cam) -{ - int err = 0; - - pr_debug("MVC: start_preview\n"); - - if (cam->v4l2_fb.flags == V4L2_FBUF_FLAG_OVERLAY) - #ifdef CONFIG_MXC_IPU_PRP_VF_SDC - err = prp_vf_sdc_select(cam); - #else - err = foreground_sdc_select(cam); - #endif - else if (cam->v4l2_fb.flags == V4L2_FBUF_FLAG_PRIMARY) - #ifdef CONFIG_MXC_IPU_PRP_VF_SDC - err = prp_vf_sdc_select_bg(cam); - #else - err = bg_overlay_sdc_select(cam); - #endif - if (err != 0) - return err; - - if (cam->vf_start_sdc) { - err = cam->vf_start_sdc(cam); - if (err != 0) - return err; - } - - if (cam->vf_enable_csi) - err = cam->vf_enable_csi(cam); - - pr_debug("End of %s: v2f pix widthxheight %d x %d\n", - __func__, - cam->v2f.fmt.pix.width, cam->v2f.fmt.pix.height); - pr_debug("End of %s: crop_bounds widthxheight %d x %d\n", - __func__, - cam->crop_bounds.width, cam->crop_bounds.height); - pr_debug("End of %s: crop_defrect widthxheight %d x %d\n", - __func__, - cam->crop_defrect.width, cam->crop_defrect.height); - pr_debug("End of %s: crop_current widthxheight %d x %d\n", - __func__, - cam->crop_current.width, cam->crop_current.height); - - return err; -} - -/*! - * shut down the viewfinder job - * - * @param cam structure cam_data * - * - * @return status 0 Success - */ -static int stop_preview(cam_data *cam) -{ - int err = 0; - - if (cam->vf_disable_csi) { - err = cam->vf_disable_csi(cam); - if (err != 0) - return err; - } - - if (cam->vf_stop_sdc) { - err = cam->vf_stop_sdc(cam); - if (err != 0) - return err; - } - - if (cam->v4l2_fb.flags == V4L2_FBUF_FLAG_OVERLAY) - #ifdef CONFIG_MXC_IPU_PRP_VF_SDC - err = prp_vf_sdc_deselect(cam); - #else - err = foreground_sdc_deselect(cam); - #endif - else if (cam->v4l2_fb.flags == V4L2_FBUF_FLAG_PRIMARY) - #ifdef CONFIG_MXC_IPU_PRP_VF_SDC - err = prp_vf_sdc_deselect_bg(cam); - #else - err = bg_overlay_sdc_deselect(cam); - #endif - - return err; -} - -/*************************************************************************** - * VIDIOC Functions. - **************************************************************************/ - -/*! - * V4L2 - mxc_v4l2_g_fmt function - * - * @param cam structure cam_data * - * - * @param f structure v4l2_format * - * - * @return status 0 success, EINVAL failed - */ -static int mxc_v4l2_g_fmt(cam_data *cam, struct v4l2_format *f) -{ - int retval = 0; - - pr_debug("In MVC: mxc_v4l2_g_fmt type=%d\n", f->type); - - switch (f->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - pr_debug(" type is V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); - f->fmt.pix = cam->v2f.fmt.pix; - break; - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - pr_debug(" type is V4L2_BUF_TYPE_VIDEO_OVERLAY\n"); - f->fmt.win = cam->win; - break; - default: - pr_debug(" type is invalid\n"); - retval = -EINVAL; - } - - pr_debug("End of %s: v2f pix widthxheight %d x %d\n", - __func__, - cam->v2f.fmt.pix.width, cam->v2f.fmt.pix.height); - pr_debug("End of %s: crop_bounds widthxheight %d x %d\n", - __func__, - cam->crop_bounds.width, cam->crop_bounds.height); - pr_debug("End of %s: crop_defrect widthxheight %d x %d\n", - __func__, - cam->crop_defrect.width, cam->crop_defrect.height); - pr_debug("End of %s: crop_current widthxheight %d x %d\n", - __func__, - cam->crop_current.width, cam->crop_current.height); - - return retval; -} - -/*! - * V4L2 - mxc_v4l2_s_fmt function - * - * @param cam structure cam_data * - * - * @param f structure v4l2_format * - * - * @return status 0 success, EINVAL failed - */ -static int mxc_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f) -{ - int retval = 0; - int size = 0; - int bytesperline = 0; - int *width, *height; - - pr_debug("In MVC: mxc_v4l2_s_fmt\n"); - - switch (f->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - pr_debug(" type=V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); - if (!valid_mode(f->fmt.pix.pixelformat)) { - pr_err("ERROR: v4l2 capture: mxc_v4l2_s_fmt: format " - "not supported\n"); - return -EINVAL; - } - - /* - * Force the capture window resolution to be crop bounds - * for CSI MEM input mode. - */ - if (strcmp(mxc_capture_inputs[cam->current_input].name, - "CSI MEM") == 0) { - f->fmt.pix.width = cam->crop_current.width; - f->fmt.pix.height = cam->crop_current.height; - } - - if (cam->rotation >= IPU_ROTATE_90_RIGHT) { - height = &f->fmt.pix.width; - width = &f->fmt.pix.height; - } else { - width = &f->fmt.pix.width; - height = &f->fmt.pix.height; - } - - /* stride line limitation */ - *width -= *width % 8; - *height -= *height % 8; - - if (*width == 0 || *height == 0) { - pr_err("ERROR: v4l2 capture: width or height" - " too small.\n"); - return -EINVAL; - } - - if ((cam->crop_current.width / *width > 8) || - ((cam->crop_current.width / *width == 8) && - (cam->crop_current.width % *width))) { - *width = cam->crop_current.width / 8; - if (*width % 8) - *width += 8 - *width % 8; - pr_err("ERROR: v4l2 capture: width exceeds limit " - "resize to %d.\n", - *width); - } - - if ((cam->crop_current.height / *height > 8) || - ((cam->crop_current.height / *height == 8) && - (cam->crop_current.height % *height))) { - *height = cam->crop_current.height / 8; - if (*height % 8) - *height += 8 - *height % 8; - pr_err("ERROR: v4l2 capture: height exceeds limit " - "resize to %d.\n", - *height); - } - - switch (f->fmt.pix.pixelformat) { - case V4L2_PIX_FMT_RGB565: - size = f->fmt.pix.width * f->fmt.pix.height * 2; - bytesperline = f->fmt.pix.width * 2; - break; - case V4L2_PIX_FMT_BGR24: - size = f->fmt.pix.width * f->fmt.pix.height * 3; - bytesperline = f->fmt.pix.width * 3; - break; - case V4L2_PIX_FMT_RGB24: - size = f->fmt.pix.width * f->fmt.pix.height * 3; - bytesperline = f->fmt.pix.width * 3; - break; - case V4L2_PIX_FMT_BGR32: - size = f->fmt.pix.width * f->fmt.pix.height * 4; - bytesperline = f->fmt.pix.width * 4; - break; - case V4L2_PIX_FMT_RGB32: - size = f->fmt.pix.width * f->fmt.pix.height * 4; - bytesperline = f->fmt.pix.width * 4; - break; - case V4L2_PIX_FMT_YUV422P: - size = f->fmt.pix.width * f->fmt.pix.height * 2; - bytesperline = f->fmt.pix.width; - break; - case V4L2_PIX_FMT_UYVY: - case V4L2_PIX_FMT_YUYV: - size = f->fmt.pix.width * f->fmt.pix.height * 2; - bytesperline = f->fmt.pix.width * 2; - break; - case V4L2_PIX_FMT_YUV420: - case V4L2_PIX_FMT_YVU420: - size = f->fmt.pix.width * f->fmt.pix.height * 3 / 2; - bytesperline = f->fmt.pix.width; - break; - case V4L2_PIX_FMT_NV12: - size = f->fmt.pix.width * f->fmt.pix.height * 3 / 2; - bytesperline = f->fmt.pix.width; - break; - default: - break; - } - - if (f->fmt.pix.bytesperline < bytesperline) - f->fmt.pix.bytesperline = bytesperline; - else - bytesperline = f->fmt.pix.bytesperline; - - if (f->fmt.pix.sizeimage < size) - f->fmt.pix.sizeimage = size; - else - size = f->fmt.pix.sizeimage; - - cam->v2f.fmt.pix = f->fmt.pix; - break; - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - pr_debug(" type=V4L2_BUF_TYPE_VIDEO_OVERLAY\n"); - retval = verify_preview(cam, &f->fmt.win); - cam->win = f->fmt.win; - break; - default: - retval = -EINVAL; - } - - pr_debug("End of %s: v2f pix widthxheight %d x %d\n", - __func__, - cam->v2f.fmt.pix.width, cam->v2f.fmt.pix.height); - pr_debug("End of %s: crop_bounds widthxheight %d x %d\n", - __func__, - cam->crop_bounds.width, cam->crop_bounds.height); - pr_debug("End of %s: crop_defrect widthxheight %d x %d\n", - __func__, - cam->crop_defrect.width, cam->crop_defrect.height); - pr_debug("End of %s: crop_current widthxheight %d x %d\n", - __func__, - cam->crop_current.width, cam->crop_current.height); - - return retval; -} - -/*! - * get control param - * - * @param cam structure cam_data * - * - * @param c structure v4l2_control * - * - * @return status 0 success, EINVAL failed - */ -static int mxc_v4l2_g_ctrl(cam_data *cam, struct v4l2_control *c) -{ - int status = 0; - - pr_debug("In MVC:mxc_v4l2_g_ctrl\n"); - - /* probably don't need to store the values that can be retrieved, - * locally, but they are for now. */ - switch (c->id) { - case V4L2_CID_HFLIP: - /* This is handled in the ipu. */ - if (cam->rotation == IPU_ROTATE_HORIZ_FLIP) - c->value = 1; - break; - case V4L2_CID_VFLIP: - /* This is handled in the ipu. */ - if (cam->rotation == IPU_ROTATE_VERT_FLIP) - c->value = 1; - break; - case V4L2_CID_MXC_ROT: - /* This is handled in the ipu. */ - c->value = cam->rotation; - break; - case V4L2_CID_BRIGHTNESS: - if (cam->sensor) { - c->value = cam->bright; - status = vidioc_int_g_ctrl(cam->sensor, c); - cam->bright = c->value; - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - status = -ENODEV; - } - break; - case V4L2_CID_HUE: - if (cam->sensor) { - c->value = cam->hue; - status = vidioc_int_g_ctrl(cam->sensor, c); - cam->hue = c->value; - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - status = -ENODEV; - } - break; - case V4L2_CID_CONTRAST: - if (cam->sensor) { - c->value = cam->contrast; - status = vidioc_int_g_ctrl(cam->sensor, c); - cam->contrast = c->value; - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - status = -ENODEV; - } - break; - case V4L2_CID_SATURATION: - if (cam->sensor) { - c->value = cam->saturation; - status = vidioc_int_g_ctrl(cam->sensor, c); - cam->saturation = c->value; - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - status = -ENODEV; - } - break; - case V4L2_CID_RED_BALANCE: - if (cam->sensor) { - c->value = cam->red; - status = vidioc_int_g_ctrl(cam->sensor, c); - cam->red = c->value; - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - status = -ENODEV; - } - break; - case V4L2_CID_BLUE_BALANCE: - if (cam->sensor) { - c->value = cam->blue; - status = vidioc_int_g_ctrl(cam->sensor, c); - cam->blue = c->value; - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - status = -ENODEV; - } - break; - case V4L2_CID_BLACK_LEVEL: - if (cam->sensor) { - c->value = cam->ae_mode; - status = vidioc_int_g_ctrl(cam->sensor, c); - cam->ae_mode = c->value; - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - status = -ENODEV; - } - break; - default: - pr_err("ERROR: v4l2 capture: unsupported ioctrl!\n"); - } - - return status; -} - -/*! - * V4L2 - set_control function - * V4L2_CID_PRIVATE_BASE is the extention for IPU preprocessing. - * 0 for normal operation - * 1 for vertical flip - * 2 for horizontal flip - * 3 for horizontal and vertical flip - * 4 for 90 degree rotation - * @param cam structure cam_data * - * - * @param c structure v4l2_control * - * - * @return status 0 success, EINVAL failed - */ -static int mxc_v4l2_s_ctrl(cam_data *cam, struct v4l2_control *c) -{ - int i, ret = 0; - int tmp_rotation = IPU_ROTATE_NONE; - struct sensor_data *sensor_data; - - pr_debug("In MVC:mxc_v4l2_s_ctrl\n"); - - switch (c->id) { - case V4L2_CID_HFLIP: - /* This is done by the IPU */ - if (c->value == 1) { - if ((cam->rotation != IPU_ROTATE_VERT_FLIP) && - (cam->rotation != IPU_ROTATE_180)) - cam->rotation = IPU_ROTATE_HORIZ_FLIP; - else - cam->rotation = IPU_ROTATE_180; - } else { - if (cam->rotation == IPU_ROTATE_HORIZ_FLIP) - cam->rotation = IPU_ROTATE_NONE; - if (cam->rotation == IPU_ROTATE_180) - cam->rotation = IPU_ROTATE_VERT_FLIP; - } - break; - case V4L2_CID_VFLIP: - /* This is done by the IPU */ - if (c->value == 1) { - if ((cam->rotation != IPU_ROTATE_HORIZ_FLIP) && - (cam->rotation != IPU_ROTATE_180)) - cam->rotation = IPU_ROTATE_VERT_FLIP; - else - cam->rotation = IPU_ROTATE_180; - } else { - if (cam->rotation == IPU_ROTATE_VERT_FLIP) - cam->rotation = IPU_ROTATE_NONE; - if (cam->rotation == IPU_ROTATE_180) - cam->rotation = IPU_ROTATE_HORIZ_FLIP; - } - break; - case V4L2_CID_MXC_ROT: - case V4L2_CID_MXC_VF_ROT: - /* This is done by the IPU */ - switch (c->value) { - case V4L2_MXC_ROTATE_NONE: - tmp_rotation = IPU_ROTATE_NONE; - break; - case V4L2_MXC_ROTATE_VERT_FLIP: - tmp_rotation = IPU_ROTATE_VERT_FLIP; - break; - case V4L2_MXC_ROTATE_HORIZ_FLIP: - tmp_rotation = IPU_ROTATE_HORIZ_FLIP; - break; - case V4L2_MXC_ROTATE_180: - tmp_rotation = IPU_ROTATE_180; - break; - case V4L2_MXC_ROTATE_90_RIGHT: - tmp_rotation = IPU_ROTATE_90_RIGHT; - break; - case V4L2_MXC_ROTATE_90_RIGHT_VFLIP: - tmp_rotation = IPU_ROTATE_90_RIGHT_VFLIP; - break; - case V4L2_MXC_ROTATE_90_RIGHT_HFLIP: - tmp_rotation = IPU_ROTATE_90_RIGHT_HFLIP; - break; - case V4L2_MXC_ROTATE_90_LEFT: - tmp_rotation = IPU_ROTATE_90_LEFT; - break; - default: - ret = -EINVAL; - } - #ifdef CONFIG_MXC_IPU_PRP_VF_SDC - if (c->id == V4L2_CID_MXC_VF_ROT) - cam->vf_rotation = tmp_rotation; - else - cam->rotation = tmp_rotation; - #else - cam->rotation = tmp_rotation; - #endif - - break; - case V4L2_CID_HUE: - if (cam->sensor) { - cam->hue = c->value; - ret = vidioc_int_s_ctrl(cam->sensor, c); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - ret = -ENODEV; - } - break; - case V4L2_CID_CONTRAST: - if (cam->sensor) { - cam->contrast = c->value; - ret = vidioc_int_s_ctrl(cam->sensor, c); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - ret = -ENODEV; - } - break; - case V4L2_CID_BRIGHTNESS: - if (cam->sensor) { - cam->bright = c->value; - ret = vidioc_int_s_ctrl(cam->sensor, c); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - ret = -ENODEV; - } - break; - case V4L2_CID_SATURATION: - if (cam->sensor) { - cam->saturation = c->value; - ret = vidioc_int_s_ctrl(cam->sensor, c); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - ret = -ENODEV; - } - break; - case V4L2_CID_RED_BALANCE: - if (cam->sensor) { - cam->red = c->value; - ret = vidioc_int_s_ctrl(cam->sensor, c); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - ret = -ENODEV; - } - break; - case V4L2_CID_BLUE_BALANCE: - if (cam->sensor) { - cam->blue = c->value; - ret = vidioc_int_s_ctrl(cam->sensor, c); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - ret = -ENODEV; - } - break; - case V4L2_CID_EXPOSURE: - if (cam->sensor) { - cam->ae_mode = c->value; - ret = vidioc_int_s_ctrl(cam->sensor, c); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - ret = -ENODEV; - } - break; - case V4L2_CID_MXC_FLASH: -#ifdef CONFIG_MXC_IPU_V1 - ipu_csi_flash_strobe(true); -#endif - break; - case V4L2_CID_MXC_SWITCH_CAM: - if (cam->sensor == cam->all_sensors[c->value]) - break; - - /* power down other cameraes before enable new one */ - for (i = 0; i < cam->sensor_index; i++) { - if (i != c->value) { - vidioc_int_dev_exit(cam->all_sensors[i]); - vidioc_int_s_power(cam->all_sensors[i], 0); - if (cam->mclk_on[cam->mclk_source]) { - ipu_csi_enable_mclk_if(cam->ipu, - CSI_MCLK_I2C, - cam->mclk_source, - false, false); - cam->mclk_on[cam->mclk_source] = - false; - } - } - } - sensor_data = cam->all_sensors[c->value]->priv; - if (sensor_data->io_init) - sensor_data->io_init(); - cam->sensor = cam->all_sensors[c->value]; - cam->mclk_source = sensor_data->mclk_source; - ipu_csi_enable_mclk_if(cam->ipu, CSI_MCLK_I2C, - cam->mclk_source, true, true); - cam->mclk_on[cam->mclk_source] = true; - vidioc_int_s_power(cam->sensor, 1); - vidioc_int_dev_init(cam->sensor); - break; - default: - pr_debug(" default case\n"); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * V4L2 - mxc_v4l2_s_param function - * Allows setting of capturemode and frame rate. - * - * @param cam structure cam_data * - * @param parm structure v4l2_streamparm * - * - * @return status 0 success, EINVAL failed - */ -static int mxc_v4l2_s_param(cam_data *cam, struct v4l2_streamparm *parm) -{ - struct v4l2_ifparm ifparm; - struct v4l2_format cam_fmt; - struct v4l2_streamparm currentparm; - ipu_csi_signal_cfg_t csi_param; - u32 current_fps, parm_fps; - int err = 0; - - pr_debug("In mxc_v4l2_s_param\n"); - - if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - pr_err(KERN_ERR "mxc_v4l2_s_param invalid type\n"); - return -EINVAL; - } - - /* Stop the viewfinder */ - if (cam->overlay_on == true) - stop_preview(cam); - - currentparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - /* First check that this device can support the changes requested. */ - err = vidioc_int_g_parm(cam->sensor, ¤tparm); - if (err) { - pr_err("%s: vidioc_int_g_parm returned an error %d\n", - __func__, err); - goto exit; - } - - current_fps = currentparm.parm.capture.timeperframe.denominator - / currentparm.parm.capture.timeperframe.numerator; - parm_fps = parm->parm.capture.timeperframe.denominator - / parm->parm.capture.timeperframe.numerator; - - pr_debug(" Current capabilities are %x\n", - currentparm.parm.capture.capability); - pr_debug(" Current capturemode is %d change to %d\n", - currentparm.parm.capture.capturemode, - parm->parm.capture.capturemode); - pr_debug(" Current framerate is %d change to %d\n", - current_fps, parm_fps); - - /* This will change any camera settings needed. */ - err = vidioc_int_s_parm(cam->sensor, parm); - if (err) { - pr_err("%s: vidioc_int_s_parm returned an error %d\n", - __func__, err); - goto exit; - } - - /* If resolution changed, need to re-program the CSI */ - /* Get new values. */ - vidioc_int_g_ifparm(cam->sensor, &ifparm); - - csi_param.data_width = 0; - csi_param.clk_mode = 0; - csi_param.ext_vsync = 0; - csi_param.Vsync_pol = 0; - csi_param.Hsync_pol = 0; - csi_param.pixclk_pol = 0; - csi_param.data_pol = 0; - csi_param.sens_clksrc = 0; - csi_param.pack_tight = 0; - csi_param.force_eof = 0; - csi_param.data_en_pol = 0; - csi_param.data_fmt = 0; - csi_param.csi = cam->csi; - csi_param.mclk = 0; - - pr_debug(" clock_curr=mclk=%d\n", ifparm.u.bt656.clock_curr); - if (ifparm.u.bt656.clock_curr == 0) - csi_param.clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED; - else - csi_param.clk_mode = IPU_CSI_CLK_MODE_GATED_CLK; - - csi_param.pixclk_pol = ifparm.u.bt656.latch_clk_inv; - - if (ifparm.u.bt656.mode == V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT) { - csi_param.data_width = IPU_CSI_DATA_WIDTH_8; - } else if (ifparm.u.bt656.mode - == V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT) { - csi_param.data_width = IPU_CSI_DATA_WIDTH_10; - } else { - csi_param.data_width = IPU_CSI_DATA_WIDTH_8; - } - - csi_param.Vsync_pol = ifparm.u.bt656.nobt_vs_inv; - csi_param.Hsync_pol = ifparm.u.bt656.nobt_hs_inv; - csi_param.ext_vsync = ifparm.u.bt656.bt_sync_correct; - - /* if the capturemode changed, the size bounds will have changed. */ - cam_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - vidioc_int_g_fmt_cap(cam->sensor, &cam_fmt); - pr_debug(" g_fmt_cap returns widthxheight of input as %d x %d\n", - cam_fmt.fmt.pix.width, cam_fmt.fmt.pix.height); - - csi_param.data_fmt = cam_fmt.fmt.pix.pixelformat; - - cam->crop_bounds.top = cam->crop_bounds.left = 0; - cam->crop_bounds.width = cam_fmt.fmt.pix.width; - cam->crop_bounds.height = cam_fmt.fmt.pix.height; - - /* - * Set the default current cropped resolution to be the same with - * the cropping boundary(except for tvin module). - */ - if (cam->device_type != 1) { - cam->crop_current.width = cam->crop_bounds.width; - cam->crop_current.height = cam->crop_bounds.height; - } - - /* This essentially loses the data at the left and bottom of the image - * giving a digital zoom image, if crop_current is less than the full - * size of the image. */ - ipu_csi_set_window_size(cam->ipu, cam->crop_current.width, - cam->crop_current.height, cam->csi); - ipu_csi_set_window_pos(cam->ipu, cam->crop_current.left, - cam->crop_current.top, - cam->csi); - ipu_csi_init_interface(cam->ipu, cam->crop_bounds.width, - cam->crop_bounds.height, - cam_fmt.fmt.pix.pixelformat, csi_param); - - -exit: - if (cam->overlay_on == true) - start_preview(cam); - - return err; -} - -/*! - * V4L2 - mxc_v4l2_s_std function - * - * Sets the TV standard to be used. - * - * @param cam structure cam_data * - * @param parm structure v4l2_streamparm * - * - * @return status 0 success, EINVAL failed - */ -static int mxc_v4l2_s_std(cam_data *cam, v4l2_std_id e) -{ - pr_debug("In mxc_v4l2_s_std %Lx\n", e); - - if (e == V4L2_STD_PAL) { - pr_debug(" Setting standard to PAL %Lx\n", V4L2_STD_PAL); - cam->standard.id = V4L2_STD_PAL; - video_index = TV_PAL; - } else if (e == V4L2_STD_NTSC) { - pr_debug(" Setting standard to NTSC %Lx\n", - V4L2_STD_NTSC); - /* Get rid of the white dot line in NTSC signal input */ - cam->standard.id = V4L2_STD_NTSC; - video_index = TV_NTSC; - } else { - cam->standard.id = V4L2_STD_ALL; - video_index = TV_NOT_LOCKED; - pr_err("ERROR: unrecognized std! %Lx (PAL=%Lx, NTSC=%Lx\n", - e, V4L2_STD_PAL, V4L2_STD_NTSC); - } - - cam->standard.index = video_index; - strcpy(cam->standard.name, video_fmts[video_index].name); - cam->crop_bounds.width = video_fmts[video_index].raw_width; - cam->crop_bounds.height = video_fmts[video_index].raw_height; - cam->crop_current.width = video_fmts[video_index].active_width; - cam->crop_current.height = video_fmts[video_index].active_height; - cam->crop_current.top = video_fmts[video_index].active_top; - cam->crop_current.left = video_fmts[video_index].active_left; - - return 0; -} - -/*! - * V4L2 - mxc_v4l2_g_std function - * - * Gets the TV standard from the TV input device. - * - * @param cam structure cam_data * - * - * @param e structure v4l2_streamparm * - * - * @return status 0 success, EINVAL failed - */ -static int mxc_v4l2_g_std(cam_data *cam, v4l2_std_id *e) -{ - struct v4l2_format tv_fmt; - - pr_debug("In mxc_v4l2_g_std\n"); - - if (cam->device_type == 1) { - /* Use this function to get what the TV-In device detects the - * format to be. pixelformat is used to return the std value - * since the interface has no vidioc_g_std.*/ - tv_fmt.type = V4L2_BUF_TYPE_PRIVATE; - vidioc_int_g_fmt_cap(cam->sensor, &tv_fmt); - - /* If the TV-in automatically detects the standard, then if it - * changes, the settings need to change. */ - if (cam->standard_autodetect) { - if (cam->standard.id != tv_fmt.fmt.pix.pixelformat) { - pr_debug("MVC: mxc_v4l2_g_std: " - "Changing standard\n"); - mxc_v4l2_s_std(cam, tv_fmt.fmt.pix.pixelformat); - } - } - - *e = tv_fmt.fmt.pix.pixelformat; - } - - return 0; -} - -/*! - * Dequeue one V4L capture buffer - * - * @param cam structure cam_data * - * @param buf structure v4l2_buffer * - * - * @return status 0 success, EINVAL invalid frame number, - * ETIME timeout, ERESTARTSYS interrupted by user - */ -static int mxc_v4l_dqueue(cam_data *cam, struct v4l2_buffer *buf) -{ - int retval = 0; - struct mxc_v4l_frame *frame; - unsigned long lock_flags; - - pr_debug("In MVC:mxc_v4l_dqueue\n"); - - if (!wait_event_interruptible_timeout(cam->enc_queue, - cam->enc_counter != 0, - 10 * HZ)) { - pr_err("ERROR: v4l2 capture: mxc_v4l_dqueue timeout " - "enc_counter %x\n", - cam->enc_counter); - return -ETIME; - } else if (signal_pending(current)) { - pr_err("ERROR: v4l2 capture: mxc_v4l_dqueue() " - "interrupt received\n"); - return -ERESTARTSYS; - } - - if (down_interruptible(&cam->busy_lock)) - return -EBUSY; - - spin_lock_irqsave(&cam->dqueue_int_lock, lock_flags); - cam->enc_counter--; - - frame = list_entry(cam->done_q.next, struct mxc_v4l_frame, queue); - list_del(cam->done_q.next); - if (frame->buffer.flags & V4L2_BUF_FLAG_DONE) { - frame->buffer.flags &= ~V4L2_BUF_FLAG_DONE; - } else if (frame->buffer.flags & V4L2_BUF_FLAG_QUEUED) { - pr_err("ERROR: v4l2 capture: VIDIOC_DQBUF: " - "Buffer not filled.\n"); - frame->buffer.flags &= ~V4L2_BUF_FLAG_QUEUED; - retval = -EINVAL; - } else if ((frame->buffer.flags & 0x7) == V4L2_BUF_FLAG_MAPPED) { - pr_err("ERROR: v4l2 capture: VIDIOC_DQBUF: " - "Buffer not queued.\n"); - retval = -EINVAL; - } - - cam->frame[frame->index].buffer.field = cam->device_type ? - V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE; - - buf->bytesused = cam->v2f.fmt.pix.sizeimage; - buf->index = frame->index; - buf->flags = frame->buffer.flags; - buf->m = cam->frame[frame->index].buffer.m; - buf->timestamp = cam->frame[frame->index].buffer.timestamp; - buf->field = cam->frame[frame->index].buffer.field; - spin_unlock_irqrestore(&cam->dqueue_int_lock, lock_flags); - - up(&cam->busy_lock); - return retval; -} - -/*! - * V4L interface - open function - * - * @param file structure file * - * - * @return status 0 success, ENODEV invalid device instance, - * ENODEV timeout, ERESTARTSYS interrupted by user - */ -static int mxc_v4l_open(struct file *file) -{ - struct v4l2_ifparm ifparm; - struct v4l2_format cam_fmt; - ipu_csi_signal_cfg_t csi_param; - struct video_device *dev = video_devdata(file); - cam_data *cam = video_get_drvdata(dev); - int err = 0; - struct sensor_data *sensor; - - pr_debug("\nIn MVC: mxc_v4l_open\n"); - pr_debug(" device name is %s\n", dev->name); - - if (!cam) { - pr_err("ERROR: v4l2 capture: Internal error, " - "cam_data not found!\n"); - return -EBADF; - } - - if (cam->sensor == NULL || - cam->sensor->type != v4l2_int_type_slave) { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - return -EAGAIN; - } - - sensor = cam->sensor->priv; - if (!sensor) { - pr_err("%s: Internal error, sensor_data is not found!\n", - __func__); - return -EBADF; - } - - down(&cam->busy_lock); - err = 0; - if (signal_pending(current)) - goto oops; - - if (cam->open_count++ == 0) { - wait_event_interruptible(cam->power_queue, - cam->low_power == false); - - if (strcmp(mxc_capture_inputs[cam->current_input].name, - "CSI MEM") == 0) { -#if defined(CONFIG_MXC_IPU_CSI_ENC) || defined(CONFIG_MXC_IPU_CSI_ENC_MODULE) - err = csi_enc_select(cam); -#endif - } else if (strcmp(mxc_capture_inputs[cam->current_input].name, - "CSI IC MEM") == 0) { -#if defined(CONFIG_MXC_IPU_PRP_ENC) || defined(CONFIG_MXC_IPU_PRP_ENC_MODULE) - err = prp_enc_select(cam); -#endif - } - - cam->enc_counter = 0; - INIT_LIST_HEAD(&cam->ready_q); - INIT_LIST_HEAD(&cam->working_q); - INIT_LIST_HEAD(&cam->done_q); - - vidioc_int_g_ifparm(cam->sensor, &ifparm); - - csi_param.sens_clksrc = 0; - - csi_param.clk_mode = 0; - csi_param.data_pol = 0; - csi_param.ext_vsync = 0; - - csi_param.pack_tight = 0; - csi_param.force_eof = 0; - csi_param.data_en_pol = 0; - - csi_param.mclk = ifparm.u.bt656.clock_curr; - - csi_param.pixclk_pol = ifparm.u.bt656.latch_clk_inv; - - if (ifparm.u.bt656.mode - == V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT) - csi_param.data_width = IPU_CSI_DATA_WIDTH_8; - else if (ifparm.u.bt656.mode - == V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT) - csi_param.data_width = IPU_CSI_DATA_WIDTH_10; - else - csi_param.data_width = IPU_CSI_DATA_WIDTH_8; - - - csi_param.Vsync_pol = ifparm.u.bt656.nobt_vs_inv; - csi_param.Hsync_pol = ifparm.u.bt656.nobt_hs_inv; - - csi_param.csi = cam->csi; - - cam_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - vidioc_int_g_fmt_cap(cam->sensor, &cam_fmt); - - /* Reset the sizes. Needed to prevent carryover of last - * operation.*/ - cam->crop_bounds.top = cam->crop_bounds.left = 0; - cam->crop_bounds.width = cam_fmt.fmt.pix.width; - cam->crop_bounds.height = cam_fmt.fmt.pix.height; - - /* This also is the max crop size for this device. */ - cam->crop_defrect.top = cam->crop_defrect.left = 0; - cam->crop_defrect.width = cam_fmt.fmt.pix.width; - cam->crop_defrect.height = cam_fmt.fmt.pix.height; - - /* At this point, this is also the current image size. */ - cam->crop_current.top = cam->crop_current.left = 0; - cam->crop_current.width = cam_fmt.fmt.pix.width; - cam->crop_current.height = cam_fmt.fmt.pix.height; - - pr_debug("End of %s: v2f pix widthxheight %d x %d\n", - __func__, - cam->v2f.fmt.pix.width, cam->v2f.fmt.pix.height); - pr_debug("End of %s: crop_bounds widthxheight %d x %d\n", - __func__, - cam->crop_bounds.width, cam->crop_bounds.height); - pr_debug("End of %s: crop_defrect widthxheight %d x %d\n", - __func__, - cam->crop_defrect.width, cam->crop_defrect.height); - pr_debug("End of %s: crop_current widthxheight %d x %d\n", - __func__, - cam->crop_current.width, cam->crop_current.height); - - csi_param.data_fmt = cam_fmt.fmt.pix.pixelformat; - pr_debug("On Open: Input to ipu size is %d x %d\n", - cam_fmt.fmt.pix.width, cam_fmt.fmt.pix.height); - ipu_csi_set_window_size(cam->ipu, cam->crop_current.width, - cam->crop_current.height, - cam->csi); - ipu_csi_set_window_pos(cam->ipu, cam->crop_current.left, - cam->crop_current.top, - cam->csi); - ipu_csi_init_interface(cam->ipu, cam->crop_bounds.width, - cam->crop_bounds.height, - cam_fmt.fmt.pix.pixelformat, - csi_param); - clk_prepare_enable(sensor->sensor_clk); - vidioc_int_s_power(cam->sensor, 1); - vidioc_int_init(cam->sensor); - vidioc_int_dev_init(cam->sensor); - } - - file->private_data = dev; - -oops: - up(&cam->busy_lock); - return err; -} - -/*! - * V4L interface - close function - * - * @param file struct file * - * - * @return 0 success - */ -static int mxc_v4l_close(struct file *file) -{ - struct video_device *dev = video_devdata(file); - int err = 0; - cam_data *cam = video_get_drvdata(dev); - struct sensor_data *sensor; - pr_debug("In MVC:mxc_v4l_close\n"); - - if (!cam) { - pr_err("ERROR: v4l2 capture: Internal error, " - "cam_data not found!\n"); - return -EBADF; - } - - if (!cam->sensor) { - pr_err("%s: Internal error, camera is not found!\n", - __func__); - return -EBADF; - } - - sensor = cam->sensor->priv; - if (!sensor) { - pr_err("%s: Internal error, sensor_data is not found!\n", - __func__); - return -EBADF; - } - - down(&cam->busy_lock); - - /* for the case somebody hit the ctrl C */ - if (cam->overlay_pid == current->pid && cam->overlay_on) { - err = stop_preview(cam); - cam->overlay_on = false; - } - if (cam->capture_pid == current->pid) { - err |= mxc_streamoff(cam); - wake_up_interruptible(&cam->enc_queue); - } - - if (--cam->open_count == 0) { - vidioc_int_s_power(cam->sensor, 0); - clk_disable_unprepare(sensor->sensor_clk); - wait_event_interruptible(cam->power_queue, - cam->low_power == false); - pr_debug("mxc_v4l_close: release resource\n"); - - if (strcmp(mxc_capture_inputs[cam->current_input].name, - "CSI MEM") == 0) { -#if defined(CONFIG_MXC_IPU_CSI_ENC) || defined(CONFIG_MXC_IPU_CSI_ENC_MODULE) - err |= csi_enc_deselect(cam); -#endif - } else if (strcmp(mxc_capture_inputs[cam->current_input].name, - "CSI IC MEM") == 0) { -#if defined(CONFIG_MXC_IPU_PRP_ENC) || defined(CONFIG_MXC_IPU_PRP_ENC_MODULE) - err |= prp_enc_deselect(cam); -#endif - } - - mxc_free_frame_buf(cam); - file->private_data = NULL; - - /* capture off */ - wake_up_interruptible(&cam->enc_queue); - mxc_free_frames(cam); - cam->enc_counter++; - } - - up(&cam->busy_lock); - - return err; -} - -#if defined(CONFIG_MXC_IPU_PRP_ENC) || defined(CONFIG_MXC_IPU_CSI_ENC) || \ - defined(CONFIG_MXC_IPU_PRP_ENC_MODULE) || \ - defined(CONFIG_MXC_IPU_CSI_ENC_MODULE) -/* - * V4L interface - read function - * - * @param file struct file * - * @param read buf char * - * @param count size_t - * @param ppos structure loff_t * - * - * @return bytes read - */ -static ssize_t mxc_v4l_read(struct file *file, char *buf, size_t count, - loff_t *ppos) -{ - int err = 0; - u8 *v_address[2]; - struct video_device *dev = video_devdata(file); - cam_data *cam = video_get_drvdata(dev); - - if (down_interruptible(&cam->busy_lock)) - return -EINTR; - - /* Stop the viewfinder */ - if (cam->overlay_on == true) - stop_preview(cam); - - v_address[0] = dma_alloc_coherent(0, - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage), - &cam->still_buf[0], - GFP_DMA | GFP_KERNEL); - - v_address[1] = dma_alloc_coherent(0, - PAGE_ALIGN(cam->v2f.fmt.pix.sizeimage), - &cam->still_buf[1], - GFP_DMA | GFP_KERNEL); - - if (!v_address[0] || !v_address[1]) { - err = -ENOBUFS; - goto exit0; - } - - err = prp_still_select(cam); - if (err != 0) { - err = -EIO; - goto exit0; - } - - cam->still_counter = 0; - err = cam->csi_start(cam); - if (err != 0) { - err = -EIO; - goto exit1; - } - - if (!wait_event_interruptible_timeout(cam->still_queue, - cam->still_counter != 0, - 10 * HZ)) { - pr_err("ERROR: v4l2 capture: mxc_v4l_read timeout counter %x\n", - cam->still_counter); - err = -ETIME; - goto exit1; - } - err = copy_to_user(buf, v_address[1], cam->v2f.fmt.pix.sizeimage); - -exit1: - prp_still_deselect(cam); - -exit0: - if (v_address[0] != 0) - dma_free_coherent(0, cam->v2f.fmt.pix.sizeimage, v_address[0], - cam->still_buf[0]); - if (v_address[1] != 0) - dma_free_coherent(0, cam->v2f.fmt.pix.sizeimage, v_address[1], - cam->still_buf[1]); - - cam->still_buf[0] = cam->still_buf[1] = 0; - - if (cam->overlay_on == true) - start_preview(cam); - - up(&cam->busy_lock); - if (err < 0) - return err; - - return cam->v2f.fmt.pix.sizeimage - err; -} -#endif - -/*! - * V4L interface - ioctl function - * - * @param file struct file* - * - * @param ioctlnr unsigned int - * - * @param arg void* - * - * @return 0 success, ENODEV for invalid device instance, - * -1 for other errors. - */ -static long mxc_v4l_do_ioctl(struct file *file, - unsigned int ioctlnr, void *arg) -{ - struct video_device *dev = video_devdata(file); - cam_data *cam = video_get_drvdata(dev); - int retval = 0; - unsigned long lock_flags; - - pr_debug("In MVC: mxc_v4l_do_ioctl %x\n", ioctlnr); - wait_event_interruptible(cam->power_queue, cam->low_power == false); - /* make this _really_ smp-safe */ - if (ioctlnr != VIDIOC_DQBUF) - if (down_interruptible(&cam->busy_lock)) - return -EBUSY; - - switch (ioctlnr) { - /*! - * V4l2 VIDIOC_QUERYCAP ioctl - */ - case VIDIOC_QUERYCAP: { - struct v4l2_capability *cap = arg; - pr_debug(" case VIDIOC_QUERYCAP\n"); - strcpy(cap->driver, "mxc_v4l2"); - cap->version = KERNEL_VERSION(0, 1, 11); - cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | - V4L2_CAP_VIDEO_OVERLAY | - V4L2_CAP_STREAMING | - V4L2_CAP_READWRITE; - cap->card[0] = '\0'; - cap->bus_info[0] = '\0'; - break; - } - - /*! - * V4l2 VIDIOC_G_FMT ioctl - */ - case VIDIOC_G_FMT: { - struct v4l2_format *gf = arg; - pr_debug(" case VIDIOC_G_FMT\n"); - retval = mxc_v4l2_g_fmt(cam, gf); - break; - } - - /*! - * V4l2 VIDIOC_S_DEST_CROP ioctl - */ - case VIDIOC_S_DEST_CROP: { - struct v4l2_mxc_dest_crop *of = arg; - pr_debug(" case VIDIOC_S_DEST_CROP\n"); - cam->offset.u_offset = of->offset.u_offset; - cam->offset.v_offset = of->offset.v_offset; - break; - } - - /*! - * V4l2 VIDIOC_S_FMT ioctl - */ - case VIDIOC_S_FMT: { - struct v4l2_format *sf = arg; - pr_debug(" case VIDIOC_S_FMT\n"); - retval = mxc_v4l2_s_fmt(cam, sf); - break; - } - - /*! - * V4l2 VIDIOC_REQBUFS ioctl - */ - case VIDIOC_REQBUFS: { - struct v4l2_requestbuffers *req = arg; - pr_debug(" case VIDIOC_REQBUFS\n"); - - if (req->count > FRAME_NUM) { - pr_err("ERROR: v4l2 capture: VIDIOC_REQBUFS: " - "not enough buffers\n"); - req->count = FRAME_NUM; - } - - if ((req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) { - pr_err("ERROR: v4l2 capture: VIDIOC_REQBUFS: " - "wrong buffer type\n"); - retval = -EINVAL; - break; - } - - mxc_streamoff(cam); - if (req->memory & V4L2_MEMORY_MMAP) { - mxc_free_frame_buf(cam); - retval = mxc_allocate_frame_buf(cam, req->count); - } - break; - } - - /*! - * V4l2 VIDIOC_QUERYBUF ioctl - */ - case VIDIOC_QUERYBUF: { - struct v4l2_buffer *buf = arg; - int index = buf->index; - pr_debug(" case VIDIOC_QUERYBUF\n"); - - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - pr_err("ERROR: v4l2 capture: " - "VIDIOC_QUERYBUFS: " - "wrong buffer type\n"); - retval = -EINVAL; - break; - } - - if (buf->memory & V4L2_MEMORY_MMAP) { - memset(buf, 0, sizeof(buf)); - buf->index = index; - } - - down(&cam->param_lock); - if (buf->memory & V4L2_MEMORY_USERPTR) { - mxc_v4l2_release_bufs(cam); - retval = mxc_v4l2_prepare_bufs(cam, buf); - } - - if (buf->memory & V4L2_MEMORY_MMAP) - retval = mxc_v4l2_buffer_status(cam, buf); - up(&cam->param_lock); - break; - } - - /*! - * V4l2 VIDIOC_QBUF ioctl - */ - case VIDIOC_QBUF: { - struct v4l2_buffer *buf = arg; - int index = buf->index; - pr_debug(" case VIDIOC_QBUF\n"); - - spin_lock_irqsave(&cam->queue_int_lock, lock_flags); - if ((cam->frame[index].buffer.flags & 0x7) == - V4L2_BUF_FLAG_MAPPED) { - cam->frame[index].buffer.flags |= - V4L2_BUF_FLAG_QUEUED; - list_add_tail(&cam->frame[index].queue, - &cam->ready_q); - } else if (cam->frame[index].buffer. - flags & V4L2_BUF_FLAG_QUEUED) { - pr_err("ERROR: v4l2 capture: VIDIOC_QBUF: " - "buffer already queued\n"); - retval = -EINVAL; - } else if (cam->frame[index].buffer. - flags & V4L2_BUF_FLAG_DONE) { - pr_err("ERROR: v4l2 capture: VIDIOC_QBUF: " - "overwrite done buffer.\n"); - cam->frame[index].buffer.flags &= - ~V4L2_BUF_FLAG_DONE; - cam->frame[index].buffer.flags |= - V4L2_BUF_FLAG_QUEUED; - retval = -EINVAL; - } - - buf->flags = cam->frame[index].buffer.flags; - spin_unlock_irqrestore(&cam->queue_int_lock, lock_flags); - break; - } - - /*! - * V4l2 VIDIOC_DQBUF ioctl - */ - case VIDIOC_DQBUF: { - struct v4l2_buffer *buf = arg; - pr_debug(" case VIDIOC_DQBUF\n"); - - if ((cam->enc_counter == 0) && - (file->f_flags & O_NONBLOCK)) { - retval = -EAGAIN; - break; - } - - retval = mxc_v4l_dqueue(cam, buf); - break; - } - - /*! - * V4l2 VIDIOC_STREAMON ioctl - */ - case VIDIOC_STREAMON: { - pr_debug(" case VIDIOC_STREAMON\n"); - retval = mxc_streamon(cam); - break; - } - - /*! - * V4l2 VIDIOC_STREAMOFF ioctl - */ - case VIDIOC_STREAMOFF: { - pr_debug(" case VIDIOC_STREAMOFF\n"); - retval = mxc_streamoff(cam); - break; - } - - /*! - * V4l2 VIDIOC_G_CTRL ioctl - */ - case VIDIOC_G_CTRL: { - pr_debug(" case VIDIOC_G_CTRL\n"); - retval = mxc_v4l2_g_ctrl(cam, arg); - break; - } - - /*! - * V4l2 VIDIOC_S_CTRL ioctl - */ - case VIDIOC_S_CTRL: { - pr_debug(" case VIDIOC_S_CTRL\n"); - retval = mxc_v4l2_s_ctrl(cam, arg); - break; - } - - /*! - * V4l2 VIDIOC_CROPCAP ioctl - */ - case VIDIOC_CROPCAP: { - struct v4l2_cropcap *cap = arg; - pr_debug(" case VIDIOC_CROPCAP\n"); - if (cap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) { - retval = -EINVAL; - break; - } - cap->bounds = cam->crop_bounds; - cap->defrect = cam->crop_defrect; - break; - } - - /*! - * V4l2 VIDIOC_G_CROP ioctl - */ - case VIDIOC_G_CROP: { - struct v4l2_crop *crop = arg; - pr_debug(" case VIDIOC_G_CROP\n"); - - if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) { - retval = -EINVAL; - break; - } - crop->c = cam->crop_current; - break; - } - - /*! - * V4l2 VIDIOC_S_CROP ioctl - */ - case VIDIOC_S_CROP: { - struct v4l2_crop *crop = arg; - struct v4l2_rect *b = &cam->crop_bounds; - pr_debug(" case VIDIOC_S_CROP\n"); - - if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) { - retval = -EINVAL; - break; - } - - crop->c.top = (crop->c.top < b->top) ? b->top - : crop->c.top; - if (crop->c.top > b->top + b->height) - crop->c.top = b->top + b->height - 1; - if (crop->c.height > b->top + b->height - crop->c.top) - crop->c.height = - b->top + b->height - crop->c.top; - - crop->c.left = (crop->c.left < b->left) ? b->left - : crop->c.left; - if (crop->c.left > b->left + b->width) - crop->c.left = b->left + b->width - 1; - if (crop->c.width > b->left - crop->c.left + b->width) - crop->c.width = - b->left - crop->c.left + b->width; - - crop->c.width -= crop->c.width % 8; - crop->c.left -= crop->c.left % 4; - cam->crop_current = crop->c; - - pr_debug(" Cropping Input to ipu size %d x %d\n", - cam->crop_current.width, - cam->crop_current.height); - ipu_csi_set_window_size(cam->ipu, cam->crop_current.width, - cam->crop_current.height, - cam->csi); - ipu_csi_set_window_pos(cam->ipu, cam->crop_current.left, - cam->crop_current.top, - cam->csi); - break; - } - - /*! - * V4l2 VIDIOC_OVERLAY ioctl - */ - case VIDIOC_OVERLAY: { - int *on = arg; - pr_debug(" VIDIOC_OVERLAY on=%d\n", *on); - if (*on) { - cam->overlay_on = true; - cam->overlay_pid = current->pid; - retval = start_preview(cam); - } - if (!*on) { - retval = stop_preview(cam); - cam->overlay_on = false; - } - break; - } - - /*! - * V4l2 VIDIOC_G_FBUF ioctl - */ - case VIDIOC_G_FBUF: { - struct v4l2_framebuffer *fb = arg; - pr_debug(" case VIDIOC_G_FBUF\n"); - *fb = cam->v4l2_fb; - fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY; - break; - } - - /*! - * V4l2 VIDIOC_S_FBUF ioctl - */ - case VIDIOC_S_FBUF: { - struct v4l2_framebuffer *fb = arg; - pr_debug(" case VIDIOC_S_FBUF\n"); - cam->v4l2_fb = *fb; - break; - } - - case VIDIOC_G_PARM: { - struct v4l2_streamparm *parm = arg; - pr_debug(" case VIDIOC_G_PARM\n"); - if (cam->sensor) - retval = vidioc_int_g_parm(cam->sensor, parm); - else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - retval = -ENODEV; - } - break; - } - - case VIDIOC_S_PARM: { - struct v4l2_streamparm *parm = arg; - pr_debug(" case VIDIOC_S_PARM\n"); - if (cam->sensor) - retval = mxc_v4l2_s_param(cam, parm); - else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - retval = -ENODEV; - } - break; - } - - /* linux v4l2 bug, kernel c0485619 user c0405619 */ - case VIDIOC_ENUMSTD: { - struct v4l2_standard *e = arg; - pr_debug(" case VIDIOC_ENUMSTD\n"); - *e = cam->standard; - break; - } - - case VIDIOC_G_STD: { - v4l2_std_id *e = arg; - pr_debug(" case VIDIOC_G_STD\n"); - if (cam->sensor) - retval = mxc_v4l2_g_std(cam, e); - else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - retval = -ENODEV; - } - break; - } - - case VIDIOC_S_STD: { - v4l2_std_id *e = arg; - pr_debug(" case VIDIOC_S_STD\n"); - retval = mxc_v4l2_s_std(cam, *e); - - break; - } - - case VIDIOC_ENUMOUTPUT: { - struct v4l2_output *output = arg; - pr_debug(" case VIDIOC_ENUMOUTPUT\n"); - if (output->index >= MXC_V4L2_CAPTURE_NUM_OUTPUTS) { - retval = -EINVAL; - break; - } - *output = mxc_capture_outputs[output->index]; - - break; - } - case VIDIOC_G_OUTPUT: { - int *p_output_num = arg; - pr_debug(" case VIDIOC_G_OUTPUT\n"); - *p_output_num = cam->output; - break; - } - - case VIDIOC_S_OUTPUT: { - int *p_output_num = arg; - pr_debug(" case VIDIOC_S_OUTPUT\n"); - if (*p_output_num >= MXC_V4L2_CAPTURE_NUM_OUTPUTS) { - retval = -EINVAL; - break; - } - cam->output = *p_output_num; - break; - } - - case VIDIOC_ENUMINPUT: { - struct v4l2_input *input = arg; - pr_debug(" case VIDIOC_ENUMINPUT\n"); - if (input->index >= MXC_V4L2_CAPTURE_NUM_INPUTS) { - retval = -EINVAL; - break; - } - *input = mxc_capture_inputs[input->index]; - break; - } - - case VIDIOC_G_INPUT: { - int *index = arg; - pr_debug(" case VIDIOC_G_INPUT\n"); - *index = cam->current_input; - break; - } - - case VIDIOC_S_INPUT: { - int *index = arg; - pr_debug(" case VIDIOC_S_INPUT\n"); - if (*index >= MXC_V4L2_CAPTURE_NUM_INPUTS) { - retval = -EINVAL; - break; - } - - if (*index == cam->current_input) - break; - - if ((mxc_capture_inputs[cam->current_input].status & - V4L2_IN_ST_NO_POWER) == 0) { - retval = mxc_streamoff(cam); - if (retval) - break; - mxc_capture_inputs[cam->current_input].status |= - V4L2_IN_ST_NO_POWER; - } - - if (strcmp(mxc_capture_inputs[*index].name, "CSI MEM") == 0) { -#if defined(CONFIG_MXC_IPU_CSI_ENC) || defined(CONFIG_MXC_IPU_CSI_ENC_MODULE) - retval = csi_enc_select(cam); - if (retval) - break; -#endif - } else if (strcmp(mxc_capture_inputs[*index].name, - "CSI IC MEM") == 0) { -#if defined(CONFIG_MXC_IPU_PRP_ENC) || defined(CONFIG_MXC_IPU_PRP_ENC_MODULE) - retval = prp_enc_select(cam); - if (retval) - break; -#endif - } - - mxc_capture_inputs[*index].status &= ~V4L2_IN_ST_NO_POWER; - cam->current_input = *index; - break; - } - case VIDIOC_ENUM_FMT: { - struct v4l2_fmtdesc *f = arg; - if (cam->sensor) - retval = vidioc_int_enum_fmt_cap(cam->sensor, f); - else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - retval = -ENODEV; - } - break; - } - case VIDIOC_ENUM_FRAMESIZES: { - struct v4l2_frmsizeenum *fsize = arg; - if (cam->sensor) - retval = vidioc_int_enum_framesizes(cam->sensor, fsize); - else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - retval = -ENODEV; - } - break; - } - case VIDIOC_ENUM_FRAMEINTERVALS: { - struct v4l2_frmivalenum *fival = arg; - if (cam->sensor) { - retval = vidioc_int_enum_frameintervals(cam->sensor, - fival); - } else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - retval = -ENODEV; - } - break; - } - case VIDIOC_DBG_G_CHIP_IDENT: { - struct v4l2_dbg_chip_ident *p = arg; - p->ident = V4L2_IDENT_NONE; - p->revision = 0; - if (cam->sensor) - retval = vidioc_int_g_chip_ident(cam->sensor, (int *)p); - else { - pr_err("ERROR: v4l2 capture: slave not found!\n"); - retval = -ENODEV; - } - break; - } - case VIDIOC_TRY_FMT: - case VIDIOC_QUERYCTRL: - case VIDIOC_G_TUNER: - case VIDIOC_S_TUNER: - case VIDIOC_G_FREQUENCY: - case VIDIOC_S_FREQUENCY: - default: - pr_debug(" case default or not supported\n"); - retval = -EINVAL; - break; - } - - if (ioctlnr != VIDIOC_DQBUF) - up(&cam->busy_lock); - return retval; -} - -/* - * V4L interface - ioctl function - * - * @return None - */ -static long mxc_v4l_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - pr_debug("In MVC:mxc_v4l_ioctl\n"); - return video_usercopy(file, cmd, arg, mxc_v4l_do_ioctl); -} - -/*! - * V4L interface - mmap function - * - * @param file structure file * - * - * @param vma structure vm_area_struct * - * - * @return status 0 Success, EINTR busy lock error, ENOBUFS remap_page error - */ -static int mxc_mmap(struct file *file, struct vm_area_struct *vma) -{ - struct video_device *dev = video_devdata(file); - unsigned long size; - int res = 0; - cam_data *cam = video_get_drvdata(dev); - - pr_debug("In MVC:mxc_mmap\n"); - pr_debug(" pgoff=0x%lx, start=0x%lx, end=0x%lx\n", - vma->vm_pgoff, vma->vm_start, vma->vm_end); - - /* make this _really_ smp-safe */ - if (down_interruptible(&cam->busy_lock)) - return -EINTR; - - size = vma->vm_end - vma->vm_start; - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); - - if (remap_pfn_range(vma, vma->vm_start, - vma->vm_pgoff, size, vma->vm_page_prot)) { - pr_err("ERROR: v4l2 capture: mxc_mmap: " - "remap_pfn_range failed\n"); - res = -ENOBUFS; - goto mxc_mmap_exit; - } - - vma->vm_flags &= ~VM_IO; /* using shared anonymous pages */ - -mxc_mmap_exit: - up(&cam->busy_lock); - return res; -} - -/*! - * V4L interface - poll function - * - * @param file structure file * - * - * @param wait structure poll_table_struct * - * - * @return status POLLIN | POLLRDNORM - */ -static unsigned int mxc_poll(struct file *file, struct poll_table_struct *wait) -{ - struct video_device *dev = video_devdata(file); - cam_data *cam = video_get_drvdata(dev); - wait_queue_head_t *queue = NULL; - int res = POLLIN | POLLRDNORM; - - pr_debug("In MVC:mxc_poll\n"); - - if (down_interruptible(&cam->busy_lock)) - return -EINTR; - - queue = &cam->enc_queue; - poll_wait(file, queue, wait); - - up(&cam->busy_lock); - - return res; -} - -/*! - * This structure defines the functions to be called in this driver. - */ -static struct v4l2_file_operations mxc_v4l_fops = { - .owner = THIS_MODULE, - .open = mxc_v4l_open, - .release = mxc_v4l_close, - .read = mxc_v4l_read, - .unlocked_ioctl = mxc_v4l_ioctl, - .mmap = mxc_mmap, - .poll = mxc_poll, -}; - -static struct video_device mxc_v4l_template = { - .name = "Mxc Camera", - .fops = &mxc_v4l_fops, - .release = video_device_release, -}; - -/*! - * This function can be used to release any platform data on closing. - */ -static void camera_platform_release(struct device *device) -{ -} - -/*! - * Camera V4l2 callback function. - * - * @param mask u32 - * - * @param dev void device structure - * - * @return status - */ -static void camera_callback(u32 mask, void *dev) -{ - struct mxc_v4l_frame *done_frame; - struct mxc_v4l_frame *ready_frame; - struct timeval cur_time; - - cam_data *cam = (cam_data *) dev; - if (cam == NULL) - return; - - pr_debug("In MVC:camera_callback\n"); - - spin_lock(&cam->queue_int_lock); - spin_lock(&cam->dqueue_int_lock); - if (!list_empty(&cam->working_q)) { - do_gettimeofday(&cur_time); - - done_frame = list_entry(cam->working_q.next, - struct mxc_v4l_frame, - queue); - - if (done_frame->ipu_buf_num != cam->local_buf_num) - goto next; - - /* - * Set the current time to done frame buffer's - * timestamp. Users can use this information to judge - * the frame's usage. - */ - done_frame->buffer.timestamp = cur_time; - - if (done_frame->buffer.flags & V4L2_BUF_FLAG_QUEUED) { - done_frame->buffer.flags |= V4L2_BUF_FLAG_DONE; - done_frame->buffer.flags &= ~V4L2_BUF_FLAG_QUEUED; - - /* Added to the done queue */ - list_del(cam->working_q.next); - list_add_tail(&done_frame->queue, &cam->done_q); - - /* Wake up the queue */ - cam->enc_counter++; - wake_up_interruptible(&cam->enc_queue); - } else - pr_err("ERROR: v4l2 capture: camera_callback: " - "buffer not queued\n"); - } - -next: - if (!list_empty(&cam->ready_q)) { - ready_frame = list_entry(cam->ready_q.next, - struct mxc_v4l_frame, - queue); - if (cam->enc_update_eba) - if (cam->enc_update_eba( - cam, - ready_frame->buffer.m.offset) == 0) { - list_del(cam->ready_q.next); - list_add_tail(&ready_frame->queue, - &cam->working_q); - ready_frame->ipu_buf_num = cam->local_buf_num; - } - } else { - if (cam->enc_update_eba) - cam->enc_update_eba( - cam, cam->dummy_frame.buffer.m.offset); - } - - cam->local_buf_num = (cam->local_buf_num == 0) ? 1 : 0; - spin_unlock(&cam->dqueue_int_lock); - spin_unlock(&cam->queue_int_lock); - - return; -} - -/*! - * initialize cam_data structure - * - * @param cam structure cam_data * - * - * @return status 0 Success - */ -static int init_camera_struct(cam_data *cam, struct platform_device *pdev) -{ - const struct of_device_id *of_id = - of_match_device(mxc_v4l2_dt_ids, &pdev->dev); - struct device_node *np = pdev->dev.of_node; - int ipu_id, csi_id, mclk_source; - int ret = 0; - struct v4l2_device *v4l2_dev; - - pr_debug("In MVC: init_camera_struct\n"); - - ret = of_property_read_u32(np, "ipu_id", &ipu_id); - if (ret) { - dev_err(&pdev->dev, "ipu_id missing or invalid\n"); - return ret; - } - - ret = of_property_read_u32(np, "csi_id", &csi_id); - if (ret) { - dev_err(&pdev->dev, "csi_id missing or invalid\n"); - return ret; - } - - ret = of_property_read_u32(np, "mclk_source", &mclk_source); - if (ret) { - dev_err(&pdev->dev, "sensor mclk missing or invalid\n"); - return ret; - } - - /* Default everything to 0 */ - memset(cam, 0, sizeof(cam_data)); - - /* get devtype to distinguish if the cpu is imx5 or imx6 - * IMX5_V4L2 specify the cpu is imx5 - * IMX6_V4L2 specify the cpu is imx6q or imx6sdl - */ - if (of_id) - pdev->id_entry = of_id->data; - cam->devtype = pdev->id_entry->driver_data; - - cam->ipu = ipu_get_soc(ipu_id); - if (cam->ipu == NULL) { - pr_err("ERROR: v4l2 capture: failed to get ipu\n"); - return -EINVAL; - } else if (cam->ipu == ERR_PTR(-ENODEV)) { - pr_err("ERROR: v4l2 capture: get invalid ipu\n"); - return -ENODEV; - } - - init_MUTEX(&cam->param_lock); - init_MUTEX(&cam->busy_lock); - - cam->video_dev = video_device_alloc(); - if (cam->video_dev == NULL) - return -ENODEV; - - *(cam->video_dev) = mxc_v4l_template; - - video_set_drvdata(cam->video_dev, cam); - dev_set_drvdata(&pdev->dev, (void *)cam); - cam->video_dev->minor = -1; - - v4l2_dev = kzalloc(sizeof(*v4l2_dev), GFP_KERNEL); - if (!v4l2_dev) { - dev_err(&pdev->dev, "failed to allocate v4l2_dev structure\n"); - video_device_release(cam->video_dev); - return -ENOMEM; - } - - if (v4l2_device_register(&pdev->dev, v4l2_dev) < 0) { - dev_err(&pdev->dev, "register v4l2 device failed\n"); - video_device_release(cam->video_dev); - kfree(v4l2_dev); - return -ENODEV; - } - cam->video_dev->v4l2_dev = v4l2_dev; - - init_waitqueue_head(&cam->enc_queue); - init_waitqueue_head(&cam->still_queue); - - /* setup cropping */ - cam->crop_bounds.left = 0; - cam->crop_bounds.width = 640; - cam->crop_bounds.top = 0; - cam->crop_bounds.height = 480; - cam->crop_current = cam->crop_defrect = cam->crop_bounds; - ipu_csi_set_window_size(cam->ipu, cam->crop_current.width, - cam->crop_current.height, cam->csi); - ipu_csi_set_window_pos(cam->ipu, cam->crop_current.left, - cam->crop_current.top, cam->csi); - cam->streamparm.parm.capture.capturemode = 0; - - cam->standard.index = 0; - cam->standard.id = V4L2_STD_UNKNOWN; - cam->standard.frameperiod.denominator = 30; - cam->standard.frameperiod.numerator = 1; - cam->standard.framelines = 480; - cam->standard_autodetect = true; - cam->streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cam->streamparm.parm.capture.timeperframe = cam->standard.frameperiod; - cam->streamparm.parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - cam->overlay_on = false; - cam->capture_on = false; - cam->v4l2_fb.flags = V4L2_FBUF_FLAG_OVERLAY; - - cam->v2f.fmt.pix.sizeimage = 352 * 288 * 3 / 2; - cam->v2f.fmt.pix.bytesperline = 288 * 3 / 2; - cam->v2f.fmt.pix.width = 288; - cam->v2f.fmt.pix.height = 352; - cam->v2f.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; - cam->win.w.width = 160; - cam->win.w.height = 160; - cam->win.w.left = 0; - cam->win.w.top = 0; - - cam->ipu_id = ipu_id; - cam->csi = csi_id; - cam->mclk_source = mclk_source; - cam->mclk_on[cam->mclk_source] = false; - - cam->enc_callback = camera_callback; - init_waitqueue_head(&cam->power_queue); - spin_lock_init(&cam->queue_int_lock); - spin_lock_init(&cam->dqueue_int_lock); - - cam->self = kmalloc(sizeof(struct v4l2_int_device), GFP_KERNEL); - cam->self->module = THIS_MODULE; - sprintf(cam->self->name, "mxc_v4l2_cap%d", cam->csi); - cam->self->type = v4l2_int_type_master; - cam->self->u.master = &mxc_v4l2_master; - - return 0; -} - -static ssize_t show_streaming(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct video_device *video_dev = container_of(dev, - struct video_device, dev); - cam_data *cam = video_get_drvdata(video_dev); - - if (cam->capture_on) - return sprintf(buf, "stream on\n"); - else - return sprintf(buf, "stream off\n"); -} -static DEVICE_ATTR(fsl_v4l2_capture_property, S_IRUGO, show_streaming, NULL); - -static ssize_t show_overlay(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct video_device *video_dev = container_of(dev, - struct video_device, dev); - cam_data *cam = video_get_drvdata(video_dev); - - if (cam->overlay_on) - return sprintf(buf, "overlay on\n"); - else - return sprintf(buf, "overlay off\n"); -} -static DEVICE_ATTR(fsl_v4l2_overlay_property, S_IRUGO, show_overlay, NULL); - -static ssize_t show_csi(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct video_device *video_dev = container_of(dev, - struct video_device, dev); - cam_data *cam = video_get_drvdata(video_dev); - - return sprintf(buf, "ipu%d_csi%d\n", cam->ipu_id, cam->csi); -} -static DEVICE_ATTR(fsl_csi_property, S_IRUGO, show_csi, NULL); - -/*! - * This function is called to probe the devices if registered. - * - * @param pdev the device structure used to give information on which device - * to probe - * - * @return The function returns 0 on success and -1 on failure. - */ -static int mxc_v4l2_probe(struct platform_device *pdev) -{ - /* Create cam and initialize it. */ - cam_data *cam = kmalloc(sizeof(cam_data), GFP_KERNEL); - if (cam == NULL) { - pr_err("ERROR: v4l2 capture: failed to register camera\n"); - return -1; - } - - init_camera_struct(cam, pdev); - pdev->dev.release = camera_platform_release; - - /* Set up the v4l2 device and register it*/ - cam->self->priv = cam; - v4l2_int_device_register(cam->self); - - /* register v4l video device */ - if (video_register_device(cam->video_dev, VFL_TYPE_GRABBER, video_nr) - < 0) { - kfree(cam); - cam = NULL; - pr_err("ERROR: v4l2 capture: video_register_device failed\n"); - return -1; - } - pr_debug(" Video device registered: %s #%d\n", - cam->video_dev->name, cam->video_dev->minor); - - if (device_create_file(&cam->video_dev->dev, - &dev_attr_fsl_v4l2_capture_property)) - dev_err(&pdev->dev, "Error on creating sysfs file" - " for capture\n"); - - if (device_create_file(&cam->video_dev->dev, - &dev_attr_fsl_v4l2_overlay_property)) - dev_err(&pdev->dev, "Error on creating sysfs file" - " for overlay\n"); - - if (device_create_file(&cam->video_dev->dev, - &dev_attr_fsl_csi_property)) - dev_err(&pdev->dev, "Error on creating sysfs file" - " for csi number\n"); - - return 0; -} - -/*! - * This function is called to remove the devices when device unregistered. - * - * @param pdev the device structure used to give information on which device - * to remove - * - * @return The function returns 0 on success and -1 on failure. - */ -static int mxc_v4l2_remove(struct platform_device *pdev) -{ - cam_data *cam = (cam_data *)platform_get_drvdata(pdev); - if (cam->open_count) { - pr_err("ERROR: v4l2 capture:camera open " - "-- setting ops to NULL\n"); - return -EBUSY; - } else { - struct v4l2_device *v4l2_dev = cam->video_dev->v4l2_dev; - device_remove_file(&cam->video_dev->dev, - &dev_attr_fsl_v4l2_capture_property); - device_remove_file(&cam->video_dev->dev, - &dev_attr_fsl_v4l2_overlay_property); - device_remove_file(&cam->video_dev->dev, - &dev_attr_fsl_csi_property); - - pr_info("V4L2 freeing image input device\n"); - v4l2_int_device_unregister(cam->self); - video_unregister_device(cam->video_dev); - - mxc_free_frame_buf(cam); - kfree(cam); - - v4l2_device_unregister(v4l2_dev); - kfree(v4l2_dev); - } - - pr_info("V4L2 unregistering video\n"); - return 0; -} - -/*! - * This function is called to put the sensor in a low power state. - * Refer to the document driver-model/driver.txt in the kernel source tree - * for more information. - * - * @param pdev the device structure used to give information on which I2C - * to suspend - * @param state the power state the device is entering - * - * @return The function returns 0 on success and -1 on failure. - */ -static int mxc_v4l2_suspend(struct platform_device *pdev, pm_message_t state) -{ - cam_data *cam = platform_get_drvdata(pdev); - - pr_debug("In MVC:mxc_v4l2_suspend\n"); - - if (cam == NULL) - return -1; - - down(&cam->busy_lock); - - cam->low_power = true; - - if (cam->overlay_on == true) - stop_preview(cam); - if (cam->capture_on == true) { - if (cam->enc_disable_csi) - cam->enc_disable_csi(cam); - - if (cam->enc_disable) - cam->enc_disable(cam); - } - - if (cam->sensor && cam->open_count) { - if (cam->mclk_on[cam->mclk_source]) { - ipu_csi_enable_mclk_if(cam->ipu, CSI_MCLK_I2C, - cam->mclk_source, - false, false); - cam->mclk_on[cam->mclk_source] = false; - } - vidioc_int_s_power(cam->sensor, 0); - } - - up(&cam->busy_lock); - - return 0; -} - -/*! - * This function is called to bring the sensor back from a low power state. - * Refer to the document driver-model/driver.txt in the kernel source tree - * for more information. - * - * @param pdev the device structure - * - * @return The function returns 0 on success and -1 on failure - */ -static int mxc_v4l2_resume(struct platform_device *pdev) -{ - cam_data *cam = platform_get_drvdata(pdev); - - pr_debug("In MVC:mxc_v4l2_resume\n"); - - if (cam == NULL) - return -1; - - down(&cam->busy_lock); - - cam->low_power = false; - wake_up_interruptible(&cam->power_queue); - - if (cam->sensor && cam->open_count) { - vidioc_int_s_power(cam->sensor, 1); - - if (!cam->mclk_on[cam->mclk_source]) { - ipu_csi_enable_mclk_if(cam->ipu, CSI_MCLK_I2C, - cam->mclk_source, - true, true); - cam->mclk_on[cam->mclk_source] = true; - } - } - - if (cam->overlay_on == true) - start_preview(cam); - if (cam->capture_on == true) { - if (cam->enc_enable) - cam->enc_enable(cam); - - if (cam->enc_enable_csi) - cam->enc_enable_csi(cam); - } - - up(&cam->busy_lock); - - return 0; -} - -/*! - * This structure contains pointers to the power management callback functions. - */ -static struct platform_driver mxc_v4l2_driver = { - .driver = { - .name = "mxc_v4l2_capture", - .owner = THIS_MODULE, - .of_match_table = mxc_v4l2_dt_ids, - }, - .id_table = imx_v4l2_devtype, - .probe = mxc_v4l2_probe, - .remove = mxc_v4l2_remove, - .suspend = mxc_v4l2_suspend, - .resume = mxc_v4l2_resume, - .shutdown = NULL, -}; - -/*! - * Initializes the camera driver. - */ -static int mxc_v4l2_master_attach(struct v4l2_int_device *slave) -{ - cam_data *cam = slave->u.slave->master->priv; - struct v4l2_format cam_fmt; - int i; - struct sensor_data *sdata = slave->priv; - - pr_debug("In MVC: mxc_v4l2_master_attach\n"); - pr_debug(" slave.name = %s\n", slave->name); - pr_debug(" master.name = %s\n", slave->u.slave->master->name); - - if (slave == NULL) { - pr_err("ERROR: v4l2 capture: slave parameter not valid.\n"); - return -1; - } - - if (sdata->csi != cam->csi) { - pr_debug("%s: csi doesn't match\n", __func__); - return -1; - } - - cam->sensor = slave; - - if (cam->sensor_index < MXC_SENSOR_NUM) { - cam->all_sensors[cam->sensor_index] = slave; - cam->sensor_index++; - } else { - pr_err("ERROR: v4l2 capture: slave number exceeds " - "the maximum.\n"); - return -1; - } - - for (i = 0; i < cam->sensor_index; i++) { - vidioc_int_dev_exit(cam->all_sensors[i]); - vidioc_int_s_power(cam->all_sensors[i], 0); - } - - cam_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - vidioc_int_g_fmt_cap(cam->sensor, &cam_fmt); - - /* Used to detect TV in (type 1) vs. camera (type 0)*/ - cam->device_type = cam_fmt.fmt.pix.priv; - - /* Set the input size to the ipu for this device */ - cam->crop_bounds.top = cam->crop_bounds.left = 0; - cam->crop_bounds.width = cam_fmt.fmt.pix.width; - cam->crop_bounds.height = cam_fmt.fmt.pix.height; - - /* This also is the max crop size for this device. */ - cam->crop_defrect.top = cam->crop_defrect.left = 0; - cam->crop_defrect.width = cam_fmt.fmt.pix.width; - cam->crop_defrect.height = cam_fmt.fmt.pix.height; - - /* At this point, this is also the current image size. */ - cam->crop_current.top = cam->crop_current.left = 0; - cam->crop_current.width = cam_fmt.fmt.pix.width; - cam->crop_current.height = cam_fmt.fmt.pix.height; - - pr_debug("End of %s: v2f pix widthxheight %d x %d\n", - __func__, - cam->v2f.fmt.pix.width, cam->v2f.fmt.pix.height); - pr_debug("End of %s: crop_bounds widthxheight %d x %d\n", - __func__, - cam->crop_bounds.width, cam->crop_bounds.height); - pr_debug("End of %s: crop_defrect widthxheight %d x %d\n", - __func__, - cam->crop_defrect.width, cam->crop_defrect.height); - pr_debug("End of %s: crop_current widthxheight %d x %d\n", - __func__, - cam->crop_current.width, cam->crop_current.height); - - return 0; -} - -/*! - * Disconnects the camera driver. - */ -static void mxc_v4l2_master_detach(struct v4l2_int_device *slave) -{ - unsigned int i; - cam_data *cam = slave->u.slave->master->priv; - - pr_debug("In MVC:mxc_v4l2_master_detach\n"); - - if (cam->sensor_index > 1) { - for (i = 0; i < cam->sensor_index; i++) { - if (cam->all_sensors[i] != slave) - continue; - /* Move all the sensors behind this - * sensor one step forward - */ - for (; i <= MXC_SENSOR_NUM - 2; i++) - cam->all_sensors[i] = cam->all_sensors[i+1]; - break; - } - /* Point current sensor to the last one */ - cam->sensor = cam->all_sensors[cam->sensor_index - 2]; - } else - cam->sensor = NULL; - - cam->sensor_index--; - vidioc_int_dev_exit(slave); -} - -/*! - * Entry point for the V4L2 - * - * @return Error code indicating success or failure - */ -static __init int camera_init(void) -{ - u8 err = 0; - - pr_debug("In MVC:camera_init\n"); - - /* Register the device driver structure. */ - err = platform_driver_register(&mxc_v4l2_driver); - if (err != 0) { - pr_err("ERROR: v4l2 capture:camera_init: " - "platform_driver_register failed.\n"); - return err; - } - - return err; -} - -/*! - * Exit and cleanup for the V4L2 - */ -static void __exit camera_exit(void) -{ - pr_debug("In MVC: camera_exit\n"); - - platform_driver_unregister(&mxc_v4l2_driver); -} - -module_init(camera_init); -module_exit(camera_exit); - -module_param(video_nr, int, 0444); -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("V4L2 capture driver for Mxc based cameras"); -MODULE_LICENSE("GPL"); -MODULE_SUPPORTED_DEVICE("video"); diff --git a/drivers/media/platform/mxc/capture/mxc_v4l2_capture.h b/drivers/media/platform/mxc/capture/mxc_v4l2_capture.h deleted file mode 100644 index f6717752d4b9ae1e7a6b406f13d88163d006cc78..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/mxc_v4l2_capture.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright 2004-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/*! - * @defgroup MXC_V4L2_CAPTURE MXC V4L2 Video Capture Driver - */ -/*! - * @file mxc_v4l2_capture.h - * - * @brief mxc V4L2 capture device API Header file - * - * It include all the defines for frame operations, also three structure defines - * use case ops structure, common v4l2 driver structure and frame structure. - * - * @ingroup MXC_V4L2_CAPTURE - */ -#ifndef __MXC_V4L2_CAPTURE_H__ -#define __MXC_V4L2_CAPTURE_H__ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "v4l2-int-device.h" - - -#define FRAME_NUM 10 -#define MXC_SENSOR_NUM 2 - -enum imx_v4l2_devtype { - IMX5_V4L2, - IMX6_V4L2, -}; - -/*! - * v4l2 frame structure. - */ -struct mxc_v4l_frame { - u32 paddress; - void *vaddress; - int count; - int width; - int height; - - struct v4l2_buffer buffer; - struct list_head queue; - int index; - union { - int ipu_buf_num; - int csi_buf_num; - }; -}; - -/* Only for old version. Will go away soon. */ -typedef struct { - u8 clk_mode; - u8 ext_vsync; - u8 Vsync_pol; - u8 Hsync_pol; - u8 pixclk_pol; - u8 data_pol; - u8 data_width; - u8 pack_tight; - u8 force_eof; - u8 data_en_pol; - u16 width; - u16 height; - u32 pixel_fmt; - u32 mclk; - u16 active_width; - u16 active_height; -} sensor_interface; - -/* Sensor control function */ -/* Only for old version. Will go away soon. */ -struct camera_sensor { - void (*set_color) (int bright, int saturation, int red, int green, - int blue); - void (*get_color) (int *bright, int *saturation, int *red, int *green, - int *blue); - void (*set_ae_mode) (int ae_mode); - void (*get_ae_mode) (int *ae_mode); - sensor_interface *(*config) (int *frame_rate, int high_quality); - sensor_interface *(*reset) (void); - void (*get_std) (v4l2_std_id *std); - void (*set_std) (v4l2_std_id std); - unsigned int csi; -}; - -/*! - * common v4l2 driver structure. - */ -typedef struct _cam_data { - struct video_device *video_dev; - int device_type; - - /* semaphore guard against SMP multithreading */ - struct semaphore busy_lock; - - int open_count; - - /* params lock for this camera */ - struct semaphore param_lock; - - /* Encoder */ - struct list_head ready_q; - struct list_head done_q; - struct list_head working_q; - int ping_pong_csi; - spinlock_t queue_int_lock; - spinlock_t dqueue_int_lock; - struct mxc_v4l_frame frame[FRAME_NUM]; - struct mxc_v4l_frame dummy_frame; - wait_queue_head_t enc_queue; - int enc_counter; - dma_addr_t rot_enc_bufs[2]; - void *rot_enc_bufs_vaddr[2]; - int rot_enc_buf_size[2]; - enum v4l2_buf_type type; - - /* still image capture */ - wait_queue_head_t still_queue; - int still_counter; - dma_addr_t still_buf[2]; - void *still_buf_vaddr; - - /* overlay */ - struct v4l2_window win; - struct v4l2_framebuffer v4l2_fb; - dma_addr_t vf_bufs[2]; - void *vf_bufs_vaddr[2]; - int vf_bufs_size[2]; - dma_addr_t rot_vf_bufs[2]; - void *rot_vf_bufs_vaddr[2]; - int rot_vf_buf_size[2]; - bool overlay_active; - int output; - struct fb_info *overlay_fb; - int fb_origin_std; - struct work_struct csi_work_struct; - - /* v4l2 format */ - struct v4l2_format v2f; - struct v4l2_format input_fmt; /* camera in */ - bool bswapenable; - int rotation; /* for IPUv1 and IPUv3, this means encoder rotation */ - int vf_rotation; /* viewfinder rotation only for IPUv1 and IPUv3 */ - struct v4l2_mxc_offset offset; - - /* V4l2 control bit */ - int bright; - int hue; - int contrast; - int saturation; - int red; - int green; - int blue; - int ae_mode; - - /* standard */ - struct v4l2_streamparm streamparm; - struct v4l2_standard standard; - bool standard_autodetect; - - /* crop */ - struct v4l2_rect crop_bounds; - struct v4l2_rect crop_defrect; - struct v4l2_rect crop_current; - - int (*enc_update_eba) (void *private, dma_addr_t eba); - int (*enc_enable) (void *private); - int (*enc_disable) (void *private); - int (*enc_enable_csi) (void *private); - int (*enc_disable_csi) (void *private); - void (*enc_callback) (u32 mask, void *dev); - int (*vf_start_adc) (void *private); - int (*vf_stop_adc) (void *private); - int (*vf_start_sdc) (void *private); - int (*vf_stop_sdc) (void *private); - int (*vf_enable_csi) (void *private); - int (*vf_disable_csi) (void *private); - int (*csi_start) (void *private); - int (*csi_stop) (void *private); - - /* misc status flag */ - bool overlay_on; - bool capture_on; - int overlay_pid; - int capture_pid; - bool low_power; - wait_queue_head_t power_queue; - unsigned int ipu_id; - unsigned int csi; - u8 mclk_source; - bool mclk_on[2]; /* two mclk sources at most now */ - int current_input; - - int local_buf_num; - - /* camera sensor interface */ - struct camera_sensor *cam_sensor; /* old version */ - struct v4l2_int_device *all_sensors[MXC_SENSOR_NUM]; - struct v4l2_int_device *sensor; - struct v4l2_int_device *self; - int sensor_index; - void *ipu; - void *csi_soc; - enum imx_v4l2_devtype devtype; - - /* v4l2 buf elements related to PxP DMA */ - struct completion pxp_tx_cmpl; - struct pxp_channel *pxp_chan; - struct pxp_config_data pxp_conf; - struct dma_async_tx_descriptor *txd; - dma_cookie_t cookie; - struct scatterlist sg[2]; -} cam_data; - -struct sensor_data { - const struct ov5642_platform_data *platform_data; - struct v4l2_int_device *v4l2_int_device; - struct i2c_client *i2c_client; - struct v4l2_pix_format pix; - struct v4l2_captureparm streamcap; - bool on; - - /* control settings */ - int brightness; - int hue; - int contrast; - int saturation; - int red; - int green; - int blue; - int ae_mode; - - u32 mclk; - u8 mclk_source; - struct clk *sensor_clk; - int csi; - - void (*io_init)(void); -}; - -void set_mclk_rate(uint32_t *p_mclk_freq, uint32_t csi); -#endif /* __MXC_V4L2_CAPTURE_H__ */ diff --git a/drivers/media/platform/mxc/capture/mxc_vadc.c b/drivers/media/platform/mxc/capture/mxc_vadc.c deleted file mode 100644 index 2a844ca8ab5d0cbff8c8e016735fe77438c814d5..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/mxc_vadc.c +++ /dev/null @@ -1,830 +0,0 @@ -/* - * Copyright (C) 2014-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * 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. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mxc_vadc.h" - -/* Resource names for the VADC driver. */ -#define VAFE_REGS_ADDR_RES_NAME "vadc-vafe" -#define VDEC_REGS_ADDR_RES_NAME "vadc-vdec" - -#define reg32_write(addr, val) __raw_writel(val, addr) -#define reg32_read(addr) __raw_readl(addr) -#define reg32setbit(addr, bitpos) \ - reg32_write((addr), (reg32_read((addr)) | (1<<(bitpos)))) - -#define reg32clrbit(addr, bitpos) \ - reg32_write((addr), (reg32_read((addr)) & (0xFFFFFFFF ^ (1<<(bitpos))))) - -#define GPC_CNTR 0x00 -#define IMX6SX_GPC_CNTR_VADC_ANALOG_OFF_MASK BIT(17) -#define IMX6SX_GPC_CNTR_VADC_POWER_DOWN_MASK BIT(18) - -void __iomem *vafe_regbase; -void __iomem *vdec_regbase; - - -/* List of input video formats supported. The video formats is corresponding - * with v4l2 id in video_fmt - */ -enum video_fmt_idx { - VADC_NTSC = 0, /* Locked on (M) NTSC video signal. */ - VADC_PAL, /* (B, G, H, I, N)PAL video signal. */ -}; - -/* Number of video standards supported (including 'not locked' signal). */ -#define VADC_STD_MAX (VADC_PAL + 1) - -/* Video format structure. */ -struct video_fmt{ - v4l2_std_id v4l2_std; /* Video for linux ID. */ - char name[16]; /* Name (e.g., "NTSC", "PAL", etc.) */ - u16 raw_width; /* Raw width. */ - u16 raw_height; /* Raw height. */ - u16 active_width; /* Active width. */ - u16 active_height; /* Active height. */ - u16 framerates; -}; - -/* - * Maintains the information on the current state of the sensor. - */ -struct vadc_state { - struct v4l2_device v4l2_dev; - struct v4l2_subdev sd; - struct video_fmt *fmt; - - struct clk *vadc_clk; - struct clk *csi_clk; - struct regmap *gpr; - void __iomem *gpc_reg; - - u32 vadc_in; - u32 csi_id; -}; - -static int vadc_querystd(struct v4l2_subdev *sd, v4l2_std_id *std); - -/* Description of video formats supported. - * - * PAL: raw=720x625, active=720x576. - * NTSC: raw=720x525, active=720x480. - */ -static struct video_fmt video_fmts[] = { - /* NTSC */ - { - .v4l2_std = V4L2_STD_NTSC, - .name = "NTSC", - .raw_width = 720, - .raw_height = 525, - .active_width = 720, - .active_height = 480, - .framerates = 30, - }, - /* (B, G, H, I, N) PAL */ - { - .v4l2_std = V4L2_STD_PAL, - .name = "PAL", - .raw_width = 720, - .raw_height = 625, - .active_width = 720, - .active_height = 576, - .framerates = 25, - }, -}; - -static void afe_voltage_clampingmode(void) -{ - reg32_write(AFE_CLAMP, 0x07); - reg32_write(AFE_CLMPAMP, 0x60); - reg32_write(AFE_CLMPDAT, 0xF0); -} - -static void afe_alwayson_clampingmode(void) -{ - reg32_write(AFE_CLAMP, 0x15); - reg32_write(AFE_CLMPDAT, 0x08); - reg32_write(AFE_CLMPAMP, 0x00); -} - -static void afe_init(void) -{ - pr_debug("%s\n", __func__); - - reg32_write(AFE_PDBUF, 0x1f); - reg32_write(AFE_PDADC, 0x0f); - reg32_write(AFE_PDSARH, 0x01); - reg32_write(AFE_PDSARL, 0xff); - reg32_write(AFE_PDADCRFH, 0x01); - reg32_write(AFE_PDADCRFL, 0xff); - reg32_write(AFE_ICTRL, 0x3a); - reg32_write(AFE_ICTLSTG, 0x1e); - - reg32_write(AFE_RCTRLSTG, 0x1e); - reg32_write(AFE_INPBUF, 0x035); - reg32_write(AFE_INPFLT, 0x02); - reg32_write(AFE_ADCDGN, 0x40); - reg32_write(AFE_TSTSEL, 0x10); - - reg32_write(AFE_ACCTST, 0x07); - - reg32_write(AFE_BGREG, 0x08); - - reg32_write(AFE_ADCGN, 0x09); - - /* set current controlled clamping - * always on, low current */ - reg32_write(AFE_CLAMP, 0x11); - reg32_write(AFE_CLMPAMP, 0x08); -} - -static void vdec_mode_timing_init(int std) -{ - if (std == V4L2_STD_NTSC) { - /* NTSC 720x480 */ - reg32_write(VDEC_HACTS, 0x66); - reg32_write(VDEC_HACTE, 0x24); - - reg32_write(VDEC_VACTS, 0x29); - reg32_write(VDEC_VACTE, 0x04); - - /* set V Position */ - reg32_write(VDEC_VRTPOS, 0x2); - } else if (std == V4L2_STD_PAL) { - /* PAL 720x576 */ - reg32_write(VDEC_HACTS, 0x66); - reg32_write(VDEC_HACTE, 0x24); - - reg32_write(VDEC_VACTS, 0x29); - reg32_write(VDEC_VACTE, 0x04); - - /* set V Position */ - reg32_write(VDEC_VRTPOS, 0x6); - } else - pr_debug("Error not support video mode\n"); - - /* set H Position */ - reg32_write(VDEC_HZPOS, 0x60); - - /* set H ignore start */ - reg32_write(VDEC_HSIGS, 0xf8); - - /* set H ignore end */ - reg32_write(VDEC_HSIGE, 0x18); -} - -/* -* vdec_init() -* Initialises the VDEC registers -* Returns: nothing -*/ -static void vdec_init(struct vadc_state *vadc) -{ - v4l2_std_id std; - - pr_debug("%s\n", __func__); - - /* Get work mode PAL or NTSC */ - vadc_querystd(&vadc->sd, &std); - - vdec_mode_timing_init(std); - - /* vcr detect threshold high, automatic detections */ - reg32_write(VDEC_VSCON2, 0); - - reg32_write(VDEC_BASE + 0x110, 0x01); - - /* set the noramp mode on the Hloop PLL. */ - reg32_write(VDEC_BASE+(0x14*4), 0x10); - - /* set the YC relative delay.*/ - reg32_write(VDEC_YCDEL, 0x90); - - /* setup the Hpll */ - reg32_write(VDEC_BASE+(0x13*4), 0x13); - - /* setup the 2d comb */ - /* set the gain of the Hdetail output to 3 - * set the notch alpha gain to 1 */ - reg32_write(VDEC_CFC2, 0x34); - - /* setup various 2d comb bits.*/ - reg32_write(VDEC_BASE+(0x02*4), 0x01); - reg32_write(VDEC_BASE+(0x03*4), 0x18); - reg32_write(VDEC_BASE+(0x04*4), 0x34); - - /* set the start of the burst gate */ - reg32_write(VDEC_BRSTGT, 0x30); - - /* set 1f motion gain */ - reg32_write(VDEC_BASE+(0x0f*4), 0x20); - - /* set the 1F chroma motion detector thresh - * for colour reverse detection */ - reg32_write(VDEC_THSH1, 0x02); - reg32_write(VDEC_BASE+(0x4a*4), 0x20); - reg32_write(VDEC_BASE+(0x4b*4), 0x08); - - reg32_write(VDEC_BASE+(0x4c*4), 0x08); - - /* set the threshold for the narrow/wide adaptive chroma BW */ - reg32_write(VDEC_BASE+(0x20*4), 0x20); - - /* turn up the colour with the new colour gain reg */ - /* hue: */ - reg32_write(VDEC_HUE, 0x00); - - /* cbgain: 22 B4 */ - reg32_write(VDEC_CBGN, 0xb4); - /* cr gain 80 */ - reg32_write(VDEC_CRGN, 0x80); - /* luma gain (contrast) */ - reg32_write(VDEC_CNTR, 0x80); - - /* setup the signed black level register, brightness */ - reg32_write(VDEC_BRT, 0x00); - - /* filter the standard detection - * enable the comb for the ntsc443 */ - reg32_write(VDEC_STDDBG, 0x20); - - /* setup chroma kill thresh for no chroma */ - reg32_write(VDEC_CHBTH, 0x0); - - /* set chroma loop to wider BW - * no set it to normal BW. i fixed the bw problem.*/ - reg32_write(VDEC_YCDEL, 0x00); - - /* set the compensation in the chroma loop for the Hloop - * set the ratio for the nonarithmetic 3d comb modes.*/ - reg32_write(VDEC_BASE + (0x1d*4), 0x90); - - /* set the threshold for the nonarithmetic mode for the 2d comb - * the higher the value the more Fc Fh offset - * we will tolerate before turning off the comb. */ - reg32_write(VDEC_BASE + (0x33*4), 0xa0); - - /* setup the bluescreen output colour */ - reg32_write(VDEC_BASE + (0x3d*4), 35); - reg32_write(VDEC_BLSCRCR, 114); - reg32_write(VDEC_BLSCRCB, 212); - - /* disable the active blanking */ - reg32_write(VDEC_BASE + (0x15*4), 0x02); - - /* setup the luma agc for automatic gain. */ - reg32_write(VDEC_LMAGC2, 0x5e); - reg32_write(VDEC_LMAGC1, 0x81); - - /* setup chroma agc */ - reg32_write(VDEC_CHAGC2, 0xa0); - reg32_write(VDEC_CHAGC1, 0x01); - - /* setup the MV thresh lower nibble - * setup the sync top cap, upper nibble */ - reg32_write(VDEC_BASE + (0x3a*4), 0x80); - reg32_write(VDEC_SHPIMP, 0x00); - - /* setup the vsync block */ - reg32_write(VDEC_VSCON1, 0x87); - - /* set the nosignal threshold - * set the vsync threshold */ - reg32_write(VDEC_VSSGTH, 0x35); - - /* set length for min hphase filter - * (or saturate limit if saturate is chosen) */ - reg32_write(VDEC_BASE + (0x45*4), 0x40); - - /* enable the internal resampler, - * select min filter not saturate for - * hphase noise filter for vcr detect. - * enable vcr pause mode different field lengths */ - reg32_write(VDEC_BASE + (0x46*4), 0x90); - - /* disable VCR detection, lock to the Hsync rather than the Vsync */ - reg32_write(VDEC_VSCON2, 0x04); - - /* set tiplevel goal for dc clamp. */ - reg32_write(VDEC_BASE + (0x3c*4), 0xB0); - - /* override SECAM detection and force SECAM off */ - reg32_write(VDEC_BASE + (0x2f*4), 0x20); - - /* Set r3d_hardblend in 3D control2 reg */ - reg32_write(VDEC_BASE + (0x0c*4), 0x04); -} - -/* set Input selector & input pull-downs */ -static void vadc_s_routing(int vadc_in) -{ - switch (vadc_in) { - case 0: - reg32_write(AFE_INPFLT, 0x02); - reg32_write(AFE_OFFDRV, 0x00); - reg32_write(AFE_INPCONFIG, 0x1e); - break; - case 1: - reg32_write(AFE_INPFLT, 0x02); - reg32_write(AFE_OFFDRV, 0x00); - reg32_write(AFE_INPCONFIG, 0x2d); - break; - case 2: - reg32_write(AFE_INPFLT, 0x02); - reg32_write(AFE_OFFDRV, 0x00); - reg32_write(AFE_INPCONFIG, 0x4b); - break; - case 3: - reg32_write(AFE_INPFLT, 0x02); - reg32_write(AFE_OFFDRV, 0x00); - reg32_write(AFE_INPCONFIG, 0x87); - break; - default: - pr_debug("error video input %d\n", vadc_in); - } -} - -static void vadc_power_up(struct vadc_state *state) -{ - /* Power on vadc analog */ - reg32clrbit(state->gpc_reg + GPC_CNTR, 17); - - /* Power down vadc ext power */ - reg32clrbit(state->gpc_reg + GPC_CNTR, 18); - - /* software reset afe */ - regmap_update_bits(state->gpr, IOMUXC_GPR1, - IMX6SX_GPR1_VADC_SW_RST_MASK, - IMX6SX_GPR1_VADC_SW_RST_RESET); - - msleep(10); - - /* clock config for vadc */ - reg32_write(VDEC_BASE + 0x320, 0xe3); - reg32_write(VDEC_BASE + 0x324, 0x38); - reg32_write(VDEC_BASE + 0x328, 0x8e); - reg32_write(VDEC_BASE + 0x32c, 0x23); - - /* Release reset bit */ - regmap_update_bits(state->gpr, IOMUXC_GPR1, - IMX6SX_GPR1_VADC_SW_RST_MASK, - IMX6SX_GPR1_VADC_SW_RST_RELEASE); - - /* Power on vadc ext power */ - reg32setbit(state->gpc_reg + GPC_CNTR, 18); -} - -static void vadc_power_down(struct vadc_state *state) -{ - /* Power down vadc analog */ - reg32setbit(state->gpc_reg + GPC_CNTR, 17); - - /* Power down vadc ext power */ - reg32clrbit(state->gpc_reg + GPC_CNTR, 18); - -} -static void vadc_init(struct vadc_state *vadc) -{ - pr_debug("%s\n", __func__); - - vadc_power_up(vadc); - - afe_init(); - - /* select Video Input 0-3 */ - vadc_s_routing(vadc->vadc_in); - - afe_voltage_clampingmode(); - - vdec_init(vadc); - - /* - * current control loop will move sinewave input off below - * the bottom of the signal range visible - * when the testbus is viewed as magnitude, - * so have to break before this point while capturing ENOB data: - */ - afe_alwayson_clampingmode(); -} - -static inline struct vadc_state *to_state(struct v4l2_subdev *sd) -{ - return container_of(sd, struct vadc_state, sd); -} - -static int vadc_g_std(struct v4l2_subdev *sd, v4l2_std_id *std) -{ - struct vadc_state *state = to_state(sd); - - *std = state->fmt->v4l2_std; - return 0; -} - -/*! - * Return attributes of current video standard. - * Since this device autodetects the current standard, this function also - * sets the values that need to be changed if the standard changes. - * There is no set std equivalent function. - * - * @return None. - */ -static int vadc_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) -{ - struct vadc_state *state = to_state(sd); - int mod; - int idx; - int i; - - /* Read auto mode detected result */ - printk(KERN_INFO"wait vadc auto detect video mode....\n"); - for (i = 0; i < 10; i++) { - msleep(200); - mod = reg32_read(VDEC_VIDMOD); - /* Check video signal states */ - if ((mod & VDEC_VIDMOD_SIGNAL_MASK) - == VDEC_VIDMOD_SIGNAL_DETECT) - break; - } - if (i == 10) - printk(KERN_INFO"Timeout detect video signal mod=0x%x\n", mod); - - if ((mod & VDEC_VIDMOD_PAL_MASK) || (mod & VDEC_VIDMOD_M625_MASK)) - idx = VADC_PAL; - else - idx = VADC_NTSC; - - *std = video_fmts[idx].v4l2_std; - state->fmt = &video_fmts[idx]; - - printk(KERN_INFO"video mode %s\n", video_fmts[idx].name); - return 0; -} - -static int vadc_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) -{ - /* support only one format */ - if (code->pad || code->index >= 1) - return -EINVAL; - - code->code = MEDIA_BUS_FMT_AYUV8_1X32; - return 0; -} - -static int vadc_get_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *format) -{ - struct vadc_state *state = to_state(sd); - struct v4l2_mbus_framefmt *fmt = &format->format; - - if (format->pad) - return -EINVAL; - - fmt->code = MEDIA_BUS_FMT_AYUV8_1X32; - fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; - fmt->field = V4L2_FIELD_INTERLACED; - fmt->width = 720; - fmt->height = state->fmt->v4l2_std & V4L2_STD_NTSC ? 480 : 576; - - return 0; -} - -static int vadc_set_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *format) -{ - return vadc_get_fmt(sd, cfg, format); -} - -static int vadc_enum_framesizes(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) -{ - struct vadc_state *state = to_state(sd); - if (fse->index >= 1) - return -EINVAL; - - fse->min_width = state->fmt->active_width; - fse->max_width = state->fmt->active_width; - fse->min_height = state->fmt->active_height; - fse->max_height = state->fmt->active_height; - - return 0; -} -static int vadc_enum_frameintervals(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_interval_enum *fie) -{ - struct vadc_state *state = to_state(sd); - - if (fie->index < 0 || fie->index >= 1) - return -EINVAL; - - fie->interval.numerator = 1; - - fie->interval.denominator = state->fmt->framerates; - - return 0; -} - -static int vadc_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) -{ - struct vadc_state *state = to_state(sd); - - if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - - if (parms->parm.capture.timeperframe.denominator - != state->fmt->framerates) - parms->parm.capture.timeperframe.denominator - = state->fmt->framerates; - - return 0; -} - -static const struct v4l2_subdev_video_ops vadc_video_ops = { - .querystd = vadc_querystd, - .s_parm = vadc_s_parm, - .g_std = vadc_g_std, -}; - - -static const struct v4l2_subdev_pad_ops vadc_pad_ops = { - .get_fmt = vadc_get_fmt, - .set_fmt = vadc_set_fmt, - .enum_mbus_code = vadc_enum_mbus_code, - .enum_frame_size = vadc_enum_framesizes, - .enum_frame_interval = vadc_enum_frameintervals, -}; - -static const struct v4l2_subdev_ops vadc_ops = { - .video = &vadc_video_ops, - .pad = &vadc_pad_ops, -}; - -static const struct of_device_id fsl_vadc_dt_ids[] = { - { .compatible = "fsl,imx6sx-vadc", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, fsl_vadc_dt_ids); - -static int vadc_of_init(struct platform_device *pdev) -{ - struct device_node *np = pdev->dev.of_node; - struct device_node *gpc_np; - struct vadc_state *state = platform_get_drvdata(pdev); - int csi_id; - int ret; - - /* Get csi_id to setting vadc to csi mux in gpr */ - ret = of_property_read_u32(np, "csi_id", &csi_id); - if (ret) { - dev_err(&pdev->dev, "failed to read of property csi_id\n"); - return ret; - } - - state->csi_id = csi_id; - - /* remap GPR register */ - state->gpr = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, - "gpr"); - if (IS_ERR(state->gpr)) { - dev_dbg(&pdev->dev, "can not get gpr\n"); - return -ENOMEM; - } - - /* Configuration vadc-to-csi 0 or 1 */ - if (csi_id) { - regmap_update_bits(state->gpr, IOMUXC_GPR5, - IMX6SX_GPR5_CSI2_MUX_CTRL_MASK, - IMX6SX_GPR5_CSI2_MUX_CTRL_CVD); - } else { - regmap_update_bits(state->gpr, IOMUXC_GPR5, - IMX6SX_GPR5_CSI1_MUX_CTRL_MASK, - IMX6SX_GPR5_CSI1_MUX_CTRL_CVD); - } - - /* Get default vadc_in number */ - ret = of_property_read_u32(np, "vadc_in", &state->vadc_in); - if (ret) { - dev_err(&pdev->dev, "failed to read of property vadc_in\n"); - return ret; - } - - /* map GPC register */ - gpc_np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpc"); - state->gpc_reg = of_iomap(gpc_np, 0); - if (!state->gpc_reg) { - dev_err(&pdev->dev, "ioremap failed with gpc base\n"); - goto error; - } - - return ret; - -error: - iounmap(state->gpc_reg); - return ret; -} - -static void vadc_v4l2_subdev_init(struct v4l2_subdev *sd, - struct platform_device *pdev, - const struct v4l2_subdev_ops *ops) -{ - struct vadc_state *state = platform_get_drvdata(pdev); - int ret = 0; - - v4l2_subdev_init(sd, ops); - sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - sd->owner = pdev->dev.driver->owner; - sd->dev = &pdev->dev; - - /* initialize name */ - snprintf(sd->name, sizeof(sd->name), "%s", - pdev->dev.driver->name); - - v4l2_set_subdevdata(sd, state); - - ret = v4l2_async_register_subdev(sd); - if (ret < 0) - dev_err(&pdev->dev, "%s--Async register faialed, ret=%d\n", __func__, ret); -} - -static int vadc_probe(struct platform_device *pdev) -{ - struct vadc_state *state; - struct v4l2_subdev *sd; - struct resource *res; - int ret = 0; - - state = devm_kzalloc(&pdev->dev, sizeof(struct vadc_state), GFP_KERNEL); - if (!state) { - dev_err(&pdev->dev, "Cannot allocate device data\n"); - return -ENOMEM; - } - - /* Set initial values for the sensor struct. */ - state->fmt = &video_fmts[VADC_NTSC]; - - sd = &state->sd; - - /* map vafe address */ - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, VAFE_REGS_ADDR_RES_NAME); - if (!res) { - dev_err(&pdev->dev, "No vafe base address found.\n"); - return -ENOMEM; - } - vafe_regbase = devm_ioremap_resource(&pdev->dev, res); - if (!vafe_regbase) { - dev_err(&pdev->dev, "ioremap failed with vafe base\n"); - return -ENOMEM; - } - - /* map vdec address */ - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, VDEC_REGS_ADDR_RES_NAME); - if (!res) { - dev_err(&pdev->dev, "No vdec base address found.\n"); - return -ENODEV; - } - vdec_regbase = devm_ioremap_resource(&pdev->dev, res); - if (!vdec_regbase) { - dev_err(&pdev->dev, "ioremap failed with vdec base\n"); - return -ENOMEM; - } - - /* Get clock */ - state->vadc_clk = devm_clk_get(&pdev->dev, "vadc"); - if (IS_ERR(state->vadc_clk)) { - ret = PTR_ERR(state->vadc_clk); - return ret; - } - - state->csi_clk = devm_clk_get(&pdev->dev, "csi"); - if (IS_ERR(state->csi_clk)) { - ret = PTR_ERR(state->csi_clk); - return ret; - } - - /* clock */ - clk_prepare_enable(state->csi_clk); - clk_prepare_enable(state->vadc_clk); - - platform_set_drvdata(pdev, state); - - vadc_v4l2_subdev_init(sd, pdev, &vadc_ops); - - pm_runtime_enable(&pdev->dev); - - pm_runtime_get_sync(&pdev->dev); - /* Init VADC */ - ret = vadc_of_init(pdev); - if (ret < 0) - goto err; - vadc_init(state); - - pr_info("vadc driver loaded\n"); - - return 0; -err: - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); - v4l2_async_unregister_subdev(&state->sd); - clk_disable_unprepare(state->csi_clk); - clk_disable_unprepare(state->vadc_clk); - return ret; -} - -static int vadc_remove(struct platform_device *pdev) -{ - struct vadc_state *state = platform_get_drvdata(pdev); - - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); - v4l2_async_unregister_subdev(&state->sd); - clk_disable_unprepare(state->csi_clk); - clk_disable_unprepare(state->vadc_clk); - - vadc_power_down(state); - return true; -} - -static int vadc_suspend(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct vadc_state *state = platform_get_drvdata(pdev); - - clk_disable(state->csi_clk); - clk_disable(state->vadc_clk); - - vadc_power_down(state); - - return 0; -} - -static int vadc_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct vadc_state *state = platform_get_drvdata(pdev); - - clk_enable(state->csi_clk); - clk_enable(state->vadc_clk); - - vadc_init(state); - return 0; -} - -static const struct dev_pm_ops vadc_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(vadc_suspend, vadc_resume) -}; - -static struct platform_driver vadc_driver = { - .driver = { - .name = "fsl_vadc", - .of_match_table = of_match_ptr(fsl_vadc_dt_ids), - .pm = &vadc_pm_ops, - }, - .probe = vadc_probe, - .remove = vadc_remove, -}; - -module_platform_driver(vadc_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("fsl VADC/VDEC driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/mxc/capture/mxc_vadc.h b/drivers/media/platform/mxc/capture/mxc_vadc.h deleted file mode 100644 index d5c1389cbc589c48d6872c874da0efc4f3ba60e4..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/mxc_vadc.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (C) 2011-2015 Freescale Semiconductor, Inc. - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef MXC_VDEC_H -#define MXC_VDEC_H - -/*** define base address ***/ -#define VDEC_BASE vdec_regbase -#define AFE_BASE vafe_regbase - -/* AFE - Register offsets */ -#define AFE_BLOCK_ID_OFFSET 0x00000000 -#define AFE_PDBUF_OFFSET 0x00000004 -#define AFE_SWRST_OFFSET 0x00000008 -#define AFE_TSTSEL_OFFSET 0x0000000c -#define AFE_TSTMSC_OFFSET 0x00000010 -#define AFE_ENPADIO_OFFSET 0x00000014 -#define AFE_BGREG_OFFSET 0x00000018 -#define AFE_ACCESSAR_ID_OFFSET 0x00000400 -#define AFE_PDADC_OFFSET 0x00000404 -#define AFE_PDSARH_OFFSET 0x00000408 -#define AFE_PDSARL_OFFSET 0x0000040C -#define AFE_PDADCRFH_OFFSET 0x00000410 -#define AFE_PDADCRFL_OFFSET 0x00000414 -#define AFE_ACCTST_OFFSET 0x00000418 -#define AFE_ADCGN_OFFSET 0x0000041C -#define AFE_ICTRL_OFFSET 0x00000420 -#define AFE_ICTLSTG_OFFSET 0x00000424 -#define AFE_RCTRLSTG_OFFSET 0x00000428 -#define AFE_TCTRLSTG_OFFSET 0x0000042c -#define AFE_REFMOD_OFFSET 0x00000430 -#define AFE_REFTRIML_OFFSET 0x00000434 -#define AFE_REFTRIMH_OFFSET 0x00000438 -#define AFE_ADCR_OFFSET 0x0000043c -#define AFE_DUMMY0_OFFSET 0x00000440 -#define AFE_DUMMY1_OFFSET 0x00000444 -#define AFE_DUMMY2_OFFSET 0x00000448 -#define AFE_DACAMP_OFFSET 0x0000044c -#define AFE_CLMPTST_OFFSET 0x00000450 -#define AFE_CLMPDAT_OFFSET 0x00000454 -#define AFE_CLMPAMP_OFFSET 0x00000458 -#define AFE_CLAMP_OFFSET 0x0000045c -#define AFE_INPBUF_OFFSET 0x00000460 -#define AFE_INPFLT_OFFSET 0x00000464 -#define AFE_ADCDGN_OFFSET 0x00000468 -#define AFE_OFFDRV_OFFSET 0x0000046c -#define AFE_INPCONFIG_OFFSET 0x00000470 -#define AFE_PROGDELAY_OFFSET 0x00000474 -#define AFE_ADCOMT_OFFSET 0x00000478 -#define AFE_ALGDELAY_OFFSET 0x0000047c -#define AFE_ACC_ID_OFFSET 0x00000800 -#define AFE_ACCSTA_OFFSET 0x00000804 -#define AFE_ACCNOSLI_OFFSET 0x00000808 -#define AFE_ACCCALCON_OFFSET 0x0000080c -#define AFE_BWEWRICTRL_OFFSET 0x00000810 -#define AFE_SELSLI_OFFSET 0x00000814 -#define AFE_SELBYT_OFFSET 0x00000818 -#define AFE_REDVAL_OFFSET 0x00000820 -#define AFE_WRIBYT_OFFSET 0x00000824 - -/* AFE Register per module */ -#define AFE_BLOCK_ID (AFE_BASE + AFE_BLOCK_ID_OFFSET) -#define AFE_PDBUF (AFE_BASE + AFE_PDBUF_OFFSET) -#define AFE_SWRST (AFE_BASE + AFE_SWRST_OFFSET) -#define AFE_TSTSEL (AFE_BASE + AFE_TSTSEL_OFFSET) -#define AFE_TSTMSC (AFE_BASE + AFE_TSTMSC_OFFSET) -#define AFE_ENPADIO (AFE_BASE + AFE_ENPADIO_OFFSET) -#define AFE_BGREG (AFE_BASE + AFE_BGREG_OFFSET) -#define AFE_ACCESSAR_ID (AFE_BASE + AFE_ACCESSAR_ID_OFFSET) -#define AFE_PDADC (AFE_BASE + AFE_PDADC_OFFSET) -#define AFE_PDSARH (AFE_BASE + AFE_PDSARH_OFFSET) -#define AFE_PDSARL (AFE_BASE + AFE_PDSARL_OFFSET) -#define AFE_PDADCRFH (AFE_BASE + AFE_PDADCRFH_OFFSET) -#define AFE_PDADCRFL (AFE_BASE + AFE_PDADCRFL_OFFSET) -#define AFE_ACCTST (AFE_BASE + AFE_ACCTST_OFFSET) -#define AFE_ADCGN (AFE_BASE + AFE_ADCGN_OFFSET) -#define AFE_ICTRL (AFE_BASE + AFE_ICTRL_OFFSET) -#define AFE_ICTLSTG (AFE_BASE + AFE_ICTLSTG_OFFSET) -#define AFE_RCTRLSTG (AFE_BASE + AFE_RCTRLSTG_OFFSET) -#define AFE_TCTRLSTG (AFE_BASE + AFE_TCTRLSTG_OFFSET) -#define AFE_REFMOD (AFE_BASE + AFE_REFMOD_OFFSET) -#define AFE_REFTRIML (AFE_BASE + AFE_REFTRIML_OFFSET) -#define AFE_REFTRIMH (AFE_BASE + AFE_REFTRIMH_OFFSET) -#define AFE_ADCR (AFE_BASE + AFE_ADCR_OFFSET) -#define AFE_DUMMY0 (AFE_BASE + AFE_DUMMY0_OFFSET) -#define AFE_DUMMY1 (AFE_BASE + AFE_DUMMY1_OFFSET) -#define AFE_DUMMY2 (AFE_BASE + AFE_DUMMY2_OFFSET) -#define AFE_DACAMP (AFE_BASE + AFE_DACAMP_OFFSET) -#define AFE_CLMPTST (AFE_BASE + AFE_CLMPTST_OFFSET) -#define AFE_CLMPDAT (AFE_BASE + AFE_CLMPDAT_OFFSET) -#define AFE_CLMPAMP (AFE_BASE + AFE_CLMPAMP_OFFSET) -#define AFE_CLAMP (AFE_BASE + AFE_CLAMP_OFFSET) -#define AFE_INPBUF (AFE_BASE + AFE_INPBUF_OFFSET) -#define AFE_INPFLT (AFE_BASE + AFE_INPFLT_OFFSET) -#define AFE_ADCDGN (AFE_BASE + AFE_ADCDGN_OFFSET) -#define AFE_OFFDRV (AFE_BASE + AFE_OFFDRV_OFFSET) -#define AFE_INPCONFIG (AFE_BASE + AFE_INPCONFIG_OFFSET) -#define AFE_PROGDELAY (AFE_BASE + AFE_PROGDELAY_OFFSET) -#define AFE_ADCOMT (AFE_BASE + AFE_ADCOMT_OFFSET) -#define AFE_ALGDELAY (AFE_BASE + AFE_ALGDELAY_OFFSET) -#define AFE_ACC_ID (AFE_BASE + AFE_ACC_ID_OFFSET) -#define AFE_ACCSTA (AFE_BASE + AFE_ACCSTA_OFFSET) -#define AFE_ACCNOSLI (AFE_BASE + AFE_ACCNOSLI_OFFSET) -#define AFE_ACCCALCON (AFE_BASE + AFE_ACCCALCON_OFFSET) -#define AFE_BWEWRICTRL (AFE_BASE + AFE_BWEWRICTRL_OFFSET) -#define AFE_SELSLI (AFE_BASE + AFE_SELSLI_OFFSET) -#define AFE_SELBYT (AFE_BASE + AFE_SELBYT_OFFSET) -#define AFE_REDVAL (AFE_BASE + AFE_REDVAL_OFFSET) -#define AFE_WRIBYT (AFE_BASE + AFE_WRIBYT_OFFSET) - -/* VDEC - Register offsets */ -#define VDEC_CFC1_OFFSET 0x00000000 -#define VDEC_CFC2_OFFSET 0x00000004 -#define VDEC_BRSTGT_OFFSET 0x00000024 -#define VDEC_HZPOS_OFFSET 0x00000040 -#define VDEC_VRTPOS_OFFSET 0x00000044 -#define VDEC_HVSHIFT_OFFSET 0x00000054 -#define VDEC_HSIGS_OFFSET 0x00000058 -#define VDEC_HSIGE_OFFSET 0x0000005C -#define VDEC_VSCON1_OFFSET 0x00000060 -#define VDEC_VSCON2_OFFSET 0x00000064 -#define VDEC_YCDEL_OFFSET 0x0000006C -#define VDEC_AFTCLP_OFFSET 0x00000070 -#define VDEC_DCOFF_OFFSET 0x00000078 -#define VDEC_CSID_OFFSET 0x00000084 -#define VDEC_CBGN_OFFSET 0x00000088 -#define VDEC_CRGN_OFFSET 0x0000008C -#define VDEC_CNTR_OFFSET 0x00000090 -#define VDEC_BRT_OFFSET 0x00000094 -#define VDEC_HUE_OFFSET 0x00000098 -#define VDEC_CHBTH_OFFSET 0x0000009C -#define VDEC_SHPIMP_OFFSET 0x000000A4 -#define VDEC_CHPLLIM_OFFSET 0x000000A8 -#define VDEC_VIDMOD_OFFSET 0x000000AC -#define VDEC_VIDSTS_OFFSET 0x000000B0 -#define VDEC_NOISE_OFFSET 0x000000B4 -#define VDEC_STDDBG_OFFSET 0x000000B8 -#define VDEC_MANOVR_OFFSET 0x000000BC -#define VDEC_VSSGTH_OFFSET 0x000000C8 -#define VDEC_DBGFBH_OFFSET 0x000000D0 -#define VDEC_DBGFBL_OFFSET 0x000000D4 -#define VDEC_HACTS_OFFSET 0x000000D8 -#define VDEC_HACTE_OFFSET 0x000000DC -#define VDEC_VACTS_OFFSET 0x000000E0 -#define VDEC_VACTE_OFFSET 0x000000E4 -#define VDEC_HSTIP_OFFSET 0x000000EC -#define VDEC_BLSCRY_OFFSET 0x000000F4 -#define VDEC_BLSCRCR_OFFSET 0x000000F8 -#define VDEC_BLSCRCB_OFFSET 0x000000FC -#define VDEC_LMAGC1_OFFSET 0x00000100 -#define VDEC_LMAGC2_OFFSET 0x00000104 -#define VDEC_CHAGC1_OFFSET 0x00000108 -#define VDEC_CHAGC2_OFFSET 0x0000010C -#define VDEC_MINTH_OFFSET 0x00000114 -#define VDEC_VFRQOH_OFFSET 0x0000011C -#define VDEC_VFRQOL_OFFSET 0x00000120 -#define VDEC_THSH1_OFFSET 0x00000124 -#define VDEC_THSH2_OFFSET 0x00000128 -#define VDEC_NCHTH_OFFSET 0x0000012C -#define VDEC_TH1F_OFFSET 0x00000130 - -/* VDEC Register per module */ -#define VDEC_CFC1 (VDEC_BASE + VDEC_CFC1_OFFSET) -#define VDEC_CFC2 (VDEC_BASE + VDEC_CFC2_OFFSET) -#define VDEC_BRSTGT (VDEC_BASE + VDEC_BRSTGT_OFFSET) -#define VDEC_HZPOS (VDEC_BASE + VDEC_HZPOS_OFFSET) -#define VDEC_VRTPOS (VDEC_BASE + VDEC_VRTPOS_OFFSET) -#define VDEC_HVSHIFT (VDEC_BASE + VDEC_HVSHIFT_OFFSET) -#define VDEC_HSIGS (VDEC_BASE + VDEC_HSIGS_OFFSET) -#define VDEC_HSIGE (VDEC_BASE + VDEC_HSIGE_OFFSET) -#define VDEC_VSCON1 (VDEC_BASE + VDEC_VSCON1_OFFSET) -#define VDEC_VSCON2 (VDEC_BASE + VDEC_VSCON2_OFFSET) -#define VDEC_YCDEL (VDEC_BASE + VDEC_YCDEL_OFFSET) -#define VDEC_AFTCLP (VDEC_BASE + VDEC_AFTCLP_OFFSET) -#define VDEC_DCOFF (VDEC_BASE + VDEC_DCOFF_OFFSET) -#define VDEC_CSID (VDEC_BASE + VDEC_CSID_OFFSET) -#define VDEC_CBGN (VDEC_BASE + VDEC_CBGN_OFFSET) -#define VDEC_CRGN (VDEC_BASE + VDEC_CRGN_OFFSET) -#define VDEC_CNTR (VDEC_BASE + VDEC_CNTR_OFFSET) -#define VDEC_BRT (VDEC_BASE + VDEC_BRT_OFFSET) -#define VDEC_HUE (VDEC_BASE + VDEC_HUE_OFFSET) -#define VDEC_CHBTH (VDEC_BASE + VDEC_CHBTH_OFFSET) -#define VDEC_SHPIMP (VDEC_BASE + VDEC_SHPIMP_OFFSET) -#define VDEC_CHPLLIM (VDEC_BASE + VDEC_CHPLLIM_OFFSET) -#define VDEC_VIDMOD (VDEC_BASE + VDEC_VIDMOD_OFFSET) -#define VDEC_VIDSTS (VDEC_BASE + VDEC_VIDSTS_OFFSET) -#define VDEC_NOISE (VDEC_BASE + VDEC_NOISE_OFFSET) -#define VDEC_STDDBG (VDEC_BASE + VDEC_STDDBG_OFFSET) -#define VDEC_MANOVR (VDEC_BASE + VDEC_MANOVR_OFFSET) -#define VDEC_VSSGTH (VDEC_BASE + VDEC_VSSGTH_OFFSET) -#define VDEC_DBGFBH (VDEC_BASE + VDEC_DBGFBH_OFFSET) -#define VDEC_DBGFBL (VDEC_BASE + VDEC_DBGFBL_OFFSET) -#define VDEC_HACTS (VDEC_BASE + VDEC_HACTS_OFFSET) -#define VDEC_HACTE (VDEC_BASE + VDEC_HACTE_OFFSET) -#define VDEC_VACTS (VDEC_BASE + VDEC_VACTS_OFFSET) -#define VDEC_VACTE (VDEC_BASE + VDEC_VACTE_OFFSET) -#define VDEC_HSTIP (VDEC_BASE + VDEC_HSTIP_OFFSET) -#define VDEC_BLSCRY (VDEC_BASE + VDEC_BLSCRY_OFFSET) -#define VDEC_BLSCRCR (VDEC_BASE + VDEC_BLSCRCR_OFFSET) -#define VDEC_BLSCRCB (VDEC_BASE + VDEC_BLSCRCB_OFFSET) -#define VDEC_LMAGC1 (VDEC_BASE + VDEC_LMAGC1_OFFSET) -#define VDEC_LMAGC2 (VDEC_BASE + VDEC_LMAGC2_OFFSET) -#define VDEC_CHAGC1 (VDEC_BASE + VDEC_CHAGC1_OFFSET) -#define VDEC_CHAGC2 (VDEC_BASE + VDEC_CHAGC2_OFFSET) -#define VDEC_MINTH (VDEC_BASE + VDEC_MINTH_OFFSET) -#define VDEC_VFRQOH (VDEC_BASE + VDEC_VFRQOH_OFFSET) -#define VDEC_VFRQOL (VDEC_BASE + VDEC_VFRQOL_OFFSET) -#define VDEC_THSH1 (VDEC_BASE + VDEC_THSH1_OFFSET) -#define VDEC_THSH2 (VDEC_BASE + VDEC_THSH2_OFFSET) -#define VDEC_NCHTH (VDEC_BASE + VDEC_NCHTH_OFFSET) -#define VDEC_TH1F (VDEC_BASE + VDEC_TH1F_OFFSET) - -#define VDEC_VIDMOD_SIGNAL_MASK 0x0F -#define VDEC_VIDMOD_SIGNAL_DETECT 0x0F - -#define VDEC_VIDMOD_M625_SHIFT 4 -#define VDEC_VIDMOD_M625_MASK (1 << VDEC_VIDMOD_M625_SHIFT) - -#define VDEC_VIDMOD_PAL_SHIFT 7 -#define VDEC_VIDMOD_PAL_MASK (1 << VDEC_VIDMOD_PAL_SHIFT) -/*** define base address ***/ - -#endif diff --git a/drivers/media/platform/mxc/capture/ov5640.c b/drivers/media/platform/mxc/capture/ov5640.c deleted file mode 100644 index ec8b8090201d44b1a93b560f837836917bb6ae15..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ov5640.c +++ /dev/null @@ -1,1950 +0,0 @@ -/* - * Copyright (C) 2012-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * 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. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "v4l2-int-device.h" -#include "mxc_v4l2_capture.h" - -#define OV5640_VOLTAGE_ANALOG 2800000 -#define OV5640_VOLTAGE_DIGITAL_CORE 1500000 -#define OV5640_VOLTAGE_DIGITAL_IO 1800000 - -#define MIN_FPS 15 -#define MAX_FPS 30 -#define DEFAULT_FPS 30 - -#define OV5640_XCLK_MIN 6000000 -#define OV5640_XCLK_MAX 24000000 - -#define OV5640_CHIP_ID_HIGH_BYTE 0x300A -#define OV5640_CHIP_ID_LOW_BYTE 0x300B - -enum ov5640_mode { - ov5640_mode_MIN = 0, - ov5640_mode_VGA_640_480 = 0, - ov5640_mode_QVGA_320_240 = 1, - ov5640_mode_NTSC_720_480 = 2, - ov5640_mode_PAL_720_576 = 3, - ov5640_mode_720P_1280_720 = 4, - ov5640_mode_1080P_1920_1080 = 5, - ov5640_mode_QSXGA_2592_1944 = 6, - ov5640_mode_QCIF_176_144 = 7, - ov5640_mode_XGA_1024_768 = 8, - ov5640_mode_MAX = 8 -}; - -enum ov5640_frame_rate { - ov5640_15_fps, - ov5640_30_fps -}; - -static int ov5640_framerates[] = { - [ov5640_15_fps] = 15, - [ov5640_30_fps] = 30, -}; - -struct reg_value { - u16 u16RegAddr; - u8 u8Val; - u8 u8Mask; - u32 u32Delay_ms; -}; - -struct ov5640_mode_info { - enum ov5640_mode mode; - u32 width; - u32 height; - struct reg_value *init_data_ptr; - u32 init_data_size; -}; - -/*! - * Maintains the information on the current state of the sesor. - */ -static struct sensor_data ov5640_data; -static int pwn_gpio, rst_gpio; -static int prev_sysclk; -static int AE_Target = 52, night_mode; -static int prev_HTS; -static int AE_high, AE_low; - -static struct reg_value ov5640_global_init_setting[] = { - {0x3008, 0x42, 0, 0}, - {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, - {0x3034, 0x1a, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, - {0x3630, 0x36, 0, 0}, {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, - {0x3633, 0x12, 0, 0}, {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, - {0x3703, 0x5a, 0, 0}, {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, - {0x370b, 0x60, 0, 0}, {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, - {0x3906, 0x10, 0, 0}, {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, - {0x3600, 0x08, 0, 0}, {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, - {0x3620, 0x52, 0, 0}, {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, - {0x3a13, 0x43, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, - {0x3635, 0x13, 0, 0}, {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, - {0x3622, 0x01, 0, 0}, {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, - {0x3c05, 0x98, 0, 0}, {0x3c06, 0x00, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3c08, 0x00, 0, 0}, {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, - {0x3c0b, 0x40, 0, 0}, {0x3810, 0x00, 0, 0}, {0x3811, 0x10, 0, 0}, - {0x3812, 0x00, 0, 0}, {0x3708, 0x64, 0, 0}, {0x4001, 0x02, 0, 0}, - {0x4005, 0x1a, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, - {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x5000, 0xa7, 0, 0}, - {0x3008, 0x02, 0, 0}, -}; - -static struct reg_value ov5640_init_setting_30fps_VGA[] = { - {0x3008, 0x42, 0, 0}, - {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, - {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, {0x3036, 0x46, 0, 0}, - {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, {0x3630, 0x36, 0, 0}, - {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0}, - {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, - {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0}, - {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, {0x3906, 0x10, 0, 0}, - {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, {0x3600, 0x08, 0, 0}, - {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, {0x3620, 0x52, 0, 0}, - {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, {0x3a13, 0x43, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3635, 0x13, 0, 0}, - {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, {0x3622, 0x01, 0, 0}, - {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, {0x3c05, 0x98, 0, 0}, - {0x3c06, 0x00, 0, 0}, {0x3c07, 0x08, 0, 0}, {0x3c08, 0x00, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, - {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, {0x5000, 0xa7, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0xf2, 0, 0}, - {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0}, {0x5187, 0x09, 0, 0}, - {0x5188, 0x09, 0, 0}, {0x5189, 0x88, 0, 0}, {0x518a, 0x54, 0, 0}, - {0x518b, 0xee, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x50, 0, 0}, - {0x518e, 0x34, 0, 0}, {0x518f, 0x6b, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x6c, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x09, 0, 0}, - {0x519d, 0x2b, 0, 0}, {0x519e, 0x38, 0, 0}, {0x5381, 0x1e, 0, 0}, - {0x5382, 0x5b, 0, 0}, {0x5383, 0x08, 0, 0}, {0x5384, 0x0a, 0, 0}, - {0x5385, 0x7e, 0, 0}, {0x5386, 0x88, 0, 0}, {0x5387, 0x7c, 0, 0}, - {0x5388, 0x6c, 0, 0}, {0x5389, 0x10, 0, 0}, {0x538a, 0x01, 0, 0}, - {0x538b, 0x98, 0, 0}, {0x5300, 0x08, 0, 0}, {0x5301, 0x30, 0, 0}, - {0x5302, 0x10, 0, 0}, {0x5303, 0x00, 0, 0}, {0x5304, 0x08, 0, 0}, - {0x5305, 0x30, 0, 0}, {0x5306, 0x08, 0, 0}, {0x5307, 0x16, 0, 0}, - {0x5309, 0x08, 0, 0}, {0x530a, 0x30, 0, 0}, {0x530b, 0x04, 0, 0}, - {0x530c, 0x06, 0, 0}, {0x5480, 0x01, 0, 0}, {0x5481, 0x08, 0, 0}, - {0x5482, 0x14, 0, 0}, {0x5483, 0x28, 0, 0}, {0x5484, 0x51, 0, 0}, - {0x5485, 0x65, 0, 0}, {0x5486, 0x71, 0, 0}, {0x5487, 0x7d, 0, 0}, - {0x5488, 0x87, 0, 0}, {0x5489, 0x91, 0, 0}, {0x548a, 0x9a, 0, 0}, - {0x548b, 0xaa, 0, 0}, {0x548c, 0xb8, 0, 0}, {0x548d, 0xcd, 0, 0}, - {0x548e, 0xdd, 0, 0}, {0x548f, 0xea, 0, 0}, {0x5490, 0x1d, 0, 0}, - {0x5580, 0x02, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x10, 0, 0}, - {0x5589, 0x10, 0, 0}, {0x558a, 0x00, 0, 0}, {0x558b, 0xf8, 0, 0}, - {0x5800, 0x23, 0, 0}, {0x5801, 0x14, 0, 0}, {0x5802, 0x0f, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x12, 0, 0}, {0x5805, 0x26, 0, 0}, - {0x5806, 0x0c, 0, 0}, {0x5807, 0x08, 0, 0}, {0x5808, 0x05, 0, 0}, - {0x5809, 0x05, 0, 0}, {0x580a, 0x08, 0, 0}, {0x580b, 0x0d, 0, 0}, - {0x580c, 0x08, 0, 0}, {0x580d, 0x03, 0, 0}, {0x580e, 0x00, 0, 0}, - {0x580f, 0x00, 0, 0}, {0x5810, 0x03, 0, 0}, {0x5811, 0x09, 0, 0}, - {0x5812, 0x07, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x00, 0, 0}, - {0x5815, 0x01, 0, 0}, {0x5816, 0x03, 0, 0}, {0x5817, 0x08, 0, 0}, - {0x5818, 0x0d, 0, 0}, {0x5819, 0x08, 0, 0}, {0x581a, 0x05, 0, 0}, - {0x581b, 0x06, 0, 0}, {0x581c, 0x08, 0, 0}, {0x581d, 0x0e, 0, 0}, - {0x581e, 0x29, 0, 0}, {0x581f, 0x17, 0, 0}, {0x5820, 0x11, 0, 0}, - {0x5821, 0x11, 0, 0}, {0x5822, 0x15, 0, 0}, {0x5823, 0x28, 0, 0}, - {0x5824, 0x46, 0, 0}, {0x5825, 0x26, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x26, 0, 0}, {0x5828, 0x64, 0, 0}, {0x5829, 0x26, 0, 0}, - {0x582a, 0x24, 0, 0}, {0x582b, 0x22, 0, 0}, {0x582c, 0x24, 0, 0}, - {0x582d, 0x24, 0, 0}, {0x582e, 0x06, 0, 0}, {0x582f, 0x22, 0, 0}, - {0x5830, 0x40, 0, 0}, {0x5831, 0x42, 0, 0}, {0x5832, 0x24, 0, 0}, - {0x5833, 0x26, 0, 0}, {0x5834, 0x24, 0, 0}, {0x5835, 0x22, 0, 0}, - {0x5836, 0x22, 0, 0}, {0x5837, 0x26, 0, 0}, {0x5838, 0x44, 0, 0}, - {0x5839, 0x24, 0, 0}, {0x583a, 0x26, 0, 0}, {0x583b, 0x28, 0, 0}, - {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0}, {0x5025, 0x00, 0, 0}, - {0x3a0f, 0x30, 0, 0}, {0x3a10, 0x28, 0, 0}, {0x3a1b, 0x30, 0, 0}, - {0x3a1e, 0x26, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x14, 0, 0}, - {0x3008, 0x02, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_VGA_640_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_VGA_640_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_QVGA_320_240[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QVGA_320_240[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_NTSC_720_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, - {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_NTSC_720_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, - {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_PAL_720_576[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_PAL_720_576[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_720P_1280_720[] = { - {0x3035, 0x21, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, - {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, - {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, - {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, - {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, - {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_720P_1280_720[] = { - {0x3035, 0x41, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, - {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, - {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, - {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, - {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, - {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_QCIF_176_144[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QCIF_176_144[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_XGA_1024_768[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, - {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_XGA_1024_768[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, - {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - - -static struct reg_value ov5640_setting_15fps_1080P_1920_1080[] = { - {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, - {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0xee, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x05, 0, 0}, - {0x3807, 0xc3, 0, 0}, {0x3808, 0x07, 0, 0}, {0x3809, 0x80, 0, 0}, - {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0}, {0x380c, 0x0b, 0, 0}, - {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, - {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, - {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, - {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, - {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = { - {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, - {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9f, 0, 0}, {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, - {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, - {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, - {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, - {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, - {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, - {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct ov5640_mode_info ov5640_mode_info_data[2][ov5640_mode_MAX + 1] = { - { - {ov5640_mode_VGA_640_480, 640, 480, - ov5640_setting_15fps_VGA_640_480, - ARRAY_SIZE(ov5640_setting_15fps_VGA_640_480)}, - {ov5640_mode_QVGA_320_240, 320, 240, - ov5640_setting_15fps_QVGA_320_240, - ARRAY_SIZE(ov5640_setting_15fps_QVGA_320_240)}, - {ov5640_mode_NTSC_720_480, 720, 480, - ov5640_setting_15fps_NTSC_720_480, - ARRAY_SIZE(ov5640_setting_15fps_NTSC_720_480)}, - {ov5640_mode_PAL_720_576, 720, 576, - ov5640_setting_15fps_PAL_720_576, - ARRAY_SIZE(ov5640_setting_15fps_PAL_720_576)}, - {ov5640_mode_720P_1280_720, 1280, 720, - ov5640_setting_15fps_720P_1280_720, - ARRAY_SIZE(ov5640_setting_15fps_720P_1280_720)}, - {ov5640_mode_1080P_1920_1080, 1920, 1080, - ov5640_setting_15fps_1080P_1920_1080, - ARRAY_SIZE(ov5640_setting_15fps_1080P_1920_1080)}, - {ov5640_mode_QSXGA_2592_1944, 2592, 1944, - ov5640_setting_15fps_QSXGA_2592_1944, - ARRAY_SIZE(ov5640_setting_15fps_QSXGA_2592_1944)}, - {ov5640_mode_QCIF_176_144, 176, 144, - ov5640_setting_15fps_QCIF_176_144, - ARRAY_SIZE(ov5640_setting_15fps_QCIF_176_144)}, - {ov5640_mode_XGA_1024_768, 1024, 768, - ov5640_setting_15fps_XGA_1024_768, - ARRAY_SIZE(ov5640_setting_15fps_XGA_1024_768)}, - }, - { - {ov5640_mode_VGA_640_480, 640, 480, - ov5640_setting_30fps_VGA_640_480, - ARRAY_SIZE(ov5640_setting_30fps_VGA_640_480)}, - {ov5640_mode_QVGA_320_240, 320, 240, - ov5640_setting_30fps_QVGA_320_240, - ARRAY_SIZE(ov5640_setting_30fps_QVGA_320_240)}, - {ov5640_mode_NTSC_720_480, 720, 480, - ov5640_setting_30fps_NTSC_720_480, - ARRAY_SIZE(ov5640_setting_30fps_NTSC_720_480)}, - {ov5640_mode_PAL_720_576, 720, 576, - ov5640_setting_30fps_PAL_720_576, - ARRAY_SIZE(ov5640_setting_30fps_PAL_720_576)}, - {ov5640_mode_720P_1280_720, 1280, 720, - ov5640_setting_30fps_720P_1280_720, - ARRAY_SIZE(ov5640_setting_30fps_720P_1280_720)}, - {ov5640_mode_1080P_1920_1080, 0, 0, NULL, 0}, - {ov5640_mode_QSXGA_2592_1944, 0, 0, NULL, 0}, - {ov5640_mode_QCIF_176_144, 176, 144, - ov5640_setting_30fps_QCIF_176_144, - ARRAY_SIZE(ov5640_setting_30fps_QCIF_176_144)}, - {ov5640_mode_XGA_1024_768, 1024, 768, - ov5640_setting_30fps_XGA_1024_768, - ARRAY_SIZE(ov5640_setting_30fps_XGA_1024_768)}, - }, -}; - -static struct regulator *io_regulator; -static struct regulator *core_regulator; -static struct regulator *analog_regulator; - -static int ov5640_probe(struct i2c_client *adapter, - const struct i2c_device_id *device_id); -static int ov5640_remove(struct i2c_client *client); - -static s32 ov5640_read_reg(u16 reg, u8 *val); -static s32 ov5640_write_reg(u16 reg, u8 val); - -static const struct i2c_device_id ov5640_id[] = { - {"ov564x", 0}, - {}, -}; - -MODULE_DEVICE_TABLE(i2c, ov5640_id); - -static struct i2c_driver ov5640_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "ov564x", - }, - .probe = ov5640_probe, - .remove = ov5640_remove, - .id_table = ov5640_id, -}; - -static inline void ov5640_power_down(int enable) -{ - gpio_set_value(pwn_gpio, enable); - - msleep(2); -} - -static inline void ov5640_reset(void) -{ - /* camera reset */ - gpio_set_value(rst_gpio, 1); - - /* camera power down */ - gpio_set_value(pwn_gpio, 1); - msleep(5); - gpio_set_value(pwn_gpio, 0); - msleep(5); - gpio_set_value(rst_gpio, 0); - msleep(1); - gpio_set_value(rst_gpio, 1); - msleep(5); - gpio_set_value(pwn_gpio, 1); -} - -static int ov5640_regulator_enable(struct device *dev) -{ - int ret = 0; - - io_regulator = devm_regulator_get(dev, "DOVDD"); - if (!IS_ERR(io_regulator)) { - regulator_set_voltage(io_regulator, - OV5640_VOLTAGE_DIGITAL_IO, - OV5640_VOLTAGE_DIGITAL_IO); - ret = regulator_enable(io_regulator); - if (ret) { - dev_err(dev, "set io voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set io voltage ok\n"); - } - } else { - io_regulator = NULL; - dev_warn(dev, "cannot get io voltage\n"); - } - - core_regulator = devm_regulator_get(dev, "DVDD"); - if (!IS_ERR(core_regulator)) { - regulator_set_voltage(core_regulator, - OV5640_VOLTAGE_DIGITAL_CORE, - OV5640_VOLTAGE_DIGITAL_CORE); - ret = regulator_enable(core_regulator); - if (ret) { - dev_err(dev, "set core voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set core voltage ok\n"); - } - } else { - core_regulator = NULL; - dev_warn(dev, "cannot get core voltage\n"); - } - - analog_regulator = devm_regulator_get(dev, "AVDD"); - if (!IS_ERR(analog_regulator)) { - regulator_set_voltage(analog_regulator, - OV5640_VOLTAGE_ANALOG, - OV5640_VOLTAGE_ANALOG); - ret = regulator_enable(analog_regulator); - if (ret) { - dev_err(dev, "set analog voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set analog voltage ok\n"); - } - } else { - analog_regulator = NULL; - dev_warn(dev, "cannot get analog voltage\n"); - } - - return ret; -} - -static s32 ov5640_write_reg(u16 reg, u8 val) -{ - u8 au8Buf[3] = {0}; - - au8Buf[0] = reg >> 8; - au8Buf[1] = reg & 0xff; - au8Buf[2] = val; - - if (i2c_master_send(ov5640_data.i2c_client, au8Buf, 3) < 0) { - pr_err("%s:write reg error:reg=%x,val=%x\n", - __func__, reg, val); - return -1; - } - - return 0; -} - -static s32 ov5640_read_reg(u16 reg, u8 *val) -{ - u8 au8RegBuf[2] = {0}; - u8 u8RdVal = 0; - - au8RegBuf[0] = reg >> 8; - au8RegBuf[1] = reg & 0xff; - - if (2 != i2c_master_send(ov5640_data.i2c_client, au8RegBuf, 2)) { - pr_err("%s:write reg error:reg=%x\n", - __func__, reg); - return -1; - } - - if (1 != i2c_master_recv(ov5640_data.i2c_client, &u8RdVal, 1)) { - pr_err("%s:read reg error:reg=%x,val=%x\n", - __func__, reg, u8RdVal); - return -1; - } - - *val = u8RdVal; - - return u8RdVal; -} - -static void ov5640_soft_reset(void) -{ - /* sysclk from pad */ - ov5640_write_reg(0x3103, 0x11); - - /* software reset */ - ov5640_write_reg(0x3008, 0x82); - - /* delay at least 5ms */ - msleep(10); -} - -/* set sensor driver capability - * 0x302c[7:6] - strength - 00 - 1x - 01 - 2x - 10 - 3x - 11 - 4x - */ -static int ov5640_driver_capability(int strength) -{ - u8 temp = 0; - - if (strength > 4 || strength < 1) { - pr_err("The valid driver capability of ov5640 is 1x~4x\n"); - return -EINVAL; - } - - ov5640_read_reg(0x302c, &temp); - - temp &= ~0xc0; /* clear [7:6] */ - temp |= ((strength - 1) << 6); /* set [7:6] */ - - ov5640_write_reg(0x302c, temp); - - return 0; -} - -/* calculate sysclk */ -static int ov5640_get_sysclk(void) -{ - int xvclk = ov5640_data.mclk / 10000; - int sysclk; - int temp1, temp2; - int Multiplier, PreDiv, VCO, SysDiv, Pll_rdiv, Bit_div2x, sclk_rdiv; - int sclk_rdiv_map[] = {1, 2, 4, 8}; - u8 regval = 0; - - temp1 = ov5640_read_reg(0x3034, ®val); - temp2 = temp1 & 0x0f; - if (temp2 == 8 || temp2 == 10) { - Bit_div2x = temp2 / 2; - } else { - pr_err("ov5640: unsupported bit mode %d\n", temp2); - return -1; - } - - temp1 = ov5640_read_reg(0x3035, ®val); - SysDiv = temp1 >> 4; - if (SysDiv == 0) - SysDiv = 16; - - temp1 = ov5640_read_reg(0x3036, ®val); - Multiplier = temp1; - temp1 = ov5640_read_reg(0x3037, ®val); - PreDiv = temp1 & 0x0f; - Pll_rdiv = ((temp1 >> 4) & 0x01) + 1; - - temp1 = ov5640_read_reg(0x3108, ®val); - temp2 = temp1 & 0x03; - - sclk_rdiv = sclk_rdiv_map[temp2]; - VCO = xvclk * Multiplier / PreDiv; - sysclk = VCO / SysDiv / Pll_rdiv * 2 / Bit_div2x / sclk_rdiv; - - return sysclk; -} - -/* read HTS from register settings */ -static int ov5640_get_HTS(void) -{ - int HTS; - u8 temp = 0; - - HTS = ov5640_read_reg(0x380c, &temp); - HTS = (HTS<<8) + ov5640_read_reg(0x380d, &temp); - return HTS; -} - -/* read VTS from register settings */ -static int ov5640_get_VTS(void) -{ - int VTS; - u8 temp = 0; - - VTS = ov5640_read_reg(0x380e, &temp); - VTS = (VTS<<8) + ov5640_read_reg(0x380f, &temp); - - return VTS; -} - -/* write VTS to registers */ -static int ov5640_set_VTS(int VTS) -{ - int temp; - - temp = VTS & 0xff; - ov5640_write_reg(0x380f, temp); - - temp = VTS>>8; - ov5640_write_reg(0x380e, temp); - return 0; -} - -/* read shutter, in number of line period */ -static int ov5640_get_shutter(void) -{ - int shutter; - u8 regval; - - shutter = (ov5640_read_reg(0x03500, ®val) & 0x0f); - - shutter = (shutter<<8) + ov5640_read_reg(0x3501, ®val); - shutter = (shutter<<4) + (ov5640_read_reg(0x3502, ®val)>>4); - - return shutter; -} - -/* write shutter, in number of line period */ -static int ov5640_set_shutter(int shutter) -{ - int temp; - - shutter = shutter & 0xffff; - temp = shutter & 0x0f; - temp = temp<<4; - ov5640_write_reg(0x3502, temp); - - temp = shutter & 0xfff; - temp = temp>>4; - ov5640_write_reg(0x3501, temp); - - temp = shutter>>12; - ov5640_write_reg(0x3500, temp); - - return 0; -} - -/* read gain, 16 = 1x */ -static int ov5640_get_gain16(void) -{ - int gain16; - u8 regval; - - gain16 = ov5640_read_reg(0x350a, ®val) & 0x03; - gain16 = (gain16<<8) + ov5640_read_reg(0x350b, ®val); - - return gain16; -} - -/* write gain, 16 = 1x */ -static int ov5640_set_gain16(int gain16) -{ - int temp; - - gain16 = gain16 & 0x3ff; - temp = gain16 & 0xff; - - ov5640_write_reg(0x350b, temp); - temp = gain16>>8; - - ov5640_write_reg(0x350a, temp); - return 0; -} - -/* get banding filter value */ -static int ov5640_get_light_freq(void) -{ - int temp, temp1, light_frequency; - u8 regval; - - temp = ov5640_read_reg(0x3c01, ®val); - if (temp & 0x80) { - /* manual */ - temp1 = ov5640_read_reg(0x3c00, ®val); - if (temp1 & 0x04) { - /* 50Hz */ - light_frequency = 50; - } else { - /* 60Hz */ - light_frequency = 60; - } - } else { - /* auto */ - temp1 = ov5640_read_reg(0x3c0c, ®val); - if (temp1 & 0x01) { - /* 50Hz */ - light_frequency = 50; - } else { - /* 60Hz */ - light_frequency = 60; - } - } - - return light_frequency; -} - -static void ov5640_set_bandingfilter(void) -{ - int prev_VTS; - int band_step60, max_band60, band_step50, max_band50; - - /* read preview PCLK */ - prev_sysclk = ov5640_get_sysclk(); - - /* read preview HTS */ - prev_HTS = ov5640_get_HTS(); - - /* read preview VTS */ - prev_VTS = ov5640_get_VTS(); - - /* calculate banding filter */ - /* 60Hz */ - band_step60 = prev_sysclk * 100/prev_HTS * 100/120; - ov5640_write_reg(0x3a0a, (band_step60 >> 8)); - ov5640_write_reg(0x3a0b, (band_step60 & 0xff)); - - max_band60 = (int)((prev_VTS-4)/band_step60); - ov5640_write_reg(0x3a0d, max_band60); - - /* 50Hz */ - band_step50 = prev_sysclk * 100/prev_HTS; - ov5640_write_reg(0x3a08, (band_step50 >> 8)); - ov5640_write_reg(0x3a09, (band_step50 & 0xff)); - - max_band50 = (int)((prev_VTS-4)/band_step50); - ov5640_write_reg(0x3a0e, max_band50); -} - -/* stable in high */ -static int ov5640_set_AE_target(int target) -{ - int fast_high, fast_low; - - AE_low = target * 23 / 25; /* 0.92 */ - AE_high = target * 27 / 25; /* 1.08 */ - fast_high = AE_high << 1; - - if (fast_high > 255) - fast_high = 255; - fast_low = AE_low >> 1; - - ov5640_write_reg(0x3a0f, AE_high); - ov5640_write_reg(0x3a10, AE_low); - ov5640_write_reg(0x3a1b, AE_high); - ov5640_write_reg(0x3a1e, AE_low); - ov5640_write_reg(0x3a11, fast_high); - ov5640_write_reg(0x3a1f, fast_low); - - return 0; -} - -/* enable = 0 to turn off night mode - enable = 1 to turn on night mode */ -static int ov5640_set_night_mode(int enable) -{ - u8 mode; - - ov5640_read_reg(0x3a00, &mode); - - if (enable) { - /* night mode on */ - mode |= 0x04; - ov5640_write_reg(0x3a00, mode); - } else { - /* night mode off */ - mode &= 0xfb; - ov5640_write_reg(0x3a00, mode); - } - - return 0; -} - -/* enable = 0 to turn off AEC/AGC - enable = 1 to turn on AEC/AGC */ -static void ov5640_turn_on_AE_AG(int enable) -{ - u8 ae_ag_ctrl; - - ov5640_read_reg(0x3503, &ae_ag_ctrl); - if (enable) { - /* turn on auto AE/AG */ - ae_ag_ctrl = ae_ag_ctrl & ~(0x03); - } else { - /* turn off AE/AG */ - ae_ag_ctrl = ae_ag_ctrl | 0x03; - } - ov5640_write_reg(0x3503, ae_ag_ctrl); -} - -/* download ov5640 settings to sensor through i2c */ -static int ov5640_download_firmware(struct reg_value *pModeSetting, s32 ArySize) -{ - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int i, retval = 0; - - for (i = 0; i < ArySize; ++i, ++pModeSetting) { - Delay_ms = pModeSetting->u32Delay_ms; - RegAddr = pModeSetting->u16RegAddr; - Val = pModeSetting->u8Val; - Mask = pModeSetting->u8Mask; - - if (Mask) { - retval = ov5640_read_reg(RegAddr, &RegVal); - if (retval < 0) - goto err; - - RegVal &= ~(u8)Mask; - Val &= Mask; - Val |= RegVal; - } - - retval = ov5640_write_reg(RegAddr, Val); - if (retval < 0) - goto err; - - if (Delay_ms) - msleep(Delay_ms); - } -err: - return retval; -} - -static int ov5640_init_mode(void) -{ - struct reg_value *pModeSetting = NULL; - int ArySize = 0, retval = 0; - - ov5640_soft_reset(); - - pModeSetting = ov5640_global_init_setting; - ArySize = ARRAY_SIZE(ov5640_global_init_setting); - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - pModeSetting = ov5640_init_setting_30fps_VGA; - ArySize = ARRAY_SIZE(ov5640_init_setting_30fps_VGA); - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - /* change driver capability to 2x according to validation board. - * if the image is not stable, please increase the driver strength. - */ - ov5640_driver_capability(2); - ov5640_set_bandingfilter(); - ov5640_set_AE_target(AE_Target); - ov5640_set_night_mode(night_mode); - - /* skip 9 vysnc: start capture at 10th vsync */ - msleep(300); - - /* turn off night mode */ - night_mode = 0; - ov5640_data.pix.width = 640; - ov5640_data.pix.height = 480; -err: - return retval; -} - -/* change to or back to subsampling mode set the mode directly - * image size below 1280 * 960 is subsampling mode */ -static int ov5640_change_mode_direct(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - - if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { - pr_err("Wrong ov5640 mode detected!\n"); - return -1; - } - - pModeSetting = ov5640_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5640_mode_info_data[frame_rate][mode].init_data_size; - - ov5640_data.pix.width = ov5640_mode_info_data[frame_rate][mode].width; - ov5640_data.pix.height = ov5640_mode_info_data[frame_rate][mode].height; - - if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - /* set ov5640 to subsampling mode */ - retval = ov5640_download_firmware(pModeSetting, ArySize); - - /* turn on AE AG for subsampling mode, in case the firmware didn't */ - ov5640_turn_on_AE_AG(1); - - /* calculate banding filter */ - ov5640_set_bandingfilter(); - - /* set AE target */ - ov5640_set_AE_target(AE_Target); - - /* update night mode setting */ - ov5640_set_night_mode(night_mode); - - /* skip 9 vysnc: start capture at 10th vsync */ - if (mode == ov5640_mode_XGA_1024_768 && frame_rate == ov5640_30_fps) { - pr_warning("ov5640: actual frame rate of XGA is 22.5fps\n"); - /* 1/22.5 * 9*/ - msleep(400); - return retval; - } - - if (frame_rate == ov5640_15_fps) { - /* 1/15 * 9*/ - msleep(600); - } else if (frame_rate == ov5640_30_fps) { - /* 1/30 * 9*/ - msleep(300); - } - - return retval; -} - -/* change to scaling mode go through exposure calucation - * image size above 1280 * 960 is scaling mode */ -static int ov5640_change_mode_exposure_calc(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - int prev_shutter, prev_gain16, average; - int cap_shutter, cap_gain16; - int cap_sysclk, cap_HTS, cap_VTS; - int light_freq, cap_bandfilt, cap_maxband; - long cap_gain16_shutter; - u8 temp; - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - - /* check if the input mode and frame rate is valid */ - pModeSetting = - ov5640_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5640_mode_info_data[frame_rate][mode].init_data_size; - - ov5640_data.pix.width = - ov5640_mode_info_data[frame_rate][mode].width; - ov5640_data.pix.height = - ov5640_mode_info_data[frame_rate][mode].height; - - if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - /* read preview shutter */ - prev_shutter = ov5640_get_shutter(); - - /* read preview gain */ - prev_gain16 = ov5640_get_gain16(); - - /* get average */ - average = ov5640_read_reg(0x56a1, &temp); - - /* turn off night mode for capture */ - ov5640_set_night_mode(0); - - /* turn off overlay */ - ov5640_write_reg(0x3022, 0x06); - - /* Write capture setting */ - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - /* turn off AE AG when capture image. */ - ov5640_turn_on_AE_AG(0); - - /* read capture VTS */ - cap_VTS = ov5640_get_VTS(); - cap_HTS = ov5640_get_HTS(); - cap_sysclk = ov5640_get_sysclk(); - - /* calculate capture banding filter */ - light_freq = ov5640_get_light_freq(); - if (light_freq == 60) { - /* 60Hz */ - cap_bandfilt = cap_sysclk * 100 / cap_HTS * 100 / 120; - } else { - /* 50Hz */ - cap_bandfilt = cap_sysclk * 100 / cap_HTS; - } - cap_maxband = (int)((cap_VTS - 4)/cap_bandfilt); - /* calculate capture shutter/gain16 */ - if (average > AE_low && average < AE_high) { - /* in stable range */ - cap_gain16_shutter = - prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * - prev_HTS/cap_HTS * AE_Target / average; - } else { - cap_gain16_shutter = - prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * - prev_HTS/cap_HTS; - } - - /* gain to shutter */ - if (cap_gain16_shutter < (cap_bandfilt * 16)) { - /* shutter < 1/100 */ - cap_shutter = cap_gain16_shutter/16; - if (cap_shutter < 1) - cap_shutter = 1; - cap_gain16 = cap_gain16_shutter/cap_shutter; - if (cap_gain16 < 16) - cap_gain16 = 16; - } else { - if (cap_gain16_shutter > (cap_bandfilt*cap_maxband*16)) { - /* exposure reach max */ - cap_shutter = cap_bandfilt*cap_maxband; - cap_gain16 = cap_gain16_shutter / cap_shutter; - } else { - /* 1/100 < cap_shutter =< max, cap_shutter = n/100 */ - cap_shutter = - ((int)(cap_gain16_shutter/16/cap_bandfilt)) - * cap_bandfilt; - cap_gain16 = cap_gain16_shutter / cap_shutter; - } - } - - /* write capture gain */ - ov5640_set_gain16(cap_gain16); - - /* write capture shutter */ - if (cap_shutter > (cap_VTS - 4)) { - cap_VTS = cap_shutter + 4; - ov5640_set_VTS(cap_VTS); - } - - ov5640_set_shutter(cap_shutter); - - /* skip 2 vysnc: start capture at 3rd vsync - * frame rate of QSXGA and 1080P is 7.5fps: 1/7.5 * 2 - */ - pr_warning("ov5640: the actual frame rate of %s is 7.5fps\n", - mode == ov5640_mode_1080P_1920_1080 ? "1080P" : "QSXGA"); - msleep(267); -err: - return retval; -} - -static int ov5640_change_mode(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - int retval = 0; - - if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { - pr_err("Wrong ov5640 mode detected!\n"); - return -1; - } - - if (mode == ov5640_mode_1080P_1920_1080 || - mode == ov5640_mode_QSXGA_2592_1944) { - /* change to scaling mode go through exposure calucation - * image size above 1280 * 960 is scaling mode */ - retval = ov5640_change_mode_exposure_calc(frame_rate, mode); - } else { - /* change back to subsampling modem download firmware directly - * image size below 1280 * 960 is subsampling mode */ - retval = ov5640_change_mode_direct(frame_rate, mode); - } - - return retval; -} - -/* --------------- IOCTL functions from v4l2_int_ioctl_desc --------------- */ - -static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) -{ - if (s == NULL) { - pr_err(" ERROR!! no slave device set!\n"); - return -1; - } - - memset(p, 0, sizeof(*p)); - p->u.bt656.clock_curr = ov5640_data.mclk; - pr_debug(" clock_curr=mclk=%d\n", ov5640_data.mclk); - p->if_type = V4L2_IF_TYPE_BT656; - p->u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT; - p->u.bt656.clock_min = OV5640_XCLK_MIN; - p->u.bt656.clock_max = OV5640_XCLK_MAX; - p->u.bt656.bt_sync_correct = 1; /* Indicate external vsync */ - - return 0; -} - -/*! - * ioctl_s_power - V4L2 sensor interface handler for VIDIOC_S_POWER ioctl - * @s: pointer to standard V4L2 device structure - * @on: indicates power mode (on or off) - * - * Turns the power on or off, depending on the value of on and returns the - * appropriate error code. - */ -static int ioctl_s_power(struct v4l2_int_device *s, int on) -{ - struct sensor_data *sensor = s->priv; - - if (on && !sensor->on) { - if (io_regulator) - if (regulator_enable(io_regulator) != 0) - return -EIO; - if (core_regulator) - if (regulator_enable(core_regulator) != 0) - return -EIO; - if (analog_regulator) - if (regulator_enable(analog_regulator) != 0) - return -EIO; - /* Make sure power on */ - ov5640_power_down(0); - } else if (!on && sensor->on) { - if (analog_regulator) - regulator_disable(analog_regulator); - if (core_regulator) - regulator_disable(core_regulator); - if (io_regulator) - regulator_disable(io_regulator); - - ov5640_power_down(1); -} - - sensor->on = on; - - return 0; -} - -/*! - * ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure - * - * Returns the sensor's video CAPTURE parameters. - */ -static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - struct sensor_data *sensor = s->priv; - struct v4l2_captureparm *cparm = &a->parm.capture; - int ret = 0; - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - memset(a, 0, sizeof(*a)); - a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cparm->capability = sensor->streamcap.capability; - cparm->timeperframe = sensor->streamcap.timeperframe; - cparm->capturemode = sensor->streamcap.capturemode; - ret = 0; - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure - * - * Configures the sensor to use the input parameters, if possible. If - * not possible, reverts to the old parameters and returns the - * appropriate error code. - */ -static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - struct sensor_data *sensor = s->priv; - struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; - u32 tgt_fps; /* target frames per secound */ - enum ov5640_frame_rate frame_rate; - int ret = 0; - - /* Make sure power on */ - ov5640_power_down(0); - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - /* Check that the new frame rate is allowed. */ - if ((timeperframe->numerator == 0) || - (timeperframe->denominator == 0)) { - timeperframe->denominator = DEFAULT_FPS; - timeperframe->numerator = 1; - } - - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps > MAX_FPS) { - timeperframe->denominator = MAX_FPS; - timeperframe->numerator = 1; - } else if (tgt_fps < MIN_FPS) { - timeperframe->denominator = MIN_FPS; - timeperframe->numerator = 1; - } - - /* Actual frame rate we use */ - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps == 15) - frame_rate = ov5640_15_fps; - else if (tgt_fps == 30) - frame_rate = ov5640_30_fps; - else { - pr_err(" The camera frame rate is not supported!\n"); - return -EINVAL; - } - - ret = ov5640_change_mode(frame_rate, - a->parm.capture.capturemode); - if (ret < 0) - return ret; - - sensor->streamcap.timeperframe = *timeperframe; - sensor->streamcap.capturemode = a->parm.capture.capturemode; - - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - pr_debug(" type is not " \ - "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", - a->type); - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap - * @s: pointer to standard V4L2 device structure - * @f: pointer to standard V4L2 v4l2_format structure - * - * Returns the sensor's current pixel format in the v4l2_format - * parameter. - */ -static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) -{ - struct sensor_data *sensor = s->priv; - - f->fmt.pix = sensor->pix; - - return 0; -} - -/*! - * ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure - * - * If the requested control is supported, returns the control's current - * value from the video_control[] array. Otherwise, returns -EINVAL - * if the control is not supported. - */ -static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int ret = 0; - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - vc->value = ov5640_data.brightness; - break; - case V4L2_CID_HUE: - vc->value = ov5640_data.hue; - break; - case V4L2_CID_CONTRAST: - vc->value = ov5640_data.contrast; - break; - case V4L2_CID_SATURATION: - vc->value = ov5640_data.saturation; - break; - case V4L2_CID_RED_BALANCE: - vc->value = ov5640_data.red; - break; - case V4L2_CID_BLUE_BALANCE: - vc->value = ov5640_data.blue; - break; - case V4L2_CID_EXPOSURE: - vc->value = ov5640_data.ae_mode; - break; - default: - ret = -EINVAL; - } - - return ret; -} - -/*! - * ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure - * - * If the requested control is supported, sets the control's current - * value in HW (and updates the video_control[] array). Otherwise, - * returns -EINVAL if the control is not supported. - */ -static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int retval = 0; - - pr_debug("In ov5640:ioctl_s_ctrl %d\n", - vc->id); - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - break; - case V4L2_CID_CONTRAST: - break; - case V4L2_CID_SATURATION: - break; - case V4L2_CID_HUE: - break; - case V4L2_CID_AUTO_WHITE_BALANCE: - break; - case V4L2_CID_DO_WHITE_BALANCE: - break; - case V4L2_CID_RED_BALANCE: - break; - case V4L2_CID_BLUE_BALANCE: - break; - case V4L2_CID_GAMMA: - break; - case V4L2_CID_EXPOSURE: - break; - case V4L2_CID_AUTOGAIN: - break; - case V4L2_CID_GAIN: - break; - case V4L2_CID_HFLIP: - break; - case V4L2_CID_VFLIP: - break; - default: - retval = -EPERM; - break; - } - - return retval; -} - -/*! - * ioctl_enum_framesizes - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMESIZES ioctl - * @s: pointer to standard V4L2 device structure - * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_framesizes(struct v4l2_int_device *s, - struct v4l2_frmsizeenum *fsize) -{ - if (fsize->index > ov5640_mode_MAX) - return -EINVAL; - - fsize->pixel_format = ov5640_data.pix.pixelformat; - fsize->discrete.width = - max(ov5640_mode_info_data[0][fsize->index].width, - ov5640_mode_info_data[1][fsize->index].width); - fsize->discrete.height = - max(ov5640_mode_info_data[0][fsize->index].height, - ov5640_mode_info_data[1][fsize->index].height); - return 0; -} - -/*! - * ioctl_enum_frameintervals - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMEINTERVALS ioctl - * @s: pointer to standard V4L2 device structure - * @fival: standard V4L2 VIDIOC_ENUM_FRAMEINTERVALS ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_frameintervals(struct v4l2_int_device *s, - struct v4l2_frmivalenum *fival) -{ - int i, j, count; - - if (fival->index < 0 || fival->index > ov5640_mode_MAX) - return -EINVAL; - - if (fival->width == 0 || fival->height == 0 || - fival->pixel_format == 0) { - pr_warning("Please assign pixelformat, width and height.\n"); - return -EINVAL; - } - - fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; - fival->discrete.numerator = 1; - - count = 0; - for (i = 0; i < ARRAY_SIZE(ov5640_mode_info_data); i++) { - for (j = 0; j < (ov5640_mode_MAX + 1); j++) { - if (fival->pixel_format == ov5640_data.pix.pixelformat - && fival->width == ov5640_mode_info_data[i][j].width - && fival->height == ov5640_mode_info_data[i][j].height - && ov5640_mode_info_data[i][j].init_data_ptr != NULL) { - count++; - } - if (fival->index == (count - 1)) { - fival->discrete.denominator = - ov5640_framerates[i]; - return 0; - } - } - } - - return -EINVAL; -} - -/*! - * ioctl_g_chip_ident - V4L2 sensor interface handler for - * VIDIOC_DBG_G_CHIP_IDENT ioctl - * @s: pointer to standard V4L2 device structure - * @id: pointer to int - * - * Return 0. - */ -static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id) -{ - ((struct v4l2_dbg_chip_ident *)id)->match.type = - V4L2_CHIP_MATCH_I2C_DRIVER; - strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name, "ov5640_camera"); - - return 0; -} - -/*! - * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT - * @s: pointer to standard V4L2 device structure - */ -static int ioctl_init(struct v4l2_int_device *s) -{ - - return 0; -} - -/*! - * ioctl_enum_fmt_cap - V4L2 sensor interface handler for VIDIOC_ENUM_FMT - * @s: pointer to standard V4L2 device structure - * @fmt: pointer to standard V4L2 fmt description structure - * - * Return 0. - */ -static int ioctl_enum_fmt_cap(struct v4l2_int_device *s, - struct v4l2_fmtdesc *fmt) -{ - if (fmt->index > ov5640_mode_MAX) - return -EINVAL; - - fmt->pixelformat = ov5640_data.pix.pixelformat; - - return 0; -} - -/*! - * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num - * @s: pointer to standard V4L2 device structure - * - * Initialise the device when slave attaches to the master. - */ -static int ioctl_dev_init(struct v4l2_int_device *s) -{ - struct sensor_data *sensor = s->priv; - u32 tgt_xclk; /* target xclk */ - u32 tgt_fps; /* target frames per secound */ - enum ov5640_frame_rate frame_rate; - int ret; - - ov5640_data.on = true; - - /* mclk */ - tgt_xclk = ov5640_data.mclk; - tgt_xclk = min(tgt_xclk, (u32)OV5640_XCLK_MAX); - tgt_xclk = max(tgt_xclk, (u32)OV5640_XCLK_MIN); - ov5640_data.mclk = tgt_xclk; - - pr_debug(" Setting mclk to %d MHz\n", tgt_xclk / 1000000); - clk_set_rate(ov5640_data.sensor_clk, ov5640_data.mclk); - - /* Default camera frame rate is set in probe */ - tgt_fps = sensor->streamcap.timeperframe.denominator / - sensor->streamcap.timeperframe.numerator; - - if (tgt_fps == 15) - frame_rate = ov5640_15_fps; - else if (tgt_fps == 30) - frame_rate = ov5640_30_fps; - else - return -EINVAL; /* Only support 15fps or 30fps now. */ - - ret = ov5640_init_mode(); - return ret; -} - -/*! - * ioctl_dev_exit - V4L2 sensor interface handler for vidioc_int_dev_exit_num - * @s: pointer to standard V4L2 device structure - * - * Delinitialise the device when slave detaches to the master. - */ -static int ioctl_dev_exit(struct v4l2_int_device *s) -{ - return 0; -} - -/*! - * This structure defines all the ioctls for this module and links them to the - * enumeration. - */ -static struct v4l2_int_ioctl_desc ov5640_ioctl_desc[] = { - { vidioc_int_dev_init_num, - (v4l2_int_ioctl_func *)ioctl_dev_init }, - { vidioc_int_dev_exit_num, - ioctl_dev_exit}, - { vidioc_int_s_power_num, - (v4l2_int_ioctl_func *)ioctl_s_power }, - { vidioc_int_g_ifparm_num, - (v4l2_int_ioctl_func *)ioctl_g_ifparm }, - { vidioc_int_init_num, - (v4l2_int_ioctl_func *)ioctl_init }, - { vidioc_int_enum_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap }, - { vidioc_int_g_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_g_fmt_cap }, - { vidioc_int_g_parm_num, - (v4l2_int_ioctl_func *)ioctl_g_parm }, - { vidioc_int_s_parm_num, - (v4l2_int_ioctl_func *)ioctl_s_parm }, - { vidioc_int_g_ctrl_num, - (v4l2_int_ioctl_func *)ioctl_g_ctrl }, - { vidioc_int_s_ctrl_num, - (v4l2_int_ioctl_func *)ioctl_s_ctrl }, - { vidioc_int_enum_framesizes_num, - (v4l2_int_ioctl_func *)ioctl_enum_framesizes }, - { vidioc_int_enum_frameintervals_num, - (v4l2_int_ioctl_func *)ioctl_enum_frameintervals }, - { vidioc_int_g_chip_ident_num, - (v4l2_int_ioctl_func *)ioctl_g_chip_ident }, -}; - -static struct v4l2_int_slave ov5640_slave = { - .ioctls = ov5640_ioctl_desc, - .num_ioctls = ARRAY_SIZE(ov5640_ioctl_desc), -}; - -static struct v4l2_int_device ov5640_int_device = { - .module = THIS_MODULE, - .name = "ov564x", - .type = v4l2_int_type_slave, - .u = { - .slave = &ov5640_slave, - }, -}; - -/*! - * ov5640 I2C probe function - * - * @param adapter struct i2c_adapter * - * @return Error code indicating success or failure - */ -static int ov5640_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct pinctrl *pinctrl; - struct device *dev = &client->dev; - int retval; - u8 chip_id_high, chip_id_low; - - /* ov5640 pinctrl */ - pinctrl = devm_pinctrl_get_select_default(dev); - if (IS_ERR(pinctrl)) { - dev_err(dev, "setup pinctrl failed\n"); - return PTR_ERR(pinctrl); - } - - /* request power down pin */ - pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); - if (!gpio_is_valid(pwn_gpio)) { - dev_err(dev, "no sensor pwdn pin available\n"); - return -ENODEV; - } - retval = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_pwdn"); - if (retval < 0) - return retval; - - /* request reset pin */ - rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0); - if (!gpio_is_valid(rst_gpio)) { - dev_err(dev, "no sensor reset pin available\n"); - return -EINVAL; - } - retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_reset"); - if (retval < 0) - return retval; - - /* Set initial values for the sensor struct. */ - memset(&ov5640_data, 0, sizeof(ov5640_data)); - ov5640_data.sensor_clk = devm_clk_get(dev, "csi_mclk"); - if (IS_ERR(ov5640_data.sensor_clk)) { - dev_err(dev, "get mclk failed\n"); - return PTR_ERR(ov5640_data.sensor_clk); - } - - retval = of_property_read_u32(dev->of_node, "mclk", - &ov5640_data.mclk); - if (retval) { - dev_err(dev, "mclk frequency is invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "mclk_source", - (u32 *) &(ov5640_data.mclk_source)); - if (retval) { - dev_err(dev, "mclk_source invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "csi_id", - &(ov5640_data.csi)); - if (retval) { - dev_err(dev, "csi_id invalid\n"); - return retval; - } - - clk_prepare_enable(ov5640_data.sensor_clk); - - ov5640_data.io_init = ov5640_reset; - ov5640_data.i2c_client = client; - ov5640_data.pix.pixelformat = V4L2_PIX_FMT_YUYV; - ov5640_data.pix.width = 640; - ov5640_data.pix.height = 480; - ov5640_data.streamcap.capability = V4L2_MODE_HIGHQUALITY | - V4L2_CAP_TIMEPERFRAME; - ov5640_data.streamcap.capturemode = 0; - ov5640_data.streamcap.timeperframe.denominator = DEFAULT_FPS; - ov5640_data.streamcap.timeperframe.numerator = 1; - - ov5640_regulator_enable(&client->dev); - - ov5640_reset(); - - ov5640_power_down(0); - - retval = ov5640_read_reg(OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high); - if (retval < 0 || chip_id_high != 0x56) { - clk_disable_unprepare(ov5640_data.sensor_clk); - pr_warning("camera ov5640 is not found\n"); - return -ENODEV; - } - retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low); - if (retval < 0 || chip_id_low != 0x40) { - clk_disable_unprepare(ov5640_data.sensor_clk); - pr_warning("camera ov5640 is not found\n"); - return -ENODEV; - } - - ov5640_power_down(1); - - clk_disable_unprepare(ov5640_data.sensor_clk); - - ov5640_int_device.priv = &ov5640_data; - retval = v4l2_int_device_register(&ov5640_int_device); - - pr_info("camera ov5640 is found\n"); - return retval; -} - -/*! - * ov5640 I2C detach function - * - * @param client struct i2c_client * - * @return Error code indicating success or failure - */ -static int ov5640_remove(struct i2c_client *client) -{ - v4l2_int_device_unregister(&ov5640_int_device); - - if (analog_regulator) - regulator_disable(analog_regulator); - - if (core_regulator) - regulator_disable(core_regulator); - - if (io_regulator) - regulator_disable(io_regulator); - - return 0; -} - -module_i2c_driver(ov5640_i2c_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("OV5640 Camera Driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("CSI"); diff --git a/drivers/media/platform/mxc/capture/ov5640_mipi.c b/drivers/media/platform/mxc/capture/ov5640_mipi.c deleted file mode 100644 index 0d146b534f611e37c4c1b9826cd6771f688ffd80..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ov5640_mipi.c +++ /dev/null @@ -1,2142 +0,0 @@ -/* - * Copyright (C) 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * 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. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "v4l2-int-device.h" -#include "mxc_v4l2_capture.h" - -#define OV5640_VOLTAGE_ANALOG 2800000 -#define OV5640_VOLTAGE_DIGITAL_CORE 1500000 -#define OV5640_VOLTAGE_DIGITAL_IO 1800000 - -#define MIN_FPS 15 -#define MAX_FPS 30 -#define DEFAULT_FPS 30 - -#define OV5640_XCLK_MIN 6000000 -#define OV5640_XCLK_MAX 24000000 - -#define OV5640_CHIP_ID_HIGH_BYTE 0x300A -#define OV5640_CHIP_ID_LOW_BYTE 0x300B - -enum ov5640_mode { - ov5640_mode_MIN = 0, - ov5640_mode_VGA_640_480 = 0, - ov5640_mode_QVGA_320_240 = 1, - ov5640_mode_NTSC_720_480 = 2, - ov5640_mode_PAL_720_576 = 3, - ov5640_mode_720P_1280_720 = 4, - ov5640_mode_1080P_1920_1080 = 5, - ov5640_mode_QSXGA_2592_1944 = 6, - ov5640_mode_QCIF_176_144 = 7, - ov5640_mode_XGA_1024_768 = 8, - ov5640_mode_MAX = 8, - ov5640_mode_INIT = 0xff, /*only for sensor init*/ -}; - -enum ov5640_frame_rate { - ov5640_15_fps, - ov5640_30_fps -}; - -static int ov5640_framerates[] = { - [ov5640_15_fps] = 15, - [ov5640_30_fps] = 30, -}; - -/* image size under 1280 * 960 are SUBSAMPLING - * image size upper 1280 * 960 are SCALING - */ -enum ov5640_downsize_mode { - SUBSAMPLING, - SCALING, -}; - -struct reg_value { - u16 u16RegAddr; - u8 u8Val; - u8 u8Mask; - u32 u32Delay_ms; -}; - -struct ov5640_mode_info { - enum ov5640_mode mode; - enum ov5640_downsize_mode dn_mode; - u32 width; - u32 height; - struct reg_value *init_data_ptr; - u32 init_data_size; -}; - -/*! - * Maintains the information on the current state of the sesor. - */ -static struct sensor_data ov5640_data; -static int pwn_gpio, rst_gpio; - -static struct reg_value ov5640_init_setting_30fps_VGA[] = { - - {0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0}, - {0x3103, 0x03, 0, 0}, {0x3017, 0x00, 0, 0}, {0x3018, 0x00, 0, 0}, - {0x3034, 0x18, 0, 0}, {0x3035, 0x14, 0, 0}, {0x3036, 0x38, 0, 0}, - {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, {0x3630, 0x36, 0, 0}, - {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0}, - {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, - {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0}, - {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, {0x3906, 0x10, 0, 0}, - {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, {0x3600, 0x08, 0, 0}, - {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, {0x3620, 0x52, 0, 0}, - {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, {0x3a13, 0x43, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3635, 0x13, 0, 0}, - {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, {0x3622, 0x01, 0, 0}, - {0x3c01, 0xa4, 0, 0}, {0x3c04, 0x28, 0, 0}, {0x3c05, 0x98, 0, 0}, - {0x3c06, 0x00, 0, 0}, {0x3c07, 0x08, 0, 0}, {0x3c08, 0x00, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x300e, 0x45, 0, 0}, {0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, - {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x4837, 0x0a, 0, 0}, {0x4800, 0x04, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, - {0x5181, 0xf2, 0, 0}, {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, - {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0}, - {0x5187, 0x09, 0, 0}, {0x5188, 0x09, 0, 0}, {0x5189, 0x88, 0, 0}, - {0x518a, 0x54, 0, 0}, {0x518b, 0xee, 0, 0}, {0x518c, 0xb2, 0, 0}, - {0x518d, 0x50, 0, 0}, {0x518e, 0x34, 0, 0}, {0x518f, 0x6b, 0, 0}, - {0x5190, 0x46, 0, 0}, {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, - {0x5196, 0x03, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, - {0x5199, 0x6c, 0, 0}, {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, - {0x519c, 0x09, 0, 0}, {0x519d, 0x2b, 0, 0}, {0x519e, 0x38, 0, 0}, - {0x5381, 0x1e, 0, 0}, {0x5382, 0x5b, 0, 0}, {0x5383, 0x08, 0, 0}, - {0x5384, 0x0a, 0, 0}, {0x5385, 0x7e, 0, 0}, {0x5386, 0x88, 0, 0}, - {0x5387, 0x7c, 0, 0}, {0x5388, 0x6c, 0, 0}, {0x5389, 0x10, 0, 0}, - {0x538a, 0x01, 0, 0}, {0x538b, 0x98, 0, 0}, {0x5300, 0x08, 0, 0}, - {0x5301, 0x30, 0, 0}, {0x5302, 0x10, 0, 0}, {0x5303, 0x00, 0, 0}, - {0x5304, 0x08, 0, 0}, {0x5305, 0x30, 0, 0}, {0x5306, 0x08, 0, 0}, - {0x5307, 0x16, 0, 0}, {0x5309, 0x08, 0, 0}, {0x530a, 0x30, 0, 0}, - {0x530b, 0x04, 0, 0}, {0x530c, 0x06, 0, 0}, {0x5480, 0x01, 0, 0}, - {0x5481, 0x08, 0, 0}, {0x5482, 0x14, 0, 0}, {0x5483, 0x28, 0, 0}, - {0x5484, 0x51, 0, 0}, {0x5485, 0x65, 0, 0}, {0x5486, 0x71, 0, 0}, - {0x5487, 0x7d, 0, 0}, {0x5488, 0x87, 0, 0}, {0x5489, 0x91, 0, 0}, - {0x548a, 0x9a, 0, 0}, {0x548b, 0xaa, 0, 0}, {0x548c, 0xb8, 0, 0}, - {0x548d, 0xcd, 0, 0}, {0x548e, 0xdd, 0, 0}, {0x548f, 0xea, 0, 0}, - {0x5490, 0x1d, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x10, 0, 0}, {0x5589, 0x10, 0, 0}, {0x558a, 0x00, 0, 0}, - {0x558b, 0xf8, 0, 0}, {0x5800, 0x23, 0, 0}, {0x5801, 0x14, 0, 0}, - {0x5802, 0x0f, 0, 0}, {0x5803, 0x0f, 0, 0}, {0x5804, 0x12, 0, 0}, - {0x5805, 0x26, 0, 0}, {0x5806, 0x0c, 0, 0}, {0x5807, 0x08, 0, 0}, - {0x5808, 0x05, 0, 0}, {0x5809, 0x05, 0, 0}, {0x580a, 0x08, 0, 0}, - {0x580b, 0x0d, 0, 0}, {0x580c, 0x08, 0, 0}, {0x580d, 0x03, 0, 0}, - {0x580e, 0x00, 0, 0}, {0x580f, 0x00, 0, 0}, {0x5810, 0x03, 0, 0}, - {0x5811, 0x09, 0, 0}, {0x5812, 0x07, 0, 0}, {0x5813, 0x03, 0, 0}, - {0x5814, 0x00, 0, 0}, {0x5815, 0x01, 0, 0}, {0x5816, 0x03, 0, 0}, - {0x5817, 0x08, 0, 0}, {0x5818, 0x0d, 0, 0}, {0x5819, 0x08, 0, 0}, - {0x581a, 0x05, 0, 0}, {0x581b, 0x06, 0, 0}, {0x581c, 0x08, 0, 0}, - {0x581d, 0x0e, 0, 0}, {0x581e, 0x29, 0, 0}, {0x581f, 0x17, 0, 0}, - {0x5820, 0x11, 0, 0}, {0x5821, 0x11, 0, 0}, {0x5822, 0x15, 0, 0}, - {0x5823, 0x28, 0, 0}, {0x5824, 0x46, 0, 0}, {0x5825, 0x26, 0, 0}, - {0x5826, 0x08, 0, 0}, {0x5827, 0x26, 0, 0}, {0x5828, 0x64, 0, 0}, - {0x5829, 0x26, 0, 0}, {0x582a, 0x24, 0, 0}, {0x582b, 0x22, 0, 0}, - {0x582c, 0x24, 0, 0}, {0x582d, 0x24, 0, 0}, {0x582e, 0x06, 0, 0}, - {0x582f, 0x22, 0, 0}, {0x5830, 0x40, 0, 0}, {0x5831, 0x42, 0, 0}, - {0x5832, 0x24, 0, 0}, {0x5833, 0x26, 0, 0}, {0x5834, 0x24, 0, 0}, - {0x5835, 0x22, 0, 0}, {0x5836, 0x22, 0, 0}, {0x5837, 0x26, 0, 0}, - {0x5838, 0x44, 0, 0}, {0x5839, 0x24, 0, 0}, {0x583a, 0x26, 0, 0}, - {0x583b, 0x28, 0, 0}, {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0}, - {0x5025, 0x00, 0, 0}, {0x3a0f, 0x30, 0, 0}, {0x3a10, 0x28, 0, 0}, - {0x3a1b, 0x30, 0, 0}, {0x3a1e, 0x26, 0, 0}, {0x3a11, 0x60, 0, 0}, - {0x3a1f, 0x14, 0, 0}, {0x3008, 0x02, 0, 0}, {0x3c00, 0x04, 0, 300}, -}; - -static struct reg_value ov5640_setting_30fps_VGA_640_480[] = { - - {0x3035, 0x14, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x04, 0, 0}, {0x380f, 0x38, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x0e, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_VGA_640_480[] = { - {0x3035, 0x22, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_XGA_1024_768[] = { - - {0x3035, 0x14, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x04, 0, 0}, {0x380f, 0x38, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x0e, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x3503, 0x00, 0, 0}, - {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x03, 0, 0}, - {0x380b, 0x00, 0, 0}, {0x3035, 0x12, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_XGA_1024_768[] = { - {0x3035, 0x22, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x3808, 0x04, 0, 0}, - {0x3809, 0x00, 0, 0}, {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_QVGA_320_240[] = { - {0x3035, 0x14, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QVGA_320_240[] = { - {0x3035, 0x22, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_QCIF_176_144[] = { - {0x3035, 0x14, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; -static struct reg_value ov5640_setting_15fps_QCIF_176_144[] = { - {0x3035, 0x22, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_NTSC_720_480[] = { - {0x3035, 0x12, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x3c, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_NTSC_720_480[] = { - {0x3035, 0x22, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x3c, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_PAL_720_576[] = { - {0x3035, 0x12, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x38, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_PAL_720_576[] = { - {0x3035, 0x22, 0, 0}, {0x3036, 0x38, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x38, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_720P_1280_720[] = { - {0x3008, 0x42, 0, 0}, - {0x3035, 0x21, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, - {0x3a03, 0xe4, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0xbc, 0, 0}, - {0x3a0a, 0x01, 0, 0}, {0x3a0b, 0x72, 0, 0}, {0x3a0e, 0x01, 0, 0}, - {0x3a0d, 0x02, 0, 0}, {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe4, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x02, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, - {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, {0x4005, 0x1a, 0, 0}, - {0x3008, 0x02, 0, 0}, {0x3503, 0, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_720P_1280_720[] = { - {0x3035, 0x41, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, - {0x3a03, 0xe4, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0xbc, 0, 0}, - {0x3a0a, 0x01, 0, 0}, {0x3a0b, 0x72, 0, 0}, {0x3a0e, 0x01, 0, 0}, - {0x3a0d, 0x02, 0, 0}, {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe4, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4713, 0x02, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, - {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_1080P_1920_1080[] = { - {0x3008, 0x42, 0, 0}, - {0x3035, 0x21, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, {0x3814, 0x11, 0, 0}, - {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9f, 0, 0}, - {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, - {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, {0x380d, 0x1c, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x04, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x21, 0, 0}, - {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x06, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0x83, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x54, 0, 0}, {0x3c07, 0x07, 0, 0}, {0x3c08, 0x00, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3800, 0x01, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3802, 0x01, 0, 0}, - {0x3803, 0xb2, 0, 0}, {0x3804, 0x08, 0, 0}, {0x3805, 0xef, 0, 0}, - {0x3806, 0x05, 0, 0}, {0x3807, 0xf1, 0, 0}, {0x3808, 0x07, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0}, - {0x380c, 0x09, 0, 0}, {0x380d, 0xc4, 0, 0}, {0x380e, 0x04, 0, 0}, - {0x380f, 0x60, 0, 0}, {0x3612, 0x2b, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3a02, 0x04, 0, 0}, {0x3a03, 0x60, 0, 0}, {0x3a08, 0x01, 0, 0}, - {0x3a09, 0x50, 0, 0}, {0x3a0a, 0x01, 0, 0}, {0x3a0b, 0x18, 0, 0}, - {0x3a0e, 0x03, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x04, 0, 0}, - {0x3a15, 0x60, 0, 0}, {0x4713, 0x02, 0, 0}, {0x4407, 0x04, 0, 0}, - {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3824, 0x04, 0, 0}, - {0x4005, 0x1a, 0, 0}, {0x3008, 0x02, 0, 0}, - {0x3503, 0, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_1080P_1920_1080[] = { - {0x3008, 0x42, 0, 0}, - {0x3035, 0x21, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, {0x3814, 0x11, 0, 0}, - {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9f, 0, 0}, - {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, - {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, {0x380d, 0x1c, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x04, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x21, 0, 0}, - {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x06, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0x83, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x54, 0, 1}, {0x3c07, 0x07, 0, 0}, {0x3c08, 0x00, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3800, 0x01, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3802, 0x01, 0, 0}, - {0x3803, 0xb2, 0, 0}, {0x3804, 0x08, 0, 0}, {0x3805, 0xef, 0, 0}, - {0x3806, 0x05, 0, 0}, {0x3807, 0xf1, 0, 0}, {0x3808, 0x07, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0}, - {0x380c, 0x09, 0, 0}, {0x380d, 0xc4, 0, 0}, {0x380e, 0x04, 0, 0}, - {0x380f, 0x60, 0, 0}, {0x3612, 0x2b, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3a02, 0x04, 0, 0}, {0x3a03, 0x60, 0, 0}, {0x3a08, 0x01, 0, 0}, - {0x3a09, 0x50, 0, 0}, {0x3a0a, 0x01, 0, 0}, {0x3a0b, 0x18, 0, 0}, - {0x3a0e, 0x03, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x04, 0, 0}, - {0x3a15, 0x60, 0, 0}, {0x4713, 0x02, 0, 0}, {0x4407, 0x04, 0, 0}, - {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3824, 0x04, 0, 0}, - {0x4005, 0x1a, 0, 0}, {0x3008, 0x02, 0, 0}, {0x3503, 0, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = { - {0x4202, 0x0f, 0, 0}, /* stream off the sensor */ - {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, /*disable flip*/ - {0x3035, 0x21, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x08, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, {0x3814, 0x11, 0, 0}, - {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9f, 0, 0}, - {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, - {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, {0x380d, 0x1c, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x04, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x21, 0, 0}, - {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x06, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x3824, 0x02, 0, 0}, {0x5001, 0x83, 0, 70}, - {0x4202, 0x00, 0, 0}, /* stream on the sensor */ -}; - -static struct ov5640_mode_info ov5640_mode_info_data[2][ov5640_mode_MAX + 1] = { - { - {ov5640_mode_VGA_640_480, SUBSAMPLING, 640, 480, - ov5640_setting_15fps_VGA_640_480, - ARRAY_SIZE(ov5640_setting_15fps_VGA_640_480)}, - {ov5640_mode_QVGA_320_240, SUBSAMPLING, 320, 240, - ov5640_setting_15fps_QVGA_320_240, - ARRAY_SIZE(ov5640_setting_15fps_QVGA_320_240)}, - {ov5640_mode_NTSC_720_480, SUBSAMPLING, 720, 480, - ov5640_setting_15fps_NTSC_720_480, - ARRAY_SIZE(ov5640_setting_15fps_NTSC_720_480)}, - {ov5640_mode_PAL_720_576, SUBSAMPLING, 720, 576, - ov5640_setting_15fps_PAL_720_576, - ARRAY_SIZE(ov5640_setting_15fps_PAL_720_576)}, - {ov5640_mode_720P_1280_720, SUBSAMPLING, 1280, 720, - ov5640_setting_15fps_720P_1280_720, - ARRAY_SIZE(ov5640_setting_15fps_720P_1280_720)}, - {ov5640_mode_1080P_1920_1080, SCALING, 1920, 1080, - ov5640_setting_15fps_1080P_1920_1080, - ARRAY_SIZE(ov5640_setting_15fps_1080P_1920_1080)}, - {ov5640_mode_QSXGA_2592_1944, SCALING, 2592, 1944, - ov5640_setting_15fps_QSXGA_2592_1944, - ARRAY_SIZE(ov5640_setting_15fps_QSXGA_2592_1944)}, - {ov5640_mode_QCIF_176_144, SUBSAMPLING, 176, 144, - ov5640_setting_15fps_QCIF_176_144, - ARRAY_SIZE(ov5640_setting_15fps_QCIF_176_144)}, - {ov5640_mode_XGA_1024_768, SUBSAMPLING, 1024, 768, - ov5640_setting_15fps_XGA_1024_768, - ARRAY_SIZE(ov5640_setting_15fps_XGA_1024_768)}, - }, - { - {ov5640_mode_VGA_640_480, SUBSAMPLING, 640, 480, - ov5640_setting_30fps_VGA_640_480, - ARRAY_SIZE(ov5640_setting_30fps_VGA_640_480)}, - {ov5640_mode_QVGA_320_240, SUBSAMPLING, 320, 240, - ov5640_setting_30fps_QVGA_320_240, - ARRAY_SIZE(ov5640_setting_30fps_QVGA_320_240)}, - {ov5640_mode_NTSC_720_480, SUBSAMPLING, 720, 480, - ov5640_setting_30fps_NTSC_720_480, - ARRAY_SIZE(ov5640_setting_30fps_NTSC_720_480)}, - {ov5640_mode_PAL_720_576, SUBSAMPLING, 720, 576, - ov5640_setting_30fps_PAL_720_576, - ARRAY_SIZE(ov5640_setting_30fps_PAL_720_576)}, - {ov5640_mode_720P_1280_720, SUBSAMPLING, 1280, 720, - ov5640_setting_30fps_720P_1280_720, - ARRAY_SIZE(ov5640_setting_30fps_720P_1280_720)}, - {ov5640_mode_1080P_1920_1080, SCALING, 1920, 1080, - ov5640_setting_30fps_1080P_1920_1080, - ARRAY_SIZE(ov5640_setting_30fps_1080P_1920_1080)}, - {ov5640_mode_QSXGA_2592_1944, -1, 0, 0, NULL, 0}, - {ov5640_mode_QCIF_176_144, SUBSAMPLING, 176, 144, - ov5640_setting_30fps_QCIF_176_144, - ARRAY_SIZE(ov5640_setting_30fps_QCIF_176_144)}, - {ov5640_mode_XGA_1024_768, SUBSAMPLING, 1024, 768, - ov5640_setting_30fps_XGA_1024_768, - ARRAY_SIZE(ov5640_setting_30fps_XGA_1024_768)}, - }, -}; - -static struct regulator *io_regulator; -static struct regulator *core_regulator; -static struct regulator *analog_regulator; -static struct regulator *gpo_regulator; - -static int ov5640_probe(struct i2c_client *adapter, - const struct i2c_device_id *device_id); -static int ov5640_remove(struct i2c_client *client); - -static s32 ov5640_read_reg(u16 reg, u8 *val); -static s32 ov5640_write_reg(u16 reg, u8 val); - -static const struct i2c_device_id ov5640_id[] = { - {"ov564x_mipi", 0}, - {}, -}; - -MODULE_DEVICE_TABLE(i2c, ov5640_id); - -static struct i2c_driver ov5640_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "ov564x_mipi", - }, - .probe = ov5640_probe, - .remove = ov5640_remove, - .id_table = ov5640_id, -}; - -static void ov5640_standby(s32 enable) -{ - if (enable) - gpio_set_value(pwn_gpio, 1); - else - gpio_set_value(pwn_gpio, 0); - - msleep(100); -} - -static void ov5640_reset(void) -{ - /* camera reset */ - gpio_set_value(rst_gpio, 1); - - /* camera power dowmn */ - gpio_set_value(pwn_gpio, 1); - msleep(5); - - gpio_set_value(pwn_gpio, 0); - msleep(5); - - gpio_set_value(rst_gpio, 0); - msleep(1); - - gpio_set_value(rst_gpio, 1); - msleep(5); - - gpio_set_value(pwn_gpio, 1); -} - -static int ov5640_power_on(struct device *dev) -{ - int ret = 0; - - io_regulator = devm_regulator_get(dev, "DOVDD"); - if (!IS_ERR(io_regulator)) { - regulator_set_voltage(io_regulator, - OV5640_VOLTAGE_DIGITAL_IO, - OV5640_VOLTAGE_DIGITAL_IO); - ret = regulator_enable(io_regulator); - if (ret) { - pr_err("%s:io set voltage error\n", __func__); - return ret; - } else { - dev_dbg(dev, - "%s:io set voltage ok\n", __func__); - } - } else { - pr_err("%s: cannot get io voltage error\n", __func__); - io_regulator = NULL; - } - - core_regulator = devm_regulator_get(dev, "DVDD"); - if (!IS_ERR(core_regulator)) { - regulator_set_voltage(core_regulator, - OV5640_VOLTAGE_DIGITAL_CORE, - OV5640_VOLTAGE_DIGITAL_CORE); - ret = regulator_enable(core_regulator); - if (ret) { - pr_err("%s:core set voltage error\n", __func__); - return ret; - } else { - dev_dbg(dev, - "%s:core set voltage ok\n", __func__); - } - } else { - core_regulator = NULL; - pr_err("%s: cannot get core voltage error\n", __func__); - } - - analog_regulator = devm_regulator_get(dev, "AVDD"); - if (!IS_ERR(analog_regulator)) { - regulator_set_voltage(analog_regulator, - OV5640_VOLTAGE_ANALOG, - OV5640_VOLTAGE_ANALOG); - ret = regulator_enable(analog_regulator); - if (ret) { - pr_err("%s:analog set voltage error\n", - __func__); - return ret; - } else { - dev_dbg(dev, - "%s:analog set voltage ok\n", __func__); - } - } else { - analog_regulator = NULL; - pr_err("%s: cannot get analog voltage error\n", __func__); - } - - return ret; -} - -static s32 ov5640_write_reg(u16 reg, u8 val) -{ - u8 au8Buf[3] = {0}; - - au8Buf[0] = reg >> 8; - au8Buf[1] = reg & 0xff; - au8Buf[2] = val; - - if (i2c_master_send(ov5640_data.i2c_client, au8Buf, 3) < 0) { - pr_err("%s:write reg error:reg=%x,val=%x\n", - __func__, reg, val); - return -1; - } - - return 0; -} - -static s32 ov5640_read_reg(u16 reg, u8 *val) -{ - u8 au8RegBuf[2] = {0}; - u8 u8RdVal = 0; - - au8RegBuf[0] = reg >> 8; - au8RegBuf[1] = reg & 0xff; - - if (2 != i2c_master_send(ov5640_data.i2c_client, au8RegBuf, 2)) { - pr_err("%s:write reg error:reg=%x\n", - __func__, reg); - return -1; - } - - if (1 != i2c_master_recv(ov5640_data.i2c_client, &u8RdVal, 1)) { - pr_err("%s:read reg error:reg=%x,val=%x\n", - __func__, reg, u8RdVal); - return -1; - } - - *val = u8RdVal; - - return u8RdVal; -} - -static int prev_sysclk, prev_HTS; -static int AE_low, AE_high, AE_Target = 52; - -static void OV5640_stream_on(void) -{ - ov5640_write_reg(0x4202, 0x00); -} - -static void OV5640_stream_off(void) -{ - ov5640_write_reg(0x4202, 0x0f); -} - - -static int OV5640_get_sysclk(void) -{ - /* calculate sysclk */ - int xvclk = ov5640_data.mclk / 10000; - int temp1, temp2; - int Multiplier, PreDiv, VCO, SysDiv, Pll_rdiv; - int Bit_div2x = 1, sclk_rdiv, sysclk; - u8 temp; - - int sclk_rdiv_map[] = {1, 2, 4, 8}; - - temp1 = ov5640_read_reg(0x3034, &temp); - temp2 = temp1 & 0x0f; - if (temp2 == 8 || temp2 == 10) - Bit_div2x = temp2 / 2; - - temp1 = ov5640_read_reg(0x3035, &temp); - SysDiv = temp1>>4; - if (SysDiv == 0) - SysDiv = 16; - - temp1 = ov5640_read_reg(0x3036, &temp); - Multiplier = temp1; - - temp1 = ov5640_read_reg(0x3037, &temp); - PreDiv = temp1 & 0x0f; - Pll_rdiv = ((temp1 >> 4) & 0x01) + 1; - - temp1 = ov5640_read_reg(0x3108, &temp); - temp2 = temp1 & 0x03; - sclk_rdiv = sclk_rdiv_map[temp2]; - - VCO = xvclk * Multiplier / PreDiv; - - sysclk = VCO / SysDiv / Pll_rdiv * 2 / Bit_div2x / sclk_rdiv; - - return sysclk; -} - -static void OV5640_set_night_mode(void) -{ - /* read HTS from register settings */ - u8 mode; - - ov5640_read_reg(0x3a00, &mode); - mode &= 0xfb; - ov5640_write_reg(0x3a00, mode); -} - -static int OV5640_get_HTS(void) -{ - /* read HTS from register settings */ - int HTS; - u8 temp; - - HTS = ov5640_read_reg(0x380c, &temp); - HTS = (HTS<<8) + ov5640_read_reg(0x380d, &temp); - - return HTS; -} - -static int OV5640_get_VTS(void) -{ - /* read VTS from register settings */ - int VTS; - u8 temp; - - /* total vertical size[15:8] high byte */ - VTS = ov5640_read_reg(0x380e, &temp); - - VTS = (VTS<<8) + ov5640_read_reg(0x380f, &temp); - - return VTS; -} - -static int OV5640_set_VTS(int VTS) -{ - /* write VTS to registers */ - int temp; - - temp = VTS & 0xff; - ov5640_write_reg(0x380f, temp); - - temp = VTS>>8; - ov5640_write_reg(0x380e, temp); - - return 0; -} - -static int OV5640_get_shutter(void) -{ - /* read shutter, in number of line period */ - int shutter; - u8 temp; - - shutter = (ov5640_read_reg(0x03500, &temp) & 0x0f); - shutter = (shutter<<8) + ov5640_read_reg(0x3501, &temp); - shutter = (shutter<<4) + (ov5640_read_reg(0x3502, &temp)>>4); - - return shutter; -} - -static int OV5640_set_shutter(int shutter) -{ - /* write shutter, in number of line period */ - int temp; - - shutter = shutter & 0xffff; - - temp = shutter & 0x0f; - temp = temp<<4; - ov5640_write_reg(0x3502, temp); - - temp = shutter & 0xfff; - temp = temp>>4; - ov5640_write_reg(0x3501, temp); - - temp = shutter>>12; - ov5640_write_reg(0x3500, temp); - - return 0; -} - -static int OV5640_get_gain16(void) -{ - /* read gain, 16 = 1x */ - int gain16; - u8 temp; - - gain16 = ov5640_read_reg(0x350a, &temp) & 0x03; - gain16 = (gain16<<8) + ov5640_read_reg(0x350b, &temp); - - return gain16; -} - -static int OV5640_set_gain16(int gain16) -{ - /* write gain, 16 = 1x */ - u8 temp; - gain16 = gain16 & 0x3ff; - - temp = gain16 & 0xff; - ov5640_write_reg(0x350b, temp); - - temp = gain16>>8; - ov5640_write_reg(0x350a, temp); - - return 0; -} - -static int OV5640_get_light_freq(void) -{ - /* get banding filter value */ - int temp, temp1, light_freq = 0; - u8 tmp; - - temp = ov5640_read_reg(0x3c01, &tmp); - - if (temp & 0x80) { - /* manual */ - temp1 = ov5640_read_reg(0x3c00, &tmp); - if (temp1 & 0x04) { - /* 50Hz */ - light_freq = 50; - } else { - /* 60Hz */ - light_freq = 60; - } - } else { - /* auto */ - temp1 = ov5640_read_reg(0x3c0c, &tmp); - if (temp1 & 0x01) { - /* 50Hz */ - light_freq = 50; - } else { - /* 60Hz */ - } - } - return light_freq; -} - -static void OV5640_set_bandingfilter(void) -{ - int prev_VTS; - int band_step60, max_band60, band_step50, max_band50; - - /* read preview PCLK */ - prev_sysclk = OV5640_get_sysclk(); - /* read preview HTS */ - prev_HTS = OV5640_get_HTS(); - - /* read preview VTS */ - prev_VTS = OV5640_get_VTS(); - - /* calculate banding filter */ - /* 60Hz */ - band_step60 = prev_sysclk * 100/prev_HTS * 100/120; - ov5640_write_reg(0x3a0a, (band_step60 >> 8)); - ov5640_write_reg(0x3a0b, (band_step60 & 0xff)); - - max_band60 = (int)((prev_VTS-4)/band_step60); - ov5640_write_reg(0x3a0d, max_band60); - - /* 50Hz */ - band_step50 = prev_sysclk * 100/prev_HTS; - ov5640_write_reg(0x3a08, (band_step50 >> 8)); - ov5640_write_reg(0x3a09, (band_step50 & 0xff)); - - max_band50 = (int)((prev_VTS-4)/band_step50); - ov5640_write_reg(0x3a0e, max_band50); -} - -static int OV5640_set_AE_target(int target) -{ - /* stable in high */ - int fast_high, fast_low; - AE_low = target * 23 / 25; /* 0.92 */ - AE_high = target * 27 / 25; /* 1.08 */ - - fast_high = AE_high<<1; - if (fast_high > 255) - fast_high = 255; - - fast_low = AE_low >> 1; - - ov5640_write_reg(0x3a0f, AE_high); - ov5640_write_reg(0x3a10, AE_low); - ov5640_write_reg(0x3a1b, AE_high); - ov5640_write_reg(0x3a1e, AE_low); - ov5640_write_reg(0x3a11, fast_high); - ov5640_write_reg(0x3a1f, fast_low); - - return 0; -} - -static void OV5640_turn_on_AE_AG(int enable) -{ - u8 ae_ag_ctrl; - - ov5640_read_reg(0x3503, &ae_ag_ctrl); - if (enable) { - /* turn on auto AE/AG */ - ae_ag_ctrl = ae_ag_ctrl & ~(0x03); - } else { - /* turn off AE/AG */ - ae_ag_ctrl = ae_ag_ctrl | 0x03; - } - ov5640_write_reg(0x3503, ae_ag_ctrl); -} - -static bool binning_on(void) -{ - u8 temp; - ov5640_read_reg(0x3821, &temp); - temp &= 0xfe; - if (temp) - return true; - else - return false; -} - -static void ov5640_set_virtual_channel(int channel) -{ - u8 channel_id; - - ov5640_read_reg(0x4814, &channel_id); - channel_id &= ~(3 << 6); - ov5640_write_reg(0x4814, channel_id | (channel << 6)); -} - -/* download ov5640 settings to sensor through i2c */ -static int ov5640_download_firmware(struct reg_value *pModeSetting, s32 ArySize) -{ - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int i, retval = 0; - - for (i = 0; i < ArySize; ++i, ++pModeSetting) { - Delay_ms = pModeSetting->u32Delay_ms; - RegAddr = pModeSetting->u16RegAddr; - Val = pModeSetting->u8Val; - Mask = pModeSetting->u8Mask; - - if (Mask) { - retval = ov5640_read_reg(RegAddr, &RegVal); - if (retval < 0) - goto err; - - RegVal &= ~(u8)Mask; - Val &= Mask; - Val |= RegVal; - } - - retval = ov5640_write_reg(RegAddr, Val); - if (retval < 0) - goto err; - - if (Delay_ms) - msleep(Delay_ms); - } -err: - return retval; -} - -/* sensor changes between scaling and subsampling - * go through exposure calcualtion - */ -static int ov5640_change_mode_exposure_calc(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - u8 average; - int prev_shutter, prev_gain16; - int cap_shutter, cap_gain16; - int cap_sysclk, cap_HTS, cap_VTS; - int light_freq, cap_bandfilt, cap_maxband; - long cap_gain16_shutter; - int retval = 0; - - /* check if the input mode and frame rate is valid */ - pModeSetting = - ov5640_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5640_mode_info_data[frame_rate][mode].init_data_size; - - ov5640_data.pix.width = - ov5640_mode_info_data[frame_rate][mode].width; - ov5640_data.pix.height = - ov5640_mode_info_data[frame_rate][mode].height; - - if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - /* auto focus */ - /* OV5640_auto_focus();//if no af function, just skip it */ - - /* turn off AE/AG */ - OV5640_turn_on_AE_AG(0); - - /* read preview shutter */ - prev_shutter = OV5640_get_shutter(); - if ((binning_on()) && (mode != ov5640_mode_720P_1280_720) - && (mode != ov5640_mode_1080P_1920_1080)) - prev_shutter *= 2; - - /* read preview gain */ - prev_gain16 = OV5640_get_gain16(); - - /* get average */ - ov5640_read_reg(0x56a1, &average); - - /* turn off night mode for capture */ - OV5640_set_night_mode(); - - /* turn off overlay */ - /* ov5640_write_reg(0x3022, 0x06);//if no af function, just skip it */ - - OV5640_stream_off(); - - /* Write capture setting */ - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - /* read capture VTS */ - cap_VTS = OV5640_get_VTS(); - cap_HTS = OV5640_get_HTS(); - cap_sysclk = OV5640_get_sysclk(); - - /* calculate capture banding filter */ - light_freq = OV5640_get_light_freq(); - if (light_freq == 60) { - /* 60Hz */ - cap_bandfilt = cap_sysclk * 100 / cap_HTS * 100 / 120; - } else { - /* 50Hz */ - cap_bandfilt = cap_sysclk * 100 / cap_HTS; - } - cap_maxband = (int)((cap_VTS - 4)/cap_bandfilt); - - /* calculate capture shutter/gain16 */ - if (average > AE_low && average < AE_high) { - /* in stable range */ - cap_gain16_shutter = - prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk - * prev_HTS/cap_HTS * AE_Target / average; - } else { - cap_gain16_shutter = - prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk - * prev_HTS/cap_HTS; - } - - /* gain to shutter */ - if (cap_gain16_shutter < (cap_bandfilt * 16)) { - /* shutter < 1/100 */ - cap_shutter = cap_gain16_shutter/16; - if (cap_shutter < 1) - cap_shutter = 1; - - cap_gain16 = cap_gain16_shutter/cap_shutter; - if (cap_gain16 < 16) - cap_gain16 = 16; - } else { - if (cap_gain16_shutter > - (cap_bandfilt * cap_maxband * 16)) { - /* exposure reach max */ - cap_shutter = cap_bandfilt * cap_maxband; - cap_gain16 = cap_gain16_shutter / cap_shutter; - } else { - /* 1/100 < (cap_shutter = n/100) =< max */ - cap_shutter = - ((int) (cap_gain16_shutter/16 / cap_bandfilt)) - *cap_bandfilt; - cap_gain16 = cap_gain16_shutter / cap_shutter; - } - } - - /* write capture gain */ - OV5640_set_gain16(cap_gain16); - - /* write capture shutter */ - if (cap_shutter > (cap_VTS - 4)) { - cap_VTS = cap_shutter + 4; - OV5640_set_VTS(cap_VTS); - } - OV5640_set_shutter(cap_shutter); - - OV5640_stream_on(); - -err: - return retval; -} - -/* if sensor changes inside scaling or subsampling - * change mode directly - * */ -static int ov5640_change_mode_direct(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - - /* check if the input mode and frame rate is valid */ - pModeSetting = - ov5640_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5640_mode_info_data[frame_rate][mode].init_data_size; - - ov5640_data.pix.width = - ov5640_mode_info_data[frame_rate][mode].width; - ov5640_data.pix.height = - ov5640_mode_info_data[frame_rate][mode].height; - - if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - /* turn off AE/AG */ - OV5640_turn_on_AE_AG(0); - - OV5640_stream_off(); - - /* Write capture setting */ - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - OV5640_stream_on(); - - OV5640_turn_on_AE_AG(1); - -err: - return retval; -} - -static int ov5640_init_mode(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode, enum ov5640_mode orig_mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - void *mipi_csi2_info; - u32 mipi_reg, msec_wait4stable = 0; - enum ov5640_downsize_mode dn_mode, orig_dn_mode; - - if ((mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) - && (mode != ov5640_mode_INIT)) { - pr_err("Wrong ov5640 mode detected!\n"); - return -1; - } - - mipi_csi2_info = mipi_csi2_get_info(); - - /* initial mipi dphy */ - if (!mipi_csi2_info) { - printk(KERN_ERR "%s() in %s: Fail to get mipi_csi2_info!\n", - __func__, __FILE__); - return -1; - } - - if (!mipi_csi2_get_status(mipi_csi2_info)) - mipi_csi2_enable(mipi_csi2_info); - - if (!mipi_csi2_get_status(mipi_csi2_info)) { - pr_err("Can not enable mipi csi2 driver!\n"); - return -1; - } - - mipi_csi2_set_lanes(mipi_csi2_info); - - /*Only reset MIPI CSI2 HW at sensor initialize*/ - if (mode == ov5640_mode_INIT) - mipi_csi2_reset(mipi_csi2_info); - - if (ov5640_data.pix.pixelformat == V4L2_PIX_FMT_UYVY) - mipi_csi2_set_datatype(mipi_csi2_info, MIPI_DT_YUV422); - else if (ov5640_data.pix.pixelformat == V4L2_PIX_FMT_RGB565) - mipi_csi2_set_datatype(mipi_csi2_info, MIPI_DT_RGB565); - else - pr_err("currently this sensor format can not be supported!\n"); - - dn_mode = ov5640_mode_info_data[frame_rate][mode].dn_mode; - orig_dn_mode = ov5640_mode_info_data[frame_rate][orig_mode].dn_mode; - if (mode == ov5640_mode_INIT) { - pModeSetting = ov5640_init_setting_30fps_VGA; - ArySize = ARRAY_SIZE(ov5640_init_setting_30fps_VGA); - - ov5640_data.pix.width = 640; - ov5640_data.pix.height = 480; - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - pModeSetting = ov5640_setting_30fps_VGA_640_480; - ArySize = ARRAY_SIZE(ov5640_setting_30fps_VGA_640_480); - retval = ov5640_download_firmware(pModeSetting, ArySize); - } else if ((dn_mode == SUBSAMPLING && orig_dn_mode == SCALING) || - (dn_mode == SCALING && orig_dn_mode == SUBSAMPLING)) { - /* change between subsampling and scaling - * go through exposure calucation */ - retval = ov5640_change_mode_exposure_calc(frame_rate, mode); - } else { - /* change inside subsampling or scaling - * download firmware directly */ - retval = ov5640_change_mode_direct(frame_rate, mode); - } - - if (retval < 0) - goto err; - - OV5640_set_AE_target(AE_Target); - OV5640_get_light_freq(); - OV5640_set_bandingfilter(); - ov5640_set_virtual_channel(ov5640_data.csi); - - /* add delay to wait for sensor stable */ - if (mode == ov5640_mode_QSXGA_2592_1944) { - /* dump the first two frames: 1/7.5*2 - * the frame rate of QSXGA is 7.5fps */ - msec_wait4stable = 267; - } else if (frame_rate == ov5640_15_fps) { - /* dump the first nine frames: 1/15*9 */ - msec_wait4stable = 600; - } else if (frame_rate == ov5640_30_fps) { - /* dump the first nine frames: 1/30*9 */ - msec_wait4stable = 300; - } - msleep(msec_wait4stable); - - if (mipi_csi2_info) { - unsigned int i; - - i = 0; - - /* wait for mipi sensor ready */ - mipi_reg = mipi_csi2_dphy_status(mipi_csi2_info); - while ((mipi_reg == 0x200) && (i < 10)) { - mipi_reg = mipi_csi2_dphy_status(mipi_csi2_info); - i++; - msleep(10); - } - - if (i >= 10) { - pr_err("mipi csi2 can not receive sensor clk!\n"); - return -1; - } - - i = 0; - - /* wait for mipi stable */ - mipi_reg = mipi_csi2_get_error1(mipi_csi2_info); - while ((mipi_reg != 0x0) && (i < 10)) { - mipi_reg = mipi_csi2_get_error1(mipi_csi2_info); - i++; - msleep(10); - } - - if (i >= 10) { - pr_err("mipi csi2 can not reveive data correctly!\n"); - return -1; - } - } -err: - return retval; -} - -/* --------------- IOCTL functions from v4l2_int_ioctl_desc --------------- */ - -static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) -{ - if (s == NULL) { - pr_err(" ERROR!! no slave device set!\n"); - return -1; - } - - memset(p, 0, sizeof(*p)); - p->u.bt656.clock_curr = ov5640_data.mclk; - pr_debug(" clock_curr=mclk=%d\n", ov5640_data.mclk); - p->if_type = V4L2_IF_TYPE_BT656; - p->u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT; - p->u.bt656.clock_min = OV5640_XCLK_MIN; - p->u.bt656.clock_max = OV5640_XCLK_MAX; - p->u.bt656.bt_sync_correct = 1; /* Indicate external vsync */ - - return 0; -} - -/*! - * ioctl_s_power - V4L2 sensor interface handler for VIDIOC_S_POWER ioctl - * @s: pointer to standard V4L2 device structure - * @on: indicates power mode (on or off) - * - * Turns the power on or off, depending on the value of on and returns the - * appropriate error code. - */ -static int ioctl_s_power(struct v4l2_int_device *s, int on) -{ - struct sensor_data *sensor = s->priv; - - if (on && !sensor->on) { - if (io_regulator) - if (regulator_enable(io_regulator) != 0) - return -EIO; - if (core_regulator) - if (regulator_enable(core_regulator) != 0) - return -EIO; - if (gpo_regulator) - if (regulator_enable(gpo_regulator) != 0) - return -EIO; - if (analog_regulator) - if (regulator_enable(analog_regulator) != 0) - return -EIO; - /* Make sure power on */ - ov5640_standby(0); - } else if (!on && sensor->on) { - if (analog_regulator) - regulator_disable(analog_regulator); - if (core_regulator) - regulator_disable(core_regulator); - if (io_regulator) - regulator_disable(io_regulator); - if (gpo_regulator) - regulator_disable(gpo_regulator); - - ov5640_standby(1); - } - - sensor->on = on; - - return 0; -} - -/*! - * ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure - * - * Returns the sensor's video CAPTURE parameters. - */ -static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - struct sensor_data *sensor = s->priv; - struct v4l2_captureparm *cparm = &a->parm.capture; - int ret = 0; - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - memset(a, 0, sizeof(*a)); - a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cparm->capability = sensor->streamcap.capability; - cparm->timeperframe = sensor->streamcap.timeperframe; - cparm->capturemode = sensor->streamcap.capturemode; - ret = 0; - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure - * - * Configures the sensor to use the input parameters, if possible. If - * not possible, reverts to the old parameters and returns the - * appropriate error code. - */ -static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - struct sensor_data *sensor = s->priv; - struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; - u32 tgt_fps; /* target frames per secound */ - enum ov5640_frame_rate frame_rate; - enum ov5640_mode orig_mode; - int ret = 0; - - /* Make sure power on */ - ov5640_standby(0); - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - /* Check that the new frame rate is allowed. */ - if ((timeperframe->numerator == 0) || - (timeperframe->denominator == 0)) { - timeperframe->denominator = DEFAULT_FPS; - timeperframe->numerator = 1; - } - - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps > MAX_FPS) { - timeperframe->denominator = MAX_FPS; - timeperframe->numerator = 1; - } else if (tgt_fps < MIN_FPS) { - timeperframe->denominator = MIN_FPS; - timeperframe->numerator = 1; - } - - /* Actual frame rate we use */ - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps == 15) - frame_rate = ov5640_15_fps; - else if (tgt_fps == 30) - frame_rate = ov5640_30_fps; - else { - pr_err(" The camera frame rate is not supported!\n"); - return -EINVAL; - } - - orig_mode = sensor->streamcap.capturemode; - ret = ov5640_init_mode(frame_rate, - (u32)a->parm.capture.capturemode, orig_mode); - if (ret < 0) - return ret; - - sensor->streamcap.timeperframe = *timeperframe; - sensor->streamcap.capturemode = - (u32)a->parm.capture.capturemode; - - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - pr_debug(" type is not " \ - "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", - a->type); - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap - * @s: pointer to standard V4L2 device structure - * @f: pointer to standard V4L2 v4l2_format structure - * - * Returns the sensor's current pixel format in the v4l2_format - * parameter. - */ -static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) -{ - struct sensor_data *sensor = s->priv; - - f->fmt.pix = sensor->pix; - - return 0; -} - -/*! - * ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure - * - * If the requested control is supported, returns the control's current - * value from the video_control[] array. Otherwise, returns -EINVAL - * if the control is not supported. - */ -static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int ret = 0; - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - vc->value = ov5640_data.brightness; - break; - case V4L2_CID_HUE: - vc->value = ov5640_data.hue; - break; - case V4L2_CID_CONTRAST: - vc->value = ov5640_data.contrast; - break; - case V4L2_CID_SATURATION: - vc->value = ov5640_data.saturation; - break; - case V4L2_CID_RED_BALANCE: - vc->value = ov5640_data.red; - break; - case V4L2_CID_BLUE_BALANCE: - vc->value = ov5640_data.blue; - break; - case V4L2_CID_EXPOSURE: - vc->value = ov5640_data.ae_mode; - break; - default: - ret = -EINVAL; - } - - return ret; -} - -/*! - * ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure - * - * If the requested control is supported, sets the control's current - * value in HW (and updates the video_control[] array). Otherwise, - * returns -EINVAL if the control is not supported. - */ -static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int retval = 0; - - pr_debug("In ov5640:ioctl_s_ctrl %d\n", - vc->id); - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - break; - case V4L2_CID_CONTRAST: - break; - case V4L2_CID_SATURATION: - break; - case V4L2_CID_HUE: - break; - case V4L2_CID_AUTO_WHITE_BALANCE: - break; - case V4L2_CID_DO_WHITE_BALANCE: - break; - case V4L2_CID_RED_BALANCE: - break; - case V4L2_CID_BLUE_BALANCE: - break; - case V4L2_CID_GAMMA: - break; - case V4L2_CID_EXPOSURE: - break; - case V4L2_CID_AUTOGAIN: - break; - case V4L2_CID_GAIN: - break; - case V4L2_CID_HFLIP: - break; - case V4L2_CID_VFLIP: - break; - default: - retval = -EPERM; - break; - } - - return retval; -} - -/*! - * ioctl_enum_framesizes - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMESIZES ioctl - * @s: pointer to standard V4L2 device structure - * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_framesizes(struct v4l2_int_device *s, - struct v4l2_frmsizeenum *fsize) -{ - if (fsize->index > ov5640_mode_MAX) - return -EINVAL; - - fsize->pixel_format = ov5640_data.pix.pixelformat; - fsize->discrete.width = - max(ov5640_mode_info_data[0][fsize->index].width, - ov5640_mode_info_data[1][fsize->index].width); - fsize->discrete.height = - max(ov5640_mode_info_data[0][fsize->index].height, - ov5640_mode_info_data[1][fsize->index].height); - return 0; -} - -/*! - * ioctl_enum_frameintervals - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMEINTERVALS ioctl - * @s: pointer to standard V4L2 device structure - * @fival: standard V4L2 VIDIOC_ENUM_FRAMEINTERVALS ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_frameintervals(struct v4l2_int_device *s, - struct v4l2_frmivalenum *fival) -{ - int i, j, count = 0; - - fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; - fival->discrete.numerator = 1; - - for (i = 0; i < ARRAY_SIZE(ov5640_mode_info_data); i++) - for (j = 0; j < (ov5640_mode_MAX + 1); j++) - if (fival->pixel_format == ov5640_data.pix.pixelformat - && fival->width == ov5640_mode_info_data[i][j].width - && fival->height == ov5640_mode_info_data[i][j].height - && ov5640_mode_info_data[i][j].init_data_ptr != NULL - && fival->index == count++) { - fival->discrete.denominator = - ov5640_framerates[i]; - return 0; - } - - return -EINVAL; -} - -/*! - * ioctl_g_chip_ident - V4L2 sensor interface handler for - * VIDIOC_DBG_G_CHIP_IDENT ioctl - * @s: pointer to standard V4L2 device structure - * @id: pointer to int - * - * Return 0. - */ -static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id) -{ - ((struct v4l2_dbg_chip_ident *)id)->match.type = - V4L2_CHIP_MATCH_I2C_DRIVER; - strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name, - "ov5640_mipi_camera"); - - return 0; -} - -/*! - * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT - * @s: pointer to standard V4L2 device structure - */ -static int ioctl_init(struct v4l2_int_device *s) -{ - - return 0; -} - -/*! - * ioctl_enum_fmt_cap - V4L2 sensor interface handler for VIDIOC_ENUM_FMT - * @s: pointer to standard V4L2 device structure - * @fmt: pointer to standard V4L2 fmt description structure - * - * Return 0. - */ -static int ioctl_enum_fmt_cap(struct v4l2_int_device *s, - struct v4l2_fmtdesc *fmt) -{ - if (fmt->index > ov5640_mode_MAX) - return -EINVAL; - - fmt->pixelformat = ov5640_data.pix.pixelformat; - - return 0; -} - -/*! - * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num - * @s: pointer to standard V4L2 device structure - * - * Initialise the device when slave attaches to the master. - */ -static int ioctl_dev_init(struct v4l2_int_device *s) -{ - struct sensor_data *sensor = s->priv; - u32 tgt_xclk; /* target xclk */ - u32 tgt_fps; /* target frames per secound */ - int ret; - enum ov5640_frame_rate frame_rate; - void *mipi_csi2_info; - - ov5640_data.on = true; - - /* mclk */ - tgt_xclk = ov5640_data.mclk; - tgt_xclk = min(tgt_xclk, (u32)OV5640_XCLK_MAX); - tgt_xclk = max(tgt_xclk, (u32)OV5640_XCLK_MIN); - ov5640_data.mclk = tgt_xclk; - - pr_debug(" Setting mclk to %d MHz\n", tgt_xclk / 1000000); - - /* Default camera frame rate is set in probe */ - tgt_fps = sensor->streamcap.timeperframe.denominator / - sensor->streamcap.timeperframe.numerator; - - if (tgt_fps == 15) - frame_rate = ov5640_15_fps; - else if (tgt_fps == 30) - frame_rate = ov5640_30_fps; - else - return -EINVAL; /* Only support 15fps or 30fps now. */ - - mipi_csi2_info = mipi_csi2_get_info(); - - /* enable mipi csi2 */ - if (mipi_csi2_info) - mipi_csi2_enable(mipi_csi2_info); - else { - printk(KERN_ERR "%s() in %s: Fail to get mipi_csi2_info!\n", - __func__, __FILE__); - return -EPERM; - } - - ret = ov5640_init_mode(frame_rate, ov5640_mode_INIT, ov5640_mode_INIT); - - return ret; -} - -/*! - * ioctl_dev_exit - V4L2 sensor interface handler for vidioc_int_dev_exit_num - * @s: pointer to standard V4L2 device structure - * - * Delinitialise the device when slave detaches to the master. - */ -static int ioctl_dev_exit(struct v4l2_int_device *s) -{ - void *mipi_csi2_info; - - mipi_csi2_info = mipi_csi2_get_info(); - - /* disable mipi csi2 */ - if (mipi_csi2_info) - if (mipi_csi2_get_status(mipi_csi2_info)) - mipi_csi2_disable(mipi_csi2_info); - - return 0; -} - -/*! - * This structure defines all the ioctls for this module and links them to the - * enumeration. - */ -static struct v4l2_int_ioctl_desc ov5640_ioctl_desc[] = { - {vidioc_int_dev_init_num, (v4l2_int_ioctl_func *) ioctl_dev_init}, - {vidioc_int_dev_exit_num, ioctl_dev_exit}, - {vidioc_int_s_power_num, (v4l2_int_ioctl_func *) ioctl_s_power}, - {vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func *) ioctl_g_ifparm}, -/* {vidioc_int_g_needs_reset_num, - (v4l2_int_ioctl_func *)ioctl_g_needs_reset}, */ -/* {vidioc_int_reset_num, (v4l2_int_ioctl_func *)ioctl_reset}, */ - {vidioc_int_init_num, (v4l2_int_ioctl_func *) ioctl_init}, - {vidioc_int_enum_fmt_cap_num, - (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap}, -/* {vidioc_int_try_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_try_fmt_cap}, */ - {vidioc_int_g_fmt_cap_num, (v4l2_int_ioctl_func *) ioctl_g_fmt_cap}, -/* {vidioc_int_s_fmt_cap_num, (v4l2_int_ioctl_func *) ioctl_s_fmt_cap}, */ - {vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm}, - {vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm}, -/* {vidioc_int_queryctrl_num, (v4l2_int_ioctl_func *)ioctl_queryctrl}, */ - {vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl}, - {vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl}, - {vidioc_int_enum_framesizes_num, - (v4l2_int_ioctl_func *) ioctl_enum_framesizes}, - {vidioc_int_enum_frameintervals_num, - (v4l2_int_ioctl_func *) ioctl_enum_frameintervals}, - {vidioc_int_g_chip_ident_num, - (v4l2_int_ioctl_func *) ioctl_g_chip_ident}, -}; - -static struct v4l2_int_slave ov5640_slave = { - .ioctls = ov5640_ioctl_desc, - .num_ioctls = ARRAY_SIZE(ov5640_ioctl_desc), -}; - -static struct v4l2_int_device ov5640_int_device = { - .module = THIS_MODULE, - .name = "ov564x", - .type = v4l2_int_type_slave, - .u = { - .slave = &ov5640_slave, - }, -}; - -/*! - * ov5640 I2C probe function - * - * @param adapter struct i2c_adapter * - * @return Error code indicating success or failure - */ -static int ov5640_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct device *dev = &client->dev; - int retval; - u8 chip_id_high, chip_id_low; - - /* request power down pin */ - pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); - if (!gpio_is_valid(pwn_gpio)) { - dev_warn(dev, "no sensor pwdn pin available"); - return -EINVAL; - } - retval = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_mipi_pwdn"); - if (retval < 0) - return retval; - - /* request reset pin */ - rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0); - if (!gpio_is_valid(rst_gpio)) { - dev_warn(dev, "no sensor reset pin available"); - return -EINVAL; - } - retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_mipi_reset"); - if (retval < 0) - return retval; - - /* Set initial values for the sensor struct. */ - memset(&ov5640_data, 0, sizeof(ov5640_data)); - ov5640_data.sensor_clk = devm_clk_get(dev, "csi_mclk"); - if (IS_ERR(ov5640_data.sensor_clk)) { - /* assuming clock enabled by default */ - ov5640_data.sensor_clk = NULL; - dev_err(dev, "clock-frequency missing or invalid\n"); - return PTR_ERR(ov5640_data.sensor_clk); - } - - retval = of_property_read_u32(dev->of_node, "mclk", - &(ov5640_data.mclk)); - if (retval) { - dev_err(dev, "mclk missing or invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "mclk_source", - (u32 *) &(ov5640_data.mclk_source)); - if (retval) { - dev_err(dev, "mclk_source missing or invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "csi_id", - &(ov5640_data.csi)); - if (retval) { - dev_err(dev, "csi id missing or invalid\n"); - return retval; - } - - clk_prepare_enable(ov5640_data.sensor_clk); - - ov5640_data.io_init = ov5640_reset; - ov5640_data.i2c_client = client; - ov5640_data.pix.pixelformat = V4L2_PIX_FMT_UYVY; - ov5640_data.pix.width = 640; - ov5640_data.pix.height = 480; - ov5640_data.streamcap.capability = V4L2_MODE_HIGHQUALITY | - V4L2_CAP_TIMEPERFRAME; - ov5640_data.streamcap.capturemode = 0; - ov5640_data.streamcap.timeperframe.denominator = DEFAULT_FPS; - ov5640_data.streamcap.timeperframe.numerator = 1; - - ov5640_power_on(dev); - - ov5640_reset(); - - ov5640_standby(0); - - retval = ov5640_read_reg(OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high); - if (retval < 0 || chip_id_high != 0x56) { - pr_warning("camera ov5640_mipi is not found\n"); - clk_disable_unprepare(ov5640_data.sensor_clk); - return -ENODEV; - } - retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low); - if (retval < 0 || chip_id_low != 0x40) { - pr_warning("camera ov5640_mipi is not found\n"); - clk_disable_unprepare(ov5640_data.sensor_clk); - return -ENODEV; - } - - ov5640_standby(1); - - ov5640_int_device.priv = &ov5640_data; - retval = v4l2_int_device_register(&ov5640_int_device); - - clk_disable_unprepare(ov5640_data.sensor_clk); - - pr_info("camera ov5640_mipi is found\n"); - return retval; -} - -/*! - * ov5640 I2C detach function - * - * @param client struct i2c_client * - * @return Error code indicating success or failure - */ -static int ov5640_remove(struct i2c_client *client) -{ - v4l2_int_device_unregister(&ov5640_int_device); - - if (gpo_regulator) - regulator_disable(gpo_regulator); - - if (analog_regulator) - regulator_disable(analog_regulator); - - if (core_regulator) - regulator_disable(core_regulator); - - if (io_regulator) - regulator_disable(io_regulator); - - return 0; -} - -/*! - * ov5640 init function - * Called by insmod ov5640_camera.ko. - * - * @return Error code indicating success or failure - */ -static __init int ov5640_init(void) -{ - u8 err; - - err = i2c_add_driver(&ov5640_i2c_driver); - if (err != 0) - pr_err("%s:driver registration failed, error=%d\n", - __func__, err); - - return err; -} - -/*! - * OV5640 cleanup function - * Called on rmmod ov5640_camera.ko - * - * @return Error code indicating success or failure - */ -static void __exit ov5640_clean(void) -{ - i2c_del_driver(&ov5640_i2c_driver); -} - -module_init(ov5640_init); -module_exit(ov5640_clean); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("OV5640 MIPI Camera Driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("CSI"); diff --git a/drivers/media/platform/mxc/capture/ov5640_mipi_v2.c b/drivers/media/platform/mxc/capture/ov5640_mipi_v2.c index 333201699deea8ec73df15ce387e8513c9d2ec4e..1cb3d69918f463914018c7d38b1ea1617a38097f 100644 --- a/drivers/media/platform/mxc/capture/ov5640_mipi_v2.c +++ b/drivers/media/platform/mxc/capture/ov5640_mipi_v2.c @@ -42,6 +42,8 @@ #define OV5640_CHIP_ID_HIGH_BYTE 0x300A #define OV5640_CHIP_ID_LOW_BYTE 0x300B +#define DEFAULT_SCCB_ID 0x78 + enum ov5640_mode { ov5640_mode_MIN = 0, ov5640_mode_VGA_640_480 = 0, @@ -116,7 +118,7 @@ struct ov5640 { int csi; void (*io_init)(struct ov5640 *); - int pwn_gpio, rst_gpio; + int pwn_gpio, rst_gpio; }; struct ov5640_res { @@ -128,6 +130,7 @@ struct ov5640_res { * Maintains the information on the current state of the sesor. */ + struct ov5640_res ov5640_valid_res[] = { [0] = {640, 480}, [1] = {720, 480}, @@ -333,9 +336,8 @@ static struct reg_value ov5640_setting_30fps_1080P_1920_1080[] = { static struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = { {0x3008, 0x42, 0, 0}, - {0x4202, 0x0f, 0, 0}, /* stream off the sensor */ {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, /*disable flip*/ - {0x3035, 0x21, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x08, 0, 0}, + {0x3035, 0x11, 0, 0}, {0x3036, 0x54, 0, 0}, {0x3c07, 0x08, 0, 0}, {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, @@ -353,7 +355,6 @@ static struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = { {0x4001, 0x02, 0, 0}, {0x4004, 0x06, 0, 0}, {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, {0x5001, 0x83, 0, 70}, {0x3008, 0x02, 0, 0}, - {0x4202, 0x00, 0, 0}, /* stream on the sensor */ }; static struct ov5640_mode_info ov5640_mode_info_data[2][ov5640_mode_MAX + 1] = { @@ -387,6 +388,7 @@ static struct regulator *io_regulator; static struct regulator *core_regulator; static struct regulator *analog_regulator; static struct regulator *gpo_regulator; +static DEFINE_MUTEX(ov5640_mutex); static int ov5640_probe(struct i2c_client *adapter, const struct i2c_device_id *device_id); @@ -460,6 +462,42 @@ static inline void ov5640_power_down(struct ov5640 *sensor, int enable) msleep(2); } +static int ov5640_update_slave_id(struct ov5640 *sensor) +{ + struct device *dev = &sensor->i2c_client->dev; + u8 slave_id; + struct i2c_client *tmp_client; + s32 retval; + + if (sensor->i2c_client->addr << 1 == DEFAULT_SCCB_ID) + return 0; /* nothing to do */ + + /* Change camera i2c slave address */ + slave_id = (u8)(sensor->i2c_client->addr << 1); /* new slave id*/ + tmp_client = sensor->i2c_client; + + sensor->i2c_client = + i2c_new_dummy(tmp_client->adapter, DEFAULT_SCCB_ID >> 1); + if (!sensor->i2c_client) { + dev_err(dev, "Failed to communicate on 0x%x\n", + DEFAULT_SCCB_ID); + return -1; + } + + retval = ov5640_write_reg(sensor, 0x3100, slave_id); + i2c_unregister_device(sensor->i2c_client); + sensor->i2c_client = tmp_client; + if (retval != 0) { + dev_err(dev, "Failed to update SCCB_ID to 0x%x\n", slave_id); + return -1; + } + + ov5640_read_reg(sensor, 0x3100, &slave_id); + dev_dbg(dev, "Updated SCCB_ID 0x%x\n", slave_id); + + return 0; +} + static void ov5640_reset(struct ov5640 *sensor) { if (sensor->rst_gpio < 0 || sensor->pwn_gpio < 0) @@ -546,6 +584,7 @@ static int ov5640_regulator_enable(struct device *dev) static s32 ov5640_write_reg(struct ov5640 *sensor, u16 reg, u8 val) { + struct device *dev = &sensor->i2c_client->dev; u8 au8Buf[3] = {0}; au8Buf[0] = reg >> 8; @@ -553,8 +592,7 @@ static s32 ov5640_write_reg(struct ov5640 *sensor, u16 reg, u8 val) au8Buf[2] = val; if (i2c_master_send(sensor->i2c_client, au8Buf, 3) < 0) { - pr_err("%s:write reg error:reg=%x,val=%x\n", - __func__, reg, val); + dev_err(dev, "Write reg error: reg=%x, val=%x\n", reg, val); return -1; } @@ -563,21 +601,20 @@ static s32 ov5640_write_reg(struct ov5640 *sensor, u16 reg, u8 val) static s32 ov5640_read_reg(struct ov5640 *sensor, u16 reg, u8 *val) { + struct device *dev = &sensor->i2c_client->dev; u8 au8RegBuf[2] = {0}; u8 u8RdVal = 0; au8RegBuf[0] = reg >> 8; au8RegBuf[1] = reg & 0xff; - if (2 != i2c_master_send(sensor->i2c_client, au8RegBuf, 2)) { - pr_err("%s:write reg error:reg=%x\n", - __func__, reg); + if (i2c_master_send(sensor->i2c_client, au8RegBuf, 2) != 2) { + dev_err(dev, "Read reg error: reg=%x\n", reg); return -1; } - if (1 != i2c_master_recv(sensor->i2c_client, &u8RdVal, 1)) { - pr_err("%s:read reg error:reg=%x,val=%x\n", - __func__, reg, u8RdVal); + if (i2c_master_recv(sensor->i2c_client, &u8RdVal, 1) != 1) { + dev_err(dev, "Read reg error: reg=%x, val=%x\n", reg, u8RdVal); return -1; } @@ -872,7 +909,9 @@ static void ov5640_set_virtual_channel(struct ov5640 *sensor, int channel) } /* download ov5640 settings to sensor through i2c */ -static int ov5640_download_firmware(struct ov5640 *sensor, struct reg_value *pModeSetting, s32 ArySize) +static int ov5640_download_firmware(struct ov5640 *sensor, + struct reg_value *pModeSetting, + s32 ArySize) { register u32 Delay_ms = 0; register u16 RegAddr = 0; @@ -911,7 +950,8 @@ err: /* sensor changes between scaling and subsampling * go through exposure calcualtion */ -static int ov5640_change_mode_exposure_calc(struct ov5640 *sensor, enum ov5640_frame_rate frame_rate, +static int ov5640_change_mode_exposure_calc(struct ov5640 *sensor, + enum ov5640_frame_rate frame_rate, enum ov5640_mode mode) { struct reg_value *pModeSetting = NULL; @@ -1040,7 +1080,8 @@ err: /* if sensor changes inside scaling or subsampling * change mode directly * */ -static int ov5640_change_mode_direct(struct ov5640 *sensor, enum ov5640_frame_rate frame_rate, +static int ov5640_change_mode_direct(struct ov5640 *sensor, + enum ov5640_frame_rate frame_rate, enum ov5640_mode mode) { struct reg_value *pModeSetting = NULL; @@ -1078,9 +1119,11 @@ err: return retval; } -static int ov5640_init_mode(struct ov5640 *sensor, enum ov5640_frame_rate frame_rate, +static int ov5640_init_mode(struct ov5640 *sensor, + enum ov5640_frame_rate frame_rate, enum ov5640_mode mode, enum ov5640_mode orig_mode) { + struct device *dev = &sensor->i2c_client->dev; struct reg_value *pModeSetting = NULL; s32 ArySize = 0; int retval = 0; @@ -1089,7 +1132,7 @@ static int ov5640_init_mode(struct ov5640 *sensor, enum ov5640_frame_rate frame_ if ((mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) && (mode != ov5640_mode_INIT)) { - pr_err("Wrong ov5640 mode detected!\n"); + dev_err(dev, "Wrong ov5640 mode detected!\n"); return -1; } @@ -1101,18 +1144,21 @@ static int ov5640_init_mode(struct ov5640 *sensor, enum ov5640_frame_rate frame_ sensor->pix.width = 640; sensor->pix.height = 480; - retval = ov5640_download_firmware(sensor, pModeSetting, ArySize); + retval = ov5640_download_firmware(sensor, pModeSetting, + ArySize); if (retval < 0) goto err; pModeSetting = ov5640_setting_30fps_VGA_640_480; ArySize = ARRAY_SIZE(ov5640_setting_30fps_VGA_640_480); - retval = ov5640_download_firmware(sensor, pModeSetting, ArySize); + retval = ov5640_download_firmware(sensor, pModeSetting, + ArySize); } else if ((dn_mode == SUBSAMPLING && orig_dn_mode == SCALING) || (dn_mode == SCALING && orig_dn_mode == SUBSAMPLING)) { /* change between subsampling and scaling * go through exposure calucation */ - retval = ov5640_change_mode_exposure_calc(sensor, frame_rate, mode); + retval = ov5640_change_mode_exposure_calc(sensor, + frame_rate, mode); } else { /* change inside subsampling or scaling * download firmware directly */ @@ -1195,6 +1241,7 @@ static int ov5640_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov5640 *sensor = to_ov5640(client); + struct device *dev = &sensor->i2c_client->dev; struct v4l2_captureparm *cparm = &a->parm.capture; int ret = 0; @@ -1220,7 +1267,7 @@ static int ov5640_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) break; default: - pr_debug(" type is unknown - %d\n", a->type); + dev_warn(dev, "Type is unknown - %d\n", a->type); ret = -EINVAL; break; } @@ -1241,6 +1288,7 @@ static int ov5640_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov5640 *sensor = to_ov5640(client); + struct device *dev = &sensor->i2c_client->dev; struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; u32 tgt_fps; /* target frames per secound */ enum ov5640_frame_rate frame_rate; @@ -1277,7 +1325,8 @@ static int ov5640_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) else if (tgt_fps == 30) frame_rate = ov5640_30_fps; else { - pr_err(" The camera frame rate is not supported!\n"); + dev_warn(dev, + "The camera frame rate is not supported!\n"); return -EINVAL; } @@ -1300,14 +1349,13 @@ static int ov5640_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) case V4L2_BUF_TYPE_VBI_OUTPUT: case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - pr_debug(" type is not " \ - "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", + dev_warn(dev, "Type is not V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", a->type); ret = -EINVAL; break; default: - pr_debug(" type is unknown - %d\n", a->type); + dev_warn(dev, "Type is unknown - %d\n", a->type); ret = -EINVAL; break; } @@ -1345,7 +1393,8 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, return 0; } - dev_err(&client->dev, "%s set fail\n", __func__); + dev_err(&client->dev, "Set format failed %d, %d\n", + fmt->code, fmt->colorspace); return -EINVAL; } @@ -1421,6 +1470,8 @@ static int ov5640_enum_frameintervals(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_interval_enum *fie) { + struct i2c_client *client = v4l2_get_subdevdata(sd); + struct device *dev = &client->dev; int i, j, count = 0; if (fie->index < 0 || fie->index > ov5640_mode_MAX) @@ -1428,7 +1479,7 @@ static int ov5640_enum_frameintervals(struct v4l2_subdev *sd, if (fie->width == 0 || fie->height == 0 || fie->code == 0) { - pr_warning("Please assign pixel format, width and height.\n"); + dev_warn(dev, "Please assign pixel format, width and height\n"); return -EINVAL; } @@ -1460,6 +1511,7 @@ static int ov5640_enum_frameintervals(struct v4l2_subdev *sd, */ static int init_device(struct ov5640 *sensor) { + struct device *dev = &sensor->i2c_client->dev; u32 tgt_xclk; /* target xclk */ u32 tgt_fps; /* target frames per secound */ enum ov5640_frame_rate frame_rate; @@ -1473,7 +1525,7 @@ static int init_device(struct ov5640 *sensor) tgt_xclk = max(tgt_xclk, (u32)OV5640_XCLK_MIN); sensor->mclk = tgt_xclk; - pr_debug(" Setting mclk to %d MHz\n", tgt_xclk / 1000000); + dev_dbg(dev, "Setting mclk to %d MHz\n", tgt_xclk / 1000000); /* Default camera frame rate is set in probe */ tgt_fps = sensor->streamcap.timeperframe.denominator / @@ -1486,7 +1538,8 @@ static int init_device(struct ov5640 *sensor) else return -EINVAL; /* Only support 15fps or 30fps now. */ - ret = ov5640_init_mode(sensor, frame_rate, ov5640_mode_INIT, ov5640_mode_INIT); + ret = ov5640_init_mode(sensor, frame_rate, ov5640_mode_INIT, + ov5640_mode_INIT); return ret; } @@ -1495,7 +1548,9 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov5640 *sensor = to_ov5640(client); + struct device *dev = &sensor->i2c_client->dev; + dev_info(dev, "s_stream: %d\n", enable); if (enable) OV5640_stream_on(sensor); else @@ -1558,24 +1613,22 @@ static int ov5640_probe(struct i2c_client *client, struct device *dev = &client->dev; int retval; u8 chip_id_high, chip_id_low; - struct ov5640 *sensor; + struct ov5640 *sensor; - sensor = kmalloc(sizeof(*sensor), GFP_KERNEL); - /* Set initial values for the sensor struct. */ - memset(sensor, 0, sizeof(*sensor)); + sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); /* ov5640 pinctrl */ pinctrl = devm_pinctrl_get_select_default(dev); if (IS_ERR(pinctrl)) - dev_warn(dev, "no pin available\n"); + dev_warn(dev, "No pin available\n"); /* request power down pin */ sensor->pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); if (!gpio_is_valid(sensor->pwn_gpio)) - dev_warn(dev, "no sensor pwdn pin available"); + dev_warn(dev, "No sensor pwdn pin available"); else { - retval = devm_gpio_request_one(dev, sensor->pwn_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_mipi_pwdn"); + retval = devm_gpio_request_one(dev, sensor->pwn_gpio, + GPIOF_OUT_INIT_HIGH, "ov5640_mipi_pwdn"); if (retval < 0) { dev_warn(dev, "Failed to set power pin\n"); dev_warn(dev, "retval=%d\n", retval); @@ -1586,10 +1639,10 @@ static int ov5640_probe(struct i2c_client *client, /* request reset pin */ sensor->rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0); if (!gpio_is_valid(sensor->rst_gpio)) - dev_warn(dev, "no sensor reset pin available"); + dev_warn(dev, "No sensor reset pin available"); else { - retval = devm_gpio_request_one(dev, sensor->rst_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_mipi_reset"); + retval = devm_gpio_request_one(dev, sensor->rst_gpio, + GPIOF_OUT_INIT_HIGH, "ov5640_mipi_reset"); if (retval < 0) { dev_warn(dev, "Failed to set reset pin\n"); return retval; @@ -1644,19 +1697,28 @@ static int ov5640_probe(struct i2c_client *client, ov5640_regulator_enable(&client->dev); - ov5640_reset(sensor); - - ov5640_power_down(sensor, 0); + mutex_lock(&ov5640_mutex); + { + ov5640_reset(sensor); + ov5640_power_down(sensor, 0); + retval = ov5640_update_slave_id(sensor); + } + mutex_unlock(&ov5640_mutex); + if (retval < 0) { + clk_disable_unprepare(sensor->sensor_clk); + return -ENODEV; + } - retval = ov5640_read_reg(sensor, OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high); + retval = ov5640_read_reg(sensor, OV5640_CHIP_ID_HIGH_BYTE, + &chip_id_high); if (retval < 0 || chip_id_high != 0x56) { - pr_warning("camera ov5640_mipi is not found\n"); + dev_warn(dev, "Camera is not found\n"); clk_disable_unprepare(sensor->sensor_clk); return -ENODEV; } retval = ov5640_read_reg(sensor, OV5640_CHIP_ID_LOW_BYTE, &chip_id_low); if (retval < 0 || chip_id_low != 0x40) { - pr_warning("camera ov5640_mipi is not found\n"); + dev_warn(dev, "Camera is not found\n"); clk_disable_unprepare(sensor->sensor_clk); return -ENODEV; } @@ -1665,7 +1727,7 @@ static int ov5640_probe(struct i2c_client *client, retval = init_device(sensor); if (retval < 0) { clk_disable_unprepare(sensor->sensor_clk); - pr_warning("camera ov5640 init failed\n"); + dev_warn(dev, "Camera init failed\n"); ov5640_power_down(sensor, 1); return retval; } @@ -1675,11 +1737,11 @@ static int ov5640_probe(struct i2c_client *client, sensor->subdev.grp_id = 678; retval = v4l2_async_register_subdev(&sensor->subdev); if (retval < 0) - dev_err(&client->dev, - "%s--Async register failed, ret=%d\n", __func__, retval); + dev_err(&client->dev, "Async register failed, ret=%d\n", + retval); OV5640_stream_off(sensor); - pr_info("camera ov5640_mipi is found\n"); + dev_info(dev, "Camera is found\n"); return retval; } diff --git a/drivers/media/platform/mxc/capture/ov5640_v2.c b/drivers/media/platform/mxc/capture/ov5640_v2.c deleted file mode 100644 index 70e2a8321fd0b1a1d5832abbdfea17000ff07eba..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ov5640_v2.c +++ /dev/null @@ -1,1895 +0,0 @@ -/* - * Copyright (C) 2012-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * 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. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define OV5640_VOLTAGE_ANALOG 2800000 -#define OV5640_VOLTAGE_DIGITAL_CORE 1500000 -#define OV5640_VOLTAGE_DIGITAL_IO 1800000 - -#define MIN_FPS 15 -#define MAX_FPS 30 -#define DEFAULT_FPS 30 - -#define OV5640_XCLK_MIN 6000000 -#define OV5640_XCLK_MAX 24000000 - -#define OV5640_CHIP_ID_HIGH_BYTE 0x300A -#define OV5640_CHIP_ID_LOW_BYTE 0x300B - -enum ov5640_mode { - ov5640_mode_MIN = 0, - ov5640_mode_VGA_640_480 = 0, - ov5640_mode_QVGA_320_240 = 1, - ov5640_mode_NTSC_720_480 = 2, - ov5640_mode_PAL_720_576 = 3, - ov5640_mode_720P_1280_720 = 4, - ov5640_mode_1080P_1920_1080 = 5, - ov5640_mode_QSXGA_2592_1944 = 6, - ov5640_mode_QCIF_176_144 = 7, - ov5640_mode_XGA_1024_768 = 8, - ov5640_mode_MAX = 8 -}; - -enum ov5640_frame_rate { - ov5640_15_fps, - ov5640_30_fps -}; - -static int ov5640_framerates[] = { - [ov5640_15_fps] = 15, - [ov5640_30_fps] = 30, -}; - -struct ov5640_datafmt { - u32 code; - enum v4l2_colorspace colorspace; -}; - -struct reg_value { - u16 u16RegAddr; - u8 u8Val; - u8 u8Mask; - u32 u32Delay_ms; -}; - -struct ov5640_mode_info { - enum ov5640_mode mode; - u32 width; - u32 height; - struct reg_value *init_data_ptr; - u32 init_data_size; -}; - -struct ov5640 { - struct v4l2_subdev subdev; - struct i2c_client *i2c_client; - struct v4l2_pix_format pix; - const struct ov5640_datafmt *fmt; - struct v4l2_captureparm streamcap; - bool on; - - /* control settings */ - int brightness; - int hue; - int contrast; - int saturation; - int red; - int green; - int blue; - int ae_mode; - - u32 mclk; - u8 mclk_source; - struct clk *sensor_clk; - int csi; - - void (*io_init)(void); -}; - -/*! - * Maintains the information on the current state of the sesor. - */ -static struct ov5640 ov5640_data; -static int pwn_gpio, rst_gpio; -static int prev_sysclk; -static int AE_Target = 52, night_mode; -static int prev_HTS; -static int AE_high, AE_low; - -static struct reg_value ov5640_global_init_setting[] = { - {0x3008, 0x42, 0, 0}, - {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, - {0x3034, 0x1a, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, - {0x3630, 0x36, 0, 0}, {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, - {0x3633, 0x12, 0, 0}, {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, - {0x3703, 0x5a, 0, 0}, {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, - {0x370b, 0x60, 0, 0}, {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, - {0x3906, 0x10, 0, 0}, {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, - {0x3600, 0x08, 0, 0}, {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, - {0x3620, 0x52, 0, 0}, {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, - {0x3a13, 0x43, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, - {0x3635, 0x13, 0, 0}, {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, - {0x3622, 0x01, 0, 0}, {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, - {0x3c05, 0x98, 0, 0}, {0x3c06, 0x00, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3c08, 0x00, 0, 0}, {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, - {0x3c0b, 0x40, 0, 0}, {0x3810, 0x00, 0, 0}, {0x3811, 0x10, 0, 0}, - {0x3812, 0x00, 0, 0}, {0x3708, 0x64, 0, 0}, {0x4001, 0x02, 0, 0}, - {0x4005, 0x1a, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, - {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x5000, 0xa7, 0, 0}, - {0x3008, 0x02, 0, 0}, -}; - -static struct reg_value ov5640_init_setting_30fps_VGA[] = { - {0x3008, 0x42, 0, 0}, - {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, - {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, {0x3036, 0x46, 0, 0}, - {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, {0x3630, 0x36, 0, 0}, - {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0}, - {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, - {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0}, - {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, {0x3906, 0x10, 0, 0}, - {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, {0x3600, 0x08, 0, 0}, - {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, {0x3620, 0x52, 0, 0}, - {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, {0x3a13, 0x43, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3635, 0x13, 0, 0}, - {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, {0x3622, 0x01, 0, 0}, - {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, {0x3c05, 0x98, 0, 0}, - {0x3c06, 0x00, 0, 0}, {0x3c07, 0x08, 0, 0}, {0x3c08, 0x00, 0, 0}, - {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, - {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, - {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, - {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, - {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, {0x5000, 0xa7, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0xf2, 0, 0}, - {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0}, {0x5187, 0x09, 0, 0}, - {0x5188, 0x09, 0, 0}, {0x5189, 0x88, 0, 0}, {0x518a, 0x54, 0, 0}, - {0x518b, 0xee, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x50, 0, 0}, - {0x518e, 0x34, 0, 0}, {0x518f, 0x6b, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x6c, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x09, 0, 0}, - {0x519d, 0x2b, 0, 0}, {0x519e, 0x38, 0, 0}, {0x5381, 0x1e, 0, 0}, - {0x5382, 0x5b, 0, 0}, {0x5383, 0x08, 0, 0}, {0x5384, 0x0a, 0, 0}, - {0x5385, 0x7e, 0, 0}, {0x5386, 0x88, 0, 0}, {0x5387, 0x7c, 0, 0}, - {0x5388, 0x6c, 0, 0}, {0x5389, 0x10, 0, 0}, {0x538a, 0x01, 0, 0}, - {0x538b, 0x98, 0, 0}, {0x5300, 0x08, 0, 0}, {0x5301, 0x30, 0, 0}, - {0x5302, 0x10, 0, 0}, {0x5303, 0x00, 0, 0}, {0x5304, 0x08, 0, 0}, - {0x5305, 0x30, 0, 0}, {0x5306, 0x08, 0, 0}, {0x5307, 0x16, 0, 0}, - {0x5309, 0x08, 0, 0}, {0x530a, 0x30, 0, 0}, {0x530b, 0x04, 0, 0}, - {0x530c, 0x06, 0, 0}, {0x5480, 0x01, 0, 0}, {0x5481, 0x08, 0, 0}, - {0x5482, 0x14, 0, 0}, {0x5483, 0x28, 0, 0}, {0x5484, 0x51, 0, 0}, - {0x5485, 0x65, 0, 0}, {0x5486, 0x71, 0, 0}, {0x5487, 0x7d, 0, 0}, - {0x5488, 0x87, 0, 0}, {0x5489, 0x91, 0, 0}, {0x548a, 0x9a, 0, 0}, - {0x548b, 0xaa, 0, 0}, {0x548c, 0xb8, 0, 0}, {0x548d, 0xcd, 0, 0}, - {0x548e, 0xdd, 0, 0}, {0x548f, 0xea, 0, 0}, {0x5490, 0x1d, 0, 0}, - {0x5580, 0x02, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x10, 0, 0}, - {0x5589, 0x10, 0, 0}, {0x558a, 0x00, 0, 0}, {0x558b, 0xf8, 0, 0}, - {0x5800, 0x23, 0, 0}, {0x5801, 0x14, 0, 0}, {0x5802, 0x0f, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x12, 0, 0}, {0x5805, 0x26, 0, 0}, - {0x5806, 0x0c, 0, 0}, {0x5807, 0x08, 0, 0}, {0x5808, 0x05, 0, 0}, - {0x5809, 0x05, 0, 0}, {0x580a, 0x08, 0, 0}, {0x580b, 0x0d, 0, 0}, - {0x580c, 0x08, 0, 0}, {0x580d, 0x03, 0, 0}, {0x580e, 0x00, 0, 0}, - {0x580f, 0x00, 0, 0}, {0x5810, 0x03, 0, 0}, {0x5811, 0x09, 0, 0}, - {0x5812, 0x07, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x00, 0, 0}, - {0x5815, 0x01, 0, 0}, {0x5816, 0x03, 0, 0}, {0x5817, 0x08, 0, 0}, - {0x5818, 0x0d, 0, 0}, {0x5819, 0x08, 0, 0}, {0x581a, 0x05, 0, 0}, - {0x581b, 0x06, 0, 0}, {0x581c, 0x08, 0, 0}, {0x581d, 0x0e, 0, 0}, - {0x581e, 0x29, 0, 0}, {0x581f, 0x17, 0, 0}, {0x5820, 0x11, 0, 0}, - {0x5821, 0x11, 0, 0}, {0x5822, 0x15, 0, 0}, {0x5823, 0x28, 0, 0}, - {0x5824, 0x46, 0, 0}, {0x5825, 0x26, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x26, 0, 0}, {0x5828, 0x64, 0, 0}, {0x5829, 0x26, 0, 0}, - {0x582a, 0x24, 0, 0}, {0x582b, 0x22, 0, 0}, {0x582c, 0x24, 0, 0}, - {0x582d, 0x24, 0, 0}, {0x582e, 0x06, 0, 0}, {0x582f, 0x22, 0, 0}, - {0x5830, 0x40, 0, 0}, {0x5831, 0x42, 0, 0}, {0x5832, 0x24, 0, 0}, - {0x5833, 0x26, 0, 0}, {0x5834, 0x24, 0, 0}, {0x5835, 0x22, 0, 0}, - {0x5836, 0x22, 0, 0}, {0x5837, 0x26, 0, 0}, {0x5838, 0x44, 0, 0}, - {0x5839, 0x24, 0, 0}, {0x583a, 0x26, 0, 0}, {0x583b, 0x28, 0, 0}, - {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0}, {0x5025, 0x00, 0, 0}, - {0x3a0f, 0x30, 0, 0}, {0x3a10, 0x28, 0, 0}, {0x3a1b, 0x30, 0, 0}, - {0x3a1e, 0x26, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x14, 0, 0}, - {0x3008, 0x02, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_VGA_640_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_VGA_640_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_QVGA_320_240[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QVGA_320_240[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_NTSC_720_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, - {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_NTSC_720_480[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, - {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_PAL_720_576[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_PAL_720_576[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, - {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_720P_1280_720[] = { - {0x3035, 0x21, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, - {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, - {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, - {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, - {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, - {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_720P_1280_720[] = { - {0x3035, 0x41, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, - {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, - {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, - {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, - {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, - {0x3503, 0x00, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_QCIF_176_144[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QCIF_176_144[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, - {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_30fps_XGA_1024_768[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, - {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_XGA_1024_768[] = { - {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, - {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, - {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, - {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, - {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, - {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - - -static struct reg_value ov5640_setting_15fps_1080P_1920_1080[] = { - {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, - {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0xee, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x05, 0, 0}, - {0x3807, 0xc3, 0, 0}, {0x3808, 0x07, 0, 0}, {0x3809, 0x80, 0, 0}, - {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0}, {0x380c, 0x0b, 0, 0}, - {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, - {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, - {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, - {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, - {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = { - {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, - {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, - {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, - {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, - {0x3807, 0x9f, 0, 0}, {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, - {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, - {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, - {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, - {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, - {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, - {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, - {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, -}; - -static struct ov5640_mode_info ov5640_mode_info_data[2][ov5640_mode_MAX + 1] = { - { - {ov5640_mode_VGA_640_480, 640, 480, - ov5640_setting_15fps_VGA_640_480, - ARRAY_SIZE(ov5640_setting_15fps_VGA_640_480)}, - {ov5640_mode_QVGA_320_240, 320, 240, - ov5640_setting_15fps_QVGA_320_240, - ARRAY_SIZE(ov5640_setting_15fps_QVGA_320_240)}, - {ov5640_mode_NTSC_720_480, 720, 480, - ov5640_setting_15fps_NTSC_720_480, - ARRAY_SIZE(ov5640_setting_15fps_NTSC_720_480)}, - {ov5640_mode_PAL_720_576, 720, 576, - ov5640_setting_15fps_PAL_720_576, - ARRAY_SIZE(ov5640_setting_15fps_PAL_720_576)}, - {ov5640_mode_720P_1280_720, 1280, 720, - ov5640_setting_15fps_720P_1280_720, - ARRAY_SIZE(ov5640_setting_15fps_720P_1280_720)}, - {ov5640_mode_1080P_1920_1080, 1920, 1080, - ov5640_setting_15fps_1080P_1920_1080, - ARRAY_SIZE(ov5640_setting_15fps_1080P_1920_1080)}, - {ov5640_mode_QSXGA_2592_1944, 2592, 1944, - ov5640_setting_15fps_QSXGA_2592_1944, - ARRAY_SIZE(ov5640_setting_15fps_QSXGA_2592_1944)}, - {ov5640_mode_QCIF_176_144, 176, 144, - ov5640_setting_15fps_QCIF_176_144, - ARRAY_SIZE(ov5640_setting_15fps_QCIF_176_144)}, - {ov5640_mode_XGA_1024_768, 1024, 768, - ov5640_setting_15fps_XGA_1024_768, - ARRAY_SIZE(ov5640_setting_15fps_XGA_1024_768)}, - }, - { - {ov5640_mode_VGA_640_480, 640, 480, - ov5640_setting_30fps_VGA_640_480, - ARRAY_SIZE(ov5640_setting_30fps_VGA_640_480)}, - {ov5640_mode_QVGA_320_240, 320, 240, - ov5640_setting_30fps_QVGA_320_240, - ARRAY_SIZE(ov5640_setting_30fps_QVGA_320_240)}, - {ov5640_mode_NTSC_720_480, 720, 480, - ov5640_setting_30fps_NTSC_720_480, - ARRAY_SIZE(ov5640_setting_30fps_NTSC_720_480)}, - {ov5640_mode_PAL_720_576, 720, 576, - ov5640_setting_30fps_PAL_720_576, - ARRAY_SIZE(ov5640_setting_30fps_PAL_720_576)}, - {ov5640_mode_720P_1280_720, 1280, 720, - ov5640_setting_30fps_720P_1280_720, - ARRAY_SIZE(ov5640_setting_30fps_720P_1280_720)}, - {ov5640_mode_1080P_1920_1080, 0, 0, NULL, 0}, - {ov5640_mode_QSXGA_2592_1944, 0, 0, NULL, 0}, - {ov5640_mode_QCIF_176_144, 176, 144, - ov5640_setting_30fps_QCIF_176_144, - ARRAY_SIZE(ov5640_setting_30fps_QCIF_176_144)}, - {ov5640_mode_XGA_1024_768, 1024, 768, - ov5640_setting_30fps_XGA_1024_768, - ARRAY_SIZE(ov5640_setting_30fps_XGA_1024_768)}, - }, -}; - -static struct regulator *io_regulator; -static struct regulator *core_regulator; -static struct regulator *analog_regulator; - -static int ov5640_probe(struct i2c_client *adapter, - const struct i2c_device_id *device_id); -static int ov5640_remove(struct i2c_client *client); - -static s32 ov5640_read_reg(u16 reg, u8 *val); -static s32 ov5640_write_reg(u16 reg, u8 val); - -static const struct i2c_device_id ov5640_id[] = { - {"ov5640", 0}, - {}, -}; - -MODULE_DEVICE_TABLE(i2c, ov5640_id); - -static struct i2c_driver ov5640_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "ov5640", - }, - .probe = ov5640_probe, - .remove = ov5640_remove, - .id_table = ov5640_id, -}; - -static const struct ov5640_datafmt ov5640_colour_fmts[] = { - {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}, -}; - -static struct ov5640 *to_ov5640(const struct i2c_client *client) -{ - return container_of(i2c_get_clientdata(client), struct ov5640, subdev); -} - -/* Find a data format by a pixel code in an array */ -static const struct ov5640_datafmt - *ov5640_find_datafmt(u32 code) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(ov5640_colour_fmts); i++) - if (ov5640_colour_fmts[i].code == code) - return ov5640_colour_fmts + i; - - return NULL; -} - -static inline void ov5640_power_down(int enable) -{ - gpio_set_value_cansleep(pwn_gpio, enable); - - msleep(2); -} - -static inline void ov5640_reset(void) -{ - /* camera reset */ - gpio_set_value_cansleep(rst_gpio, 1); - - /* camera power down */ - gpio_set_value_cansleep(pwn_gpio, 1); - msleep(5); - gpio_set_value_cansleep(pwn_gpio, 0); - msleep(5); - gpio_set_value_cansleep(rst_gpio, 0); - msleep(1); - gpio_set_value_cansleep(rst_gpio, 1); - msleep(5); - gpio_set_value_cansleep(pwn_gpio, 1); -} - -static int ov5640_regulator_enable(struct device *dev) -{ - int ret = 0; - - io_regulator = devm_regulator_get(dev, "DOVDD"); - if (!IS_ERR(io_regulator)) { - regulator_set_voltage(io_regulator, - OV5640_VOLTAGE_DIGITAL_IO, - OV5640_VOLTAGE_DIGITAL_IO); - ret = regulator_enable(io_regulator); - if (ret) { - dev_err(dev, "set io voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set io voltage ok\n"); - } - } else { - io_regulator = NULL; - dev_warn(dev, "cannot get io voltage\n"); - } - - core_regulator = devm_regulator_get(dev, "DVDD"); - if (!IS_ERR(core_regulator)) { - regulator_set_voltage(core_regulator, - OV5640_VOLTAGE_DIGITAL_CORE, - OV5640_VOLTAGE_DIGITAL_CORE); - ret = regulator_enable(core_regulator); - if (ret) { - dev_err(dev, "set core voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set core voltage ok\n"); - } - } else { - core_regulator = NULL; - dev_warn(dev, "cannot get core voltage\n"); - } - - analog_regulator = devm_regulator_get(dev, "AVDD"); - if (!IS_ERR(analog_regulator)) { - regulator_set_voltage(analog_regulator, - OV5640_VOLTAGE_ANALOG, - OV5640_VOLTAGE_ANALOG); - ret = regulator_enable(analog_regulator); - if (ret) { - dev_err(dev, "set analog voltage failed\n"); - return ret; - } else { - dev_dbg(dev, "set analog voltage ok\n"); - } - } else { - analog_regulator = NULL; - dev_warn(dev, "cannot get analog voltage\n"); - } - - return ret; -} - -static s32 ov5640_write_reg(u16 reg, u8 val) -{ - u8 au8Buf[3] = {0}; - - au8Buf[0] = reg >> 8; - au8Buf[1] = reg & 0xff; - au8Buf[2] = val; - - if (i2c_master_send(ov5640_data.i2c_client, au8Buf, 3) < 0) { - pr_err("%s:write reg error:reg=%x,val=%x\n", - __func__, reg, val); - return -1; - } - - return 0; -} - -static s32 ov5640_read_reg(u16 reg, u8 *val) -{ - u8 au8RegBuf[2] = {0}; - u8 u8RdVal = 0; - - au8RegBuf[0] = reg >> 8; - au8RegBuf[1] = reg & 0xff; - - if (2 != i2c_master_send(ov5640_data.i2c_client, au8RegBuf, 2)) { - pr_err("%s:write reg error:reg=%x\n", - __func__, reg); - return -1; - } - - if (1 != i2c_master_recv(ov5640_data.i2c_client, &u8RdVal, 1)) { - pr_err("%s:read reg error:reg=%x,val=%x\n", - __func__, reg, u8RdVal); - return -1; - } - - *val = u8RdVal; - - return u8RdVal; -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int ov5640_get_register(struct v4l2_subdev *sd, - struct v4l2_dbg_register *reg) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - int ret; - u8 val; - - if (reg->reg & ~0xffff) - return -EINVAL; - - reg->size = 1; - - ret = ov5640_read_reg(reg->reg, &val); - if (!ret) - reg->val = (__u64)val; - - return ret; -} - -static int ov5640_set_register(struct v4l2_subdev *sd, - const struct v4l2_dbg_register *reg) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (reg->reg & ~0xffff || reg->val & ~0xff) - return -EINVAL; - - return ov5640_write_reg(reg->reg, reg->val); -} -#endif - -static void ov5640_soft_reset(void) -{ - /* sysclk from pad */ - ov5640_write_reg(0x3103, 0x11); - - /* software reset */ - ov5640_write_reg(0x3008, 0x82); - - /* delay at least 5ms */ - msleep(10); -} - -/* set sensor driver capability - * 0x302c[7:6] - strength - 00 - 1x - 01 - 2x - 10 - 3x - 11 - 4x - */ -static int ov5640_driver_capability(int strength) -{ - u8 temp = 0; - - if (strength > 4 || strength < 1) { - pr_err("The valid driver capability of ov5640 is 1x~4x\n"); - return -EINVAL; - } - - ov5640_read_reg(0x302c, &temp); - - temp &= ~0xc0; /* clear [7:6] */ - temp |= ((strength - 1) << 6); /* set [7:6] */ - - ov5640_write_reg(0x302c, temp); - - return 0; -} - -/* calculate sysclk */ -static int ov5640_get_sysclk(void) -{ - int xvclk = ov5640_data.mclk / 10000; - int sysclk; - int temp1, temp2; - int Multiplier, PreDiv, VCO, SysDiv, Pll_rdiv, Bit_div2x, sclk_rdiv; - int sclk_rdiv_map[] = {1, 2, 4, 8}; - u8 regval = 0; - - temp1 = ov5640_read_reg(0x3034, ®val); - temp2 = temp1 & 0x0f; - if (temp2 == 8 || temp2 == 10) { - Bit_div2x = temp2 / 2; - } else { - pr_err("ov5640: unsupported bit mode %d\n", temp2); - return -1; - } - - temp1 = ov5640_read_reg(0x3035, ®val); - SysDiv = temp1 >> 4; - if (SysDiv == 0) - SysDiv = 16; - - temp1 = ov5640_read_reg(0x3036, ®val); - Multiplier = temp1; - temp1 = ov5640_read_reg(0x3037, ®val); - PreDiv = temp1 & 0x0f; - Pll_rdiv = ((temp1 >> 4) & 0x01) + 1; - - temp1 = ov5640_read_reg(0x3108, ®val); - temp2 = temp1 & 0x03; - - sclk_rdiv = sclk_rdiv_map[temp2]; - VCO = xvclk * Multiplier / PreDiv; - sysclk = VCO / SysDiv / Pll_rdiv * 2 / Bit_div2x / sclk_rdiv; - - return sysclk; -} - -/* read HTS from register settings */ -static int ov5640_get_HTS(void) -{ - int HTS; - u8 temp = 0; - - HTS = ov5640_read_reg(0x380c, &temp); - HTS = (HTS<<8) + ov5640_read_reg(0x380d, &temp); - return HTS; -} - -/* read VTS from register settings */ -static int ov5640_get_VTS(void) -{ - int VTS; - u8 temp = 0; - - VTS = ov5640_read_reg(0x380e, &temp); - VTS = (VTS<<8) + ov5640_read_reg(0x380f, &temp); - - return VTS; -} - -/* write VTS to registers */ -static int ov5640_set_VTS(int VTS) -{ - int temp; - - temp = VTS & 0xff; - ov5640_write_reg(0x380f, temp); - - temp = VTS>>8; - ov5640_write_reg(0x380e, temp); - return 0; -} - -/* read shutter, in number of line period */ -static int ov5640_get_shutter(void) -{ - int shutter; - u8 regval; - - shutter = (ov5640_read_reg(0x03500, ®val) & 0x0f); - - shutter = (shutter<<8) + ov5640_read_reg(0x3501, ®val); - shutter = (shutter<<4) + (ov5640_read_reg(0x3502, ®val)>>4); - - return shutter; -} - -/* write shutter, in number of line period */ -static int ov5640_set_shutter(int shutter) -{ - int temp; - - shutter = shutter & 0xffff; - temp = shutter & 0x0f; - temp = temp<<4; - ov5640_write_reg(0x3502, temp); - - temp = shutter & 0xfff; - temp = temp>>4; - ov5640_write_reg(0x3501, temp); - - temp = shutter>>12; - ov5640_write_reg(0x3500, temp); - - return 0; -} - -/* read gain, 16 = 1x */ -static int ov5640_get_gain16(void) -{ - int gain16; - u8 regval; - - gain16 = ov5640_read_reg(0x350a, ®val) & 0x03; - gain16 = (gain16<<8) + ov5640_read_reg(0x350b, ®val); - - return gain16; -} - -/* write gain, 16 = 1x */ -static int ov5640_set_gain16(int gain16) -{ - int temp; - - gain16 = gain16 & 0x3ff; - temp = gain16 & 0xff; - - ov5640_write_reg(0x350b, temp); - temp = gain16>>8; - - ov5640_write_reg(0x350a, temp); - return 0; -} - -/* get banding filter value */ -static int ov5640_get_light_freq(void) -{ - int temp, temp1, light_frequency; - u8 regval; - - temp = ov5640_read_reg(0x3c01, ®val); - if (temp & 0x80) { - /* manual */ - temp1 = ov5640_read_reg(0x3c00, ®val); - if (temp1 & 0x04) { - /* 50Hz */ - light_frequency = 50; - } else { - /* 60Hz */ - light_frequency = 60; - } - } else { - /* auto */ - temp1 = ov5640_read_reg(0x3c0c, ®val); - if (temp1 & 0x01) { - /* 50Hz */ - light_frequency = 50; - } else { - /* 60Hz */ - light_frequency = 60; - } - } - - return light_frequency; -} - -static void ov5640_set_bandingfilter(void) -{ - int prev_VTS; - int band_step60, max_band60, band_step50, max_band50; - - /* read preview PCLK */ - prev_sysclk = ov5640_get_sysclk(); - - /* read preview HTS */ - prev_HTS = ov5640_get_HTS(); - - /* read preview VTS */ - prev_VTS = ov5640_get_VTS(); - - /* calculate banding filter */ - /* 60Hz */ - band_step60 = prev_sysclk * 100/prev_HTS * 100/120; - ov5640_write_reg(0x3a0a, (band_step60 >> 8)); - ov5640_write_reg(0x3a0b, (band_step60 & 0xff)); - - max_band60 = (int)((prev_VTS-4)/band_step60); - ov5640_write_reg(0x3a0d, max_band60); - - /* 50Hz */ - band_step50 = prev_sysclk * 100/prev_HTS; - ov5640_write_reg(0x3a08, (band_step50 >> 8)); - ov5640_write_reg(0x3a09, (band_step50 & 0xff)); - - max_band50 = (int)((prev_VTS-4)/band_step50); - ov5640_write_reg(0x3a0e, max_band50); -} - -/* stable in high */ -static int ov5640_set_AE_target(int target) -{ - int fast_high, fast_low; - - AE_low = target * 23 / 25; /* 0.92 */ - AE_high = target * 27 / 25; /* 1.08 */ - fast_high = AE_high << 1; - - if (fast_high > 255) - fast_high = 255; - fast_low = AE_low >> 1; - - ov5640_write_reg(0x3a0f, AE_high); - ov5640_write_reg(0x3a10, AE_low); - ov5640_write_reg(0x3a1b, AE_high); - ov5640_write_reg(0x3a1e, AE_low); - ov5640_write_reg(0x3a11, fast_high); - ov5640_write_reg(0x3a1f, fast_low); - - return 0; -} - -/* enable = 0 to turn off night mode - enable = 1 to turn on night mode */ -static int ov5640_set_night_mode(int enable) -{ - u8 mode; - - ov5640_read_reg(0x3a00, &mode); - - if (enable) { - /* night mode on */ - mode |= 0x04; - ov5640_write_reg(0x3a00, mode); - } else { - /* night mode off */ - mode &= 0xfb; - ov5640_write_reg(0x3a00, mode); - } - - return 0; -} - -/* enable = 0 to turn off AEC/AGC - enable = 1 to turn on AEC/AGC */ -static void ov5640_turn_on_AE_AG(int enable) -{ - u8 ae_ag_ctrl; - - ov5640_read_reg(0x3503, &ae_ag_ctrl); - if (enable) { - /* turn on auto AE/AG */ - ae_ag_ctrl = ae_ag_ctrl & ~(0x03); - } else { - /* turn off AE/AG */ - ae_ag_ctrl = ae_ag_ctrl | 0x03; - } - ov5640_write_reg(0x3503, ae_ag_ctrl); -} - -/* download ov5640 settings to sensor through i2c */ -static int ov5640_download_firmware(struct reg_value *pModeSetting, s32 ArySize) -{ - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int i, retval = 0; - - for (i = 0; i < ArySize; ++i, ++pModeSetting) { - Delay_ms = pModeSetting->u32Delay_ms; - RegAddr = pModeSetting->u16RegAddr; - Val = pModeSetting->u8Val; - Mask = pModeSetting->u8Mask; - - if (Mask) { - retval = ov5640_read_reg(RegAddr, &RegVal); - if (retval < 0) - goto err; - - RegVal &= ~(u8)Mask; - Val &= Mask; - Val |= RegVal; - } - - retval = ov5640_write_reg(RegAddr, Val); - if (retval < 0) - goto err; - - if (Delay_ms) - msleep(Delay_ms); - } -err: - return retval; -} - -static int ov5640_init_mode(void) -{ - struct reg_value *pModeSetting = NULL; - int ArySize = 0, retval = 0; - - ov5640_soft_reset(); - - pModeSetting = ov5640_global_init_setting; - ArySize = ARRAY_SIZE(ov5640_global_init_setting); - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - pModeSetting = ov5640_init_setting_30fps_VGA; - ArySize = ARRAY_SIZE(ov5640_init_setting_30fps_VGA); - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - /* change driver capability to 2x according to validation board. - * if the image is not stable, please increase the driver strength. - */ - ov5640_driver_capability(2); - ov5640_set_bandingfilter(); - ov5640_set_AE_target(AE_Target); - ov5640_set_night_mode(night_mode); - - /* skip 9 vysnc: start capture at 10th vsync */ - msleep(300); - - /* turn off night mode */ - night_mode = 0; - ov5640_data.pix.width = 640; - ov5640_data.pix.height = 480; -err: - return retval; -} - -/* change to or back to subsampling mode set the mode directly - * image size below 1280 * 960 is subsampling mode */ -static int ov5640_change_mode_direct(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - - if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { - pr_err("Wrong ov5640 mode detected!\n"); - return -1; - } - - pModeSetting = ov5640_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5640_mode_info_data[frame_rate][mode].init_data_size; - - ov5640_data.pix.width = ov5640_mode_info_data[frame_rate][mode].width; - ov5640_data.pix.height = ov5640_mode_info_data[frame_rate][mode].height; - - if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - /* set ov5640 to subsampling mode */ - retval = ov5640_download_firmware(pModeSetting, ArySize); - - /* turn on AE AG for subsampling mode, in case the firmware didn't */ - ov5640_turn_on_AE_AG(1); - - /* calculate banding filter */ - ov5640_set_bandingfilter(); - - /* set AE target */ - ov5640_set_AE_target(AE_Target); - - /* update night mode setting */ - ov5640_set_night_mode(night_mode); - - /* skip 9 vysnc: start capture at 10th vsync */ - if (mode == ov5640_mode_XGA_1024_768 && frame_rate == ov5640_30_fps) { - pr_warning("ov5640: actual frame rate of XGA is 22.5fps\n"); - /* 1/22.5 * 9*/ - msleep(400); - return retval; - } - - if (frame_rate == ov5640_15_fps) { - /* 1/15 * 9*/ - msleep(600); - } else if (frame_rate == ov5640_30_fps) { - /* 1/30 * 9*/ - msleep(300); - } - - return retval; -} - -/* change to scaling mode go through exposure calucation - * image size above 1280 * 960 is scaling mode */ -static int ov5640_change_mode_exposure_calc(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - int prev_shutter, prev_gain16, average; - int cap_shutter, cap_gain16; - int cap_sysclk, cap_HTS, cap_VTS; - int light_freq, cap_bandfilt, cap_maxband; - long cap_gain16_shutter; - u8 temp; - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - - /* check if the input mode and frame rate is valid */ - pModeSetting = - ov5640_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5640_mode_info_data[frame_rate][mode].init_data_size; - - ov5640_data.pix.width = - ov5640_mode_info_data[frame_rate][mode].width; - ov5640_data.pix.height = - ov5640_mode_info_data[frame_rate][mode].height; - - if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - /* read preview shutter */ - prev_shutter = ov5640_get_shutter(); - - /* read preview gain */ - prev_gain16 = ov5640_get_gain16(); - - /* get average */ - average = ov5640_read_reg(0x56a1, &temp); - - /* turn off night mode for capture */ - ov5640_set_night_mode(0); - - /* turn off overlay */ - ov5640_write_reg(0x3022, 0x06); - - /* Write capture setting */ - retval = ov5640_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - /* turn off AE AG when capture image. */ - ov5640_turn_on_AE_AG(0); - - /* read capture VTS */ - cap_VTS = ov5640_get_VTS(); - cap_HTS = ov5640_get_HTS(); - cap_sysclk = ov5640_get_sysclk(); - - /* calculate capture banding filter */ - light_freq = ov5640_get_light_freq(); - if (light_freq == 60) { - /* 60Hz */ - cap_bandfilt = cap_sysclk * 100 / cap_HTS * 100 / 120; - } else { - /* 50Hz */ - cap_bandfilt = cap_sysclk * 100 / cap_HTS; - } - cap_maxband = (int)((cap_VTS - 4)/cap_bandfilt); - /* calculate capture shutter/gain16 */ - if (average > AE_low && average < AE_high) { - /* in stable range */ - cap_gain16_shutter = - prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * - prev_HTS/cap_HTS * AE_Target / average; - } else { - cap_gain16_shutter = - prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * - prev_HTS/cap_HTS; - } - - /* gain to shutter */ - if (cap_gain16_shutter < (cap_bandfilt * 16)) { - /* shutter < 1/100 */ - cap_shutter = cap_gain16_shutter/16; - if (cap_shutter < 1) - cap_shutter = 1; - cap_gain16 = cap_gain16_shutter/cap_shutter; - if (cap_gain16 < 16) - cap_gain16 = 16; - } else { - if (cap_gain16_shutter > (cap_bandfilt*cap_maxband*16)) { - /* exposure reach max */ - cap_shutter = cap_bandfilt*cap_maxband; - cap_gain16 = cap_gain16_shutter / cap_shutter; - } else { - /* 1/100 < cap_shutter =< max, cap_shutter = n/100 */ - cap_shutter = - ((int)(cap_gain16_shutter/16/cap_bandfilt)) - * cap_bandfilt; - cap_gain16 = cap_gain16_shutter / cap_shutter; - } - } - - /* write capture gain */ - ov5640_set_gain16(cap_gain16); - - /* write capture shutter */ - if (cap_shutter > (cap_VTS - 4)) { - cap_VTS = cap_shutter + 4; - ov5640_set_VTS(cap_VTS); - } - - ov5640_set_shutter(cap_shutter); - - /* skip 2 vysnc: start capture at 3rd vsync - * frame rate of QSXGA and 1080P is 7.5fps: 1/7.5 * 2 - */ - pr_warning("ov5640: the actual frame rate of %s is 7.5fps\n", - mode == ov5640_mode_1080P_1920_1080 ? "1080P" : "QSXGA"); - msleep(267); -err: - return retval; -} - -static int ov5640_change_mode(enum ov5640_frame_rate frame_rate, - enum ov5640_mode mode) -{ - int retval = 0; - - if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { - pr_err("Wrong ov5640 mode detected!\n"); - return -1; - } - - if (mode == ov5640_mode_1080P_1920_1080 || - mode == ov5640_mode_QSXGA_2592_1944) { - /* change to scaling mode go through exposure calucation - * image size above 1280 * 960 is scaling mode */ - retval = ov5640_change_mode_exposure_calc(frame_rate, mode); - } else { - /* change back to subsampling modem download firmware directly - * image size below 1280 * 960 is subsampling mode */ - retval = ov5640_change_mode_direct(frame_rate, mode); - } - - return retval; -} - -/*! - * ov5640_s_power - V4L2 sensor interface handler for VIDIOC_S_POWER ioctl - * @s: pointer to standard V4L2 device structure - * @on: indicates power mode (on or off) - * - * Turns the power on or off, depending on the value of on and returns the - * appropriate error code. - */ -static int ov5640_s_power(struct v4l2_subdev *sd, int on) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ov5640 *sensor = to_ov5640(client); - - if (on) - clk_enable(ov5640_data.sensor_clk); - else - clk_disable(ov5640_data.sensor_clk); - - sensor->on = on; - - return 0; -} - -/*! - * ov5640_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl - * @s: pointer to standard V4L2 sub device structure - * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure - * - * Returns the sensor's video CAPTURE parameters. - */ -static int ov5640_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ov5640 *sensor = to_ov5640(client); - struct v4l2_captureparm *cparm = &a->parm.capture; - int ret = 0; - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - memset(a, 0, sizeof(*a)); - a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cparm->capability = sensor->streamcap.capability; - cparm->timeperframe = sensor->streamcap.timeperframe; - cparm->capturemode = sensor->streamcap.capturemode; - ret = 0; - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ov5460_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl - * @s: pointer to standard V4L2 sub device structure - * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure - * - * Configures the sensor to use the input parameters, if possible. If - * not possible, reverts to the old parameters and returns the - * appropriate error code. - */ -static int ov5640_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ov5640 *sensor = to_ov5640(client); - struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; - u32 tgt_fps; /* target frames per secound */ - enum ov5640_frame_rate frame_rate; - int ret = 0; - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - /* Check that the new frame rate is allowed. */ - if ((timeperframe->numerator == 0) || - (timeperframe->denominator == 0)) { - timeperframe->denominator = DEFAULT_FPS; - timeperframe->numerator = 1; - } - - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps > MAX_FPS) { - timeperframe->denominator = MAX_FPS; - timeperframe->numerator = 1; - } else if (tgt_fps < MIN_FPS) { - timeperframe->denominator = MIN_FPS; - timeperframe->numerator = 1; - } - - /* Actual frame rate we use */ - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps == 15) - frame_rate = ov5640_15_fps; - else if (tgt_fps == 30) - frame_rate = ov5640_30_fps; - else { - pr_err(" The camera frame rate is not supported!\n"); - goto error; - } - - ret = ov5640_change_mode(frame_rate, - a->parm.capture.capturemode); - if (ret < 0) - goto error; - - sensor->streamcap.timeperframe = *timeperframe; - sensor->streamcap.capturemode = a->parm.capture.capturemode; - - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - pr_debug(" type is not " \ - "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", - a->type); - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - -error: - return ret; -} - -static int ov5640_set_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *format) -{ - struct v4l2_mbus_framefmt *mf = &format->format; - const struct ov5640_datafmt *fmt = ov5640_find_datafmt(mf->code); - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ov5640 *sensor = to_ov5640(client); - - if (format->pad) - return -EINVAL; - - if (!fmt) { - mf->code = ov5640_colour_fmts[0].code; - mf->colorspace = ov5640_colour_fmts[0].colorspace; - } - - mf->field = V4L2_FIELD_NONE; - - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - return 0; - - sensor->fmt = fmt; - - return 0; -} - -static int ov5640_get_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *format) -{ - struct v4l2_mbus_framefmt *mf = &format->format; - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ov5640 *sensor = to_ov5640(client); - const struct ov5640_datafmt *fmt = sensor->fmt; - - if (format->pad) - return -EINVAL; - - mf->code = fmt->code; - mf->colorspace = fmt->colorspace; - mf->field = V4L2_FIELD_NONE; - - return 0; -} - -static int ov5640_enum_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) -{ - if (code->pad || code->index >= ARRAY_SIZE(ov5640_colour_fmts)) - return -EINVAL; - - code->code = ov5640_colour_fmts[code->index].code; - return 0; -} - -/*! - * ov5640_enum_framesizes - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMESIZES ioctl - * @s: pointer to standard V4L2 device structure - * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ov5640_enum_framesizes(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) -{ - if (fse->index > ov5640_mode_MAX) - return -EINVAL; - - fse->max_width = - max(ov5640_mode_info_data[0][fse->index].width, - ov5640_mode_info_data[1][fse->index].width); - fse->min_width = fse->max_width; - fse->max_height = - max(ov5640_mode_info_data[0][fse->index].height, - ov5640_mode_info_data[1][fse->index].height); - fse->min_height = fse->max_height; - return 0; -} - -/*! - * ov5640_enum_frameintervals - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMEINTERVALS ioctl - * @s: pointer to standard V4L2 device structure - * @fival: standard V4L2 VIDIOC_ENUM_FRAMEINTERVALS ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ov5640_enum_frameintervals(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_interval_enum *fie) -{ - int i, j, count; - - if (fie->index < 0 || fie->index > ov5640_mode_MAX) - return -EINVAL; - - if (fie->width == 0 || fie->height == 0 || - fie->code == 0) { - pr_warning("Please assign pixel format, width and height.\n"); - return -EINVAL; - } - - fie->interval.numerator = 1; - - count = 0; - for (i = 0; i < ARRAY_SIZE(ov5640_mode_info_data); i++) { - for (j = 0; j < (ov5640_mode_MAX + 1); j++) { - if (fie->width == ov5640_mode_info_data[i][j].width - && fie->height == ov5640_mode_info_data[i][j].height - && ov5640_mode_info_data[i][j].init_data_ptr != NULL) { - count++; - } - if (fie->index == (count - 1)) { - fie->interval.denominator = - ov5640_framerates[i]; - return 0; - } - } - } - - return -EINVAL; -} - -static int ov5640_set_clk_rate(void) -{ - u32 tgt_xclk; /* target xclk */ - int ret; - - /* mclk */ - tgt_xclk = ov5640_data.mclk; - tgt_xclk = min(tgt_xclk, (u32)OV5640_XCLK_MAX); - tgt_xclk = max(tgt_xclk, (u32)OV5640_XCLK_MIN); - ov5640_data.mclk = tgt_xclk; - - pr_debug(" Setting mclk to %d MHz\n", tgt_xclk / 1000000); - ret = clk_set_rate(ov5640_data.sensor_clk, ov5640_data.mclk); - if (ret < 0) - pr_debug("set rate filed, rate=%d\n", ov5640_data.mclk); - return ret; -} - -/*! - * dev_init - V4L2 sensor init - * @s: pointer to standard V4L2 device structure - * - */ -static int init_device(void) -{ - u32 tgt_xclk; /* target xclk */ - u32 tgt_fps; /* target frames per secound */ - enum ov5640_frame_rate frame_rate; - int ret; - - ov5640_data.on = true; - - /* mclk */ - tgt_xclk = ov5640_data.mclk; - - /* Default camera frame rate is set in probe */ - tgt_fps = ov5640_data.streamcap.timeperframe.denominator / - ov5640_data.streamcap.timeperframe.numerator; - - if (tgt_fps == 15) - frame_rate = ov5640_15_fps; - else if (tgt_fps == 30) - frame_rate = ov5640_30_fps; - else - return -EINVAL; /* Only support 15fps or 30fps now. */ - - ret = ov5640_init_mode(); - - return ret; -} - -static struct v4l2_subdev_video_ops ov5640_subdev_video_ops = { - .g_parm = ov5640_g_parm, - .s_parm = ov5640_s_parm, -}; - -static const struct v4l2_subdev_pad_ops ov5640_subdev_pad_ops = { - .enum_frame_size = ov5640_enum_framesizes, - .enum_frame_interval = ov5640_enum_frameintervals, - .enum_mbus_code = ov5640_enum_code, - .set_fmt = ov5640_set_fmt, - .get_fmt = ov5640_get_fmt, -}; - -static struct v4l2_subdev_core_ops ov5640_subdev_core_ops = { - .s_power = ov5640_s_power, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .g_register = ov5640_get_register, - .s_register = ov5640_set_register, -#endif -}; - -static struct v4l2_subdev_ops ov5640_subdev_ops = { - .core = &ov5640_subdev_core_ops, - .video = &ov5640_subdev_video_ops, - .pad = &ov5640_subdev_pad_ops, -}; - -/*! - * ov5640 I2C probe function - * - * @param adapter struct i2c_adapter * - * @return Error code indicating success or failure - */ -static int ov5640_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct pinctrl *pinctrl; - struct device *dev = &client->dev; - int retval; - u8 chip_id_high, chip_id_low; - - /* ov5640 pinctrl */ - pinctrl = devm_pinctrl_get_select_default(dev); - if (IS_ERR(pinctrl)) { - dev_err(dev, "setup pinctrl failed\n"); - return PTR_ERR(pinctrl); - } - - /* request power down pin */ - pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); - if (!gpio_is_valid(pwn_gpio)) { - dev_err(dev, "no sensor pwdn pin available\n"); - return -ENODEV; - } - retval = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_pwdn"); - if (retval < 0) - return retval; - - /* request reset pin */ - rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0); - if (!gpio_is_valid(rst_gpio)) { - dev_err(dev, "no sensor reset pin available\n"); - return -EINVAL; - } - retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_HIGH, - "ov5640_reset"); - if (retval < 0) - return retval; - - /* Set initial values for the sensor struct. */ - memset(&ov5640_data, 0, sizeof(ov5640_data)); - ov5640_data.sensor_clk = devm_clk_get(dev, "csi_mclk"); - if (IS_ERR(ov5640_data.sensor_clk)) { - dev_err(dev, "get mclk failed\n"); - return PTR_ERR(ov5640_data.sensor_clk); - } - - retval = of_property_read_u32(dev->of_node, "mclk", - &ov5640_data.mclk); - if (retval) { - dev_err(dev, "mclk frequency is invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "mclk_source", - (u32 *) &(ov5640_data.mclk_source)); - if (retval) { - dev_err(dev, "mclk_source invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "csi_id", - &(ov5640_data.csi)); - if (retval) { - dev_err(dev, "csi_id invalid\n"); - return retval; - } - - /* Set mclk rate before clk on */ - ov5640_set_clk_rate(); - - clk_prepare_enable(ov5640_data.sensor_clk); - - ov5640_data.io_init = ov5640_reset; - ov5640_data.i2c_client = client; - ov5640_data.pix.pixelformat = V4L2_PIX_FMT_YUYV; - ov5640_data.pix.width = 640; - ov5640_data.pix.height = 480; - ov5640_data.streamcap.capability = V4L2_MODE_HIGHQUALITY | - V4L2_CAP_TIMEPERFRAME; - ov5640_data.streamcap.capturemode = 0; - ov5640_data.streamcap.timeperframe.denominator = DEFAULT_FPS; - ov5640_data.streamcap.timeperframe.numerator = 1; - - ov5640_regulator_enable(&client->dev); - - ov5640_reset(); - - ov5640_power_down(0); - - retval = ov5640_read_reg(OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high); - if (retval < 0 || chip_id_high != 0x56) { - clk_disable_unprepare(ov5640_data.sensor_clk); - pr_warning("camera ov5640 is not found\n"); - return -ENODEV; - } - retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low); - if (retval < 0 || chip_id_low != 0x40) { - clk_disable_unprepare(ov5640_data.sensor_clk); - pr_warning("camera ov5640 is not found\n"); - return -ENODEV; - } - - retval = init_device(); - if (retval < 0) { - clk_disable_unprepare(ov5640_data.sensor_clk); - pr_warning("camera ov5640 init failed\n"); - ov5640_power_down(1); - return retval; - } - - clk_disable(ov5640_data.sensor_clk); - - v4l2_i2c_subdev_init(&ov5640_data.subdev, client, &ov5640_subdev_ops); - - retval = v4l2_async_register_subdev(&ov5640_data.subdev); - if (retval < 0) - dev_err(&client->dev, - "%s--Async register failed, ret=%d\n", __func__, retval); - - pr_info("camera ov5640, is found\n"); - return retval; -} - -/*! - * ov5640 I2C detach function - * - * @param client struct i2c_client * - * @return Error code indicating success or failure - */ -static int ov5640_remove(struct i2c_client *client) -{ - struct v4l2_subdev *sd = i2c_get_clientdata(client); - - v4l2_async_unregister_subdev(sd); - - clk_unprepare(ov5640_data.sensor_clk); - - ov5640_power_down(1); - - if (analog_regulator) - regulator_disable(analog_regulator); - - if (core_regulator) - regulator_disable(core_regulator); - - if (io_regulator) - regulator_disable(io_regulator); - - return 0; -} - -module_i2c_driver(ov5640_i2c_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("OV5640 Camera Driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("CSI"); diff --git a/drivers/media/platform/mxc/capture/ov5642.c b/drivers/media/platform/mxc/capture/ov5642.c deleted file mode 100644 index be6122205c189545dae159a93faeab29b55ffc8e..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ov5642.c +++ /dev/null @@ -1,4252 +0,0 @@ -/* - * Copyright (C) 2012-2014 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * 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. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "v4l2-int-device.h" -#include "mxc_v4l2_capture.h" - -#define OV5642_VOLTAGE_ANALOG 2800000 -#define OV5642_VOLTAGE_DIGITAL_CORE 1500000 -#define OV5642_VOLTAGE_DIGITAL_IO 1800000 - -#define MIN_FPS 15 -#define MAX_FPS 30 -#define DEFAULT_FPS 30 - -#define OV5642_XCLK_MIN 6000000 -#define OV5642_XCLK_MAX 24000000 - -#define OV5642_CHIP_ID_HIGH_BYTE 0x300A -#define OV5642_CHIP_ID_LOW_BYTE 0x300B - -enum ov5642_mode { - ov5642_mode_MIN = 0, - ov5642_mode_VGA_640_480 = 0, - ov5642_mode_QVGA_320_240 = 1, - ov5642_mode_NTSC_720_480 = 2, - ov5642_mode_PAL_720_576 = 3, - ov5642_mode_720P_1280_720 = 4, - ov5642_mode_1080P_1920_1080 = 5, - ov5642_mode_QSXGA_2592_1944 = 6, - ov5642_mode_QCIF_176_144 = 7, - ov5642_mode_XGA_1024_768 = 8, - ov5642_mode_MAX = 8 -}; - -enum ov5642_frame_rate { - ov5642_15_fps, - ov5642_30_fps -}; - -static int ov5642_framerates[] = { - [ov5642_15_fps] = 15, - [ov5642_30_fps] = 30, -}; - -struct reg_value { - u16 u16RegAddr; - u8 u8Val; - u8 u8Mask; - u32 u32Delay_ms; -}; - -struct ov5642_mode_info { - enum ov5642_mode mode; - u32 width; - u32 height; - struct reg_value *init_data_ptr; - u32 init_data_size; -}; - -/*! - * Maintains the information on the current state of the sesor. - */ -static struct sensor_data ov5642_data; -static int pwn_gpio, rst_gpio; - -static struct reg_value ov5642_rot_none_VGA[] = { - {0x3818, 0xc1, 0x00, 0x00}, {0x3621, 0x87, 0x00, 0x00}, -}; - -static struct reg_value ov5642_rot_vert_flip_VGA[] = { - {0x3818, 0x20, 0xbf, 0x00}, {0x3621, 0x20, 0xff, 0x00}, -}; - -static struct reg_value ov5642_rot_horiz_flip_VGA[] = { - {0x3818, 0x81, 0x00, 0x01}, {0x3621, 0xa7, 0x00, 0x00}, -}; - -static struct reg_value ov5642_rot_180_VGA[] = { - {0x3818, 0x60, 0xff, 0x00}, {0x3621, 0x00, 0xdf, 0x00}, -}; - - -static struct reg_value ov5642_rot_none_FULL[] = { - {0x3818, 0xc0, 0x00, 0x00}, {0x3621, 0x09, 0x00, 0x00}, -}; - -static struct reg_value ov5642_rot_vert_flip_FULL[] = { - {0x3818, 0x20, 0xbf, 0x01}, {0x3621, 0x20, 0xff, 0x00}, -}; - -static struct reg_value ov5642_rot_horiz_flip_FULL[] = { - {0x3818, 0x80, 0x00, 0x01}, {0x3621, 0x29, 0x00, 0x00}, -}; - -static struct reg_value ov5642_rot_180_FULL[] = { - {0x3818, 0x60, 0xff, 0x00}, {0x3621, 0x00, 0xdf, 0x00}, -}; - - -static struct reg_value ov5642_initial_setting[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, - {0x3006, 0x43, 0, 0}, {0x3007, 0x37, 0, 0}, {0x3011, 0x08, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x22, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c00, 0x04, 0, 0}, {0x3c01, 0x80, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, - {0x5182, 0x00, 0, 0}, {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, - {0x5001, 0xff, 0, 0}, {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, - {0x5505, 0x7f, 0, 0}, {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, - {0x4610, 0x00, 0, 0}, {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, - {0x350b, 0x00, 0, 0}, {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x0c, 0, 0}, {0x380d, 0x80, 0, 0}, {0x380e, 0x03, 0, 0}, - {0x380f, 0xe8, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x08, 0, 0}, {0x3810, 0x40, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x0b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 300}, -}; - -static struct reg_value ov5642_setting_15fps_QCIF_176_144[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, - {0x3006, 0x43, 0, 0}, {0x3007, 0x37, 0, 0}, {0x3011, 0x08, 0, 0}, - {0x3010, 0x10, 0, 0}, {0x460c, 0x22, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3501, 0x1e, 0, 0}, - {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, {0x380c, 0x0c, 0, 0}, - {0x380d, 0x80, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3818, 0xc1, 0, 0}, - {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, {0x3801, 0x80, 0, 0}, - {0x3621, 0x87, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3803, 0x08, 0, 0}, - {0x3827, 0x08, 0, 0}, {0x3810, 0x40, 0, 0}, {0x3804, 0x05, 0, 0}, - {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, - {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, {0x5686, 0x03, 0, 0}, - {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x05, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, - {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, {0x3502, 0x00, 0, 0}, - {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, {0x3503, 0x00, 0, 0}, - {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, {0x528f, 0x10, 0, 0}, - {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x02, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x02, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x02, 0, 0}, - {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3c, 0, 0}, - {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, {0x3a03, 0x7d, 0, 0}, - {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, {0x3a15, 0x7d, 0, 0}, - {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a08, 0x09, 0, 0}, - {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, {0x3a0b, 0xd0, 0, 0}, - {0x3a0d, 0x08, 0, 0}, {0x3a0e, 0x06, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, {0x401e, 0x20, 0, 0}, - {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, {0x528a, 0x01, 0, 0}, - {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, {0x528d, 0x10, 0, 0}, - {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, {0x5290, 0x30, 0, 0}, - {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, {0x5294, 0x00, 0, 0}, - {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, {0x5297, 0x08, 0, 0}, - {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, {0x529a, 0x00, 0, 0}, - {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, {0x529d, 0x28, 0, 0}, - {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, {0x5282, 0x00, 0, 0}, - {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, {0x5302, 0x00, 0, 0}, - {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, {0x530d, 0x0c, 0, 0}, - {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, {0x5310, 0x20, 0, 0}, - {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, {0x5309, 0x40, 0, 0}, - {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, {0x5306, 0x00, 0, 0}, - {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, {0x5315, 0x20, 0, 0}, - {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, {0x5317, 0x00, 0, 0}, - {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, {0x5381, 0x00, 0, 0}, - {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, {0x5384, 0x00, 0, 0}, - {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, {0x5387, 0x00, 0, 0}, - {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, {0x538a, 0x00, 0, 0}, - {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, {0x538d, 0x00, 0, 0}, - {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, {0x5390, 0x00, 0, 0}, - {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, {0x5393, 0xa2, 0, 0}, - {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, {0x5481, 0x21, 0, 0}, - {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, {0x5484, 0x65, 0, 0}, - {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, {0x5487, 0x87, 0, 0}, - {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, {0x548a, 0xaa, 0, 0}, - {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, {0x548d, 0xdd, 0, 0}, - {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, {0x5490, 0x05, 0, 0}, - {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, {0x5493, 0x20, 0, 0}, - {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, {0x5496, 0x02, 0, 0}, - {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, {0x5499, 0x86, 0, 0}, - {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, {0x549c, 0x02, 0, 0}, - {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, {0x549f, 0x1c, 0, 0}, - {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, {0x54a2, 0x01, 0, 0}, - {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, {0x54a5, 0xc5, 0, 0}, - {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, {0x54a8, 0x01, 0, 0}, - {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, {0x54ab, 0x41, 0, 0}, - {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, {0x54ae, 0x00, 0, 0}, - {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, {0x54b1, 0x20, 0, 0}, - {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, {0x54b4, 0x00, 0, 0}, - {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, {0x54b7, 0xdf, 0, 0}, - {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, {0x3406, 0x00, 0, 0}, - {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, {0x5182, 0x11, 0, 0}, - {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, - {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, {0x5188, 0x08, 0, 0}, - {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, {0x518b, 0xb2, 0, 0}, - {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, {0x518e, 0x3d, 0, 0}, - {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, {0x5191, 0xf8, 0, 0}, - {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x5194, 0xf0, 0, 0}, - {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, {0x5197, 0x01, 0, 0}, - {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, {0x519a, 0x04, 0, 0}, - {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, {0x519d, 0x82, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, {0x3a0f, 0x38, 0, 0}, - {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, {0x3a1e, 0x2e, 0, 0}, - {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, {0x5688, 0xa6, 0, 0}, - {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, {0x568b, 0xae, 0, 0}, - {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, {0x568e, 0x62, 0, 0}, - {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x40, 0, 0}, - {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, {0x5800, 0x27, 0, 0}, - {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, {0x5803, 0x0f, 0, 0}, - {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, {0x5806, 0x1e, 0, 0}, - {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, {0x5809, 0x0d, 0, 0}, - {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, {0x580c, 0x0a, 0, 0}, - {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, {0x580f, 0x19, 0, 0}, - {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, {0x5812, 0x04, 0, 0}, - {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, {0x5815, 0x06, 0, 0}, - {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, {0x5818, 0x0a, 0, 0}, - {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, {0x581b, 0x00, 0, 0}, - {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, {0x581e, 0x08, 0, 0}, - {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, {0x5821, 0x05, 0, 0}, - {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, {0x5824, 0x00, 0, 0}, - {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, {0x5827, 0x0c, 0, 0}, - {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, {0x582a, 0x06, 0, 0}, - {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, {0x582d, 0x07, 0, 0}, - {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, {0x5830, 0x18, 0, 0}, - {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, {0x5833, 0x0a, 0, 0}, - {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, {0x5836, 0x15, 0, 0}, - {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, {0x5839, 0x1f, 0, 0}, - {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, {0x583c, 0x17, 0, 0}, - {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, {0x583f, 0x53, 0, 0}, - {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, {0x5842, 0x0d, 0, 0}, - {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, {0x5845, 0x09, 0, 0}, - {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, {0x5848, 0x10, 0, 0}, - {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, {0x584b, 0x0e, 0, 0}, - {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, {0x584e, 0x11, 0, 0}, - {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, {0x5851, 0x0c, 0, 0}, - {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, {0x5854, 0x10, 0, 0}, - {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, {0x5857, 0x0b, 0, 0}, - {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, {0x585a, 0x0d, 0, 0}, - {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, {0x585d, 0x0c, 0, 0}, - {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, {0x5860, 0x0c, 0, 0}, - {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, {0x5863, 0x08, 0, 0}, - {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, {0x5866, 0x18, 0, 0}, - {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, {0x5869, 0x19, 0, 0}, - {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, {0x586c, 0x13, 0, 0}, - {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, {0x586f, 0x16, 0, 0}, - {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, {0x5872, 0x10, 0, 0}, - {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, {0x5875, 0x16, 0, 0}, - {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, {0x5878, 0x10, 0, 0}, - {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, {0x587b, 0x14, 0, 0}, - {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, {0x587e, 0x11, 0, 0}, - {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, {0x5881, 0x15, 0, 0}, - {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, {0x5884, 0x15, 0, 0}, - {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, {0x5887, 0x17, 0, 0}, - {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, {0x3702, 0x10, 0, 0}, - {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, {0x370b, 0x40, 0, 0}, - {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, {0x3632, 0x52, 0, 0}, - {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, {0x5785, 0x07, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, {0x3604, 0x48, 0, 0}, - {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, {0x370f, 0xc0, 0, 0}, - {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, {0x5007, 0x00, 0, 0}, - {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, {0x5013, 0x00, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, {0x5087, 0x00, 0, 0}, - {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, {0x302b, 0x00, 0, 0}, - {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0x90, 0, 0}, {0x3a00, 0x78, 0, 0}, -}; - -static struct reg_value ov5642_setting_30fps_QCIF_176_144[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, - {0x3006, 0x43, 0, 0}, {0x3007, 0x37, 0, 0}, {0x3011, 0x10, 0, 0}, - {0x3010, 0x10, 0, 0}, {0x460c, 0x22, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3501, 0x1e, 0, 0}, - {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, {0x380c, 0x0c, 0, 0}, - {0x380d, 0x80, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3818, 0xc1, 0, 0}, - {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, {0x3801, 0x80, 0, 0}, - {0x3621, 0x87, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3803, 0x08, 0, 0}, - {0x3827, 0x08, 0, 0}, {0x3810, 0x40, 0, 0}, {0x3804, 0x05, 0, 0}, - {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, - {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, {0x5686, 0x03, 0, 0}, - {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x05, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, - {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, {0x3502, 0x00, 0, 0}, - {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, {0x3503, 0x00, 0, 0}, - {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, {0x528f, 0x10, 0, 0}, - {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x02, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x02, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x02, 0, 0}, - {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3c, 0, 0}, - {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, {0x3a03, 0x7d, 0, 0}, - {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, {0x3a15, 0x7d, 0, 0}, - {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a08, 0x09, 0, 0}, - {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, {0x3a0b, 0xd0, 0, 0}, - {0x3a0d, 0x08, 0, 0}, {0x3a0e, 0x06, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, {0x401e, 0x20, 0, 0}, - {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, {0x528a, 0x01, 0, 0}, - {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, {0x528d, 0x10, 0, 0}, - {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, {0x5290, 0x30, 0, 0}, - {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, {0x5294, 0x00, 0, 0}, - {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, {0x5297, 0x08, 0, 0}, - {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, {0x529a, 0x00, 0, 0}, - {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, {0x529d, 0x28, 0, 0}, - {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, {0x5282, 0x00, 0, 0}, - {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, {0x5302, 0x00, 0, 0}, - {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, {0x530d, 0x0c, 0, 0}, - {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, {0x5310, 0x20, 0, 0}, - {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, {0x5309, 0x40, 0, 0}, - {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, {0x5306, 0x00, 0, 0}, - {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, {0x5315, 0x20, 0, 0}, - {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, {0x5317, 0x00, 0, 0}, - {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, {0x5381, 0x00, 0, 0}, - {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, {0x5384, 0x00, 0, 0}, - {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, {0x5387, 0x00, 0, 0}, - {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, {0x538a, 0x00, 0, 0}, - {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, {0x538d, 0x00, 0, 0}, - {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, {0x5390, 0x00, 0, 0}, - {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, {0x5393, 0xa2, 0, 0}, - {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, {0x5481, 0x21, 0, 0}, - {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, {0x5484, 0x65, 0, 0}, - {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, {0x5487, 0x87, 0, 0}, - {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, {0x548a, 0xaa, 0, 0}, - {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, {0x548d, 0xdd, 0, 0}, - {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, {0x5490, 0x05, 0, 0}, - {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, {0x5493, 0x20, 0, 0}, - {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, {0x5496, 0x02, 0, 0}, - {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, {0x5499, 0x86, 0, 0}, - {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, {0x549c, 0x02, 0, 0}, - {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, {0x549f, 0x1c, 0, 0}, - {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, {0x54a2, 0x01, 0, 0}, - {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, {0x54a5, 0xc5, 0, 0}, - {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, {0x54a8, 0x01, 0, 0}, - {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, {0x54ab, 0x41, 0, 0}, - {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, {0x54ae, 0x00, 0, 0}, - {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, {0x54b1, 0x20, 0, 0}, - {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, {0x54b4, 0x00, 0, 0}, - {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, {0x54b7, 0xdf, 0, 0}, - {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, {0x3406, 0x00, 0, 0}, - {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, {0x5182, 0x11, 0, 0}, - {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, - {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, {0x5188, 0x08, 0, 0}, - {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, {0x518b, 0xb2, 0, 0}, - {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, {0x518e, 0x3d, 0, 0}, - {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, {0x5191, 0xf8, 0, 0}, - {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x5194, 0xf0, 0, 0}, - {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, {0x5197, 0x01, 0, 0}, - {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, {0x519a, 0x04, 0, 0}, - {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, {0x519d, 0x82, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, {0x3a0f, 0x38, 0, 0}, - {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, {0x3a1e, 0x2e, 0, 0}, - {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, {0x5688, 0xa6, 0, 0}, - {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, {0x568b, 0xae, 0, 0}, - {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, {0x568e, 0x62, 0, 0}, - {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x40, 0, 0}, - {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, {0x5800, 0x27, 0, 0}, - {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, {0x5803, 0x0f, 0, 0}, - {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, {0x5806, 0x1e, 0, 0}, - {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, {0x5809, 0x0d, 0, 0}, - {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, {0x580c, 0x0a, 0, 0}, - {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, {0x580f, 0x19, 0, 0}, - {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, {0x5812, 0x04, 0, 0}, - {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, {0x5815, 0x06, 0, 0}, - {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, {0x5818, 0x0a, 0, 0}, - {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, {0x581b, 0x00, 0, 0}, - {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, {0x581e, 0x08, 0, 0}, - {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, {0x5821, 0x05, 0, 0}, - {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, {0x5824, 0x00, 0, 0}, - {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, {0x5827, 0x0c, 0, 0}, - {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, {0x582a, 0x06, 0, 0}, - {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, {0x582d, 0x07, 0, 0}, - {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, {0x5830, 0x18, 0, 0}, - {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, {0x5833, 0x0a, 0, 0}, - {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, {0x5836, 0x15, 0, 0}, - {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, {0x5839, 0x1f, 0, 0}, - {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, {0x583c, 0x17, 0, 0}, - {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, {0x583f, 0x53, 0, 0}, - {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, {0x5842, 0x0d, 0, 0}, - {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, {0x5845, 0x09, 0, 0}, - {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, {0x5848, 0x10, 0, 0}, - {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, {0x584b, 0x0e, 0, 0}, - {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, {0x584e, 0x11, 0, 0}, - {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, {0x5851, 0x0c, 0, 0}, - {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, {0x5854, 0x10, 0, 0}, - {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, {0x5857, 0x0b, 0, 0}, - {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, {0x585a, 0x0d, 0, 0}, - {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, {0x585d, 0x0c, 0, 0}, - {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, {0x5860, 0x0c, 0, 0}, - {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, {0x5863, 0x08, 0, 0}, - {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, {0x5866, 0x18, 0, 0}, - {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, {0x5869, 0x19, 0, 0}, - {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, {0x586c, 0x13, 0, 0}, - {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, {0x586f, 0x16, 0, 0}, - {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, {0x5872, 0x10, 0, 0}, - {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, {0x5875, 0x16, 0, 0}, - {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, {0x5878, 0x10, 0, 0}, - {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, {0x587b, 0x14, 0, 0}, - {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, {0x587e, 0x11, 0, 0}, - {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, {0x5881, 0x15, 0, 0}, - {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, {0x5884, 0x15, 0, 0}, - {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, {0x5887, 0x17, 0, 0}, - {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, {0x3702, 0x10, 0, 0}, - {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, {0x370b, 0x40, 0, 0}, - {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, {0x3632, 0x52, 0, 0}, - {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, {0x5785, 0x07, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, {0x3604, 0x48, 0, 0}, - {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, {0x370f, 0xc0, 0, 0}, - {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, {0x5007, 0x00, 0, 0}, - {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, {0x5013, 0x00, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, {0x5087, 0x00, 0, 0}, - {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, {0x302b, 0x00, 0, 0}, - {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0x90, 0, 0}, {0x3a00, 0x78, 0, 0}, -}; - -static struct reg_value ov5642_setting_15fps_QSXGA_2592_1944[] = { - {0x3503, 0x07, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, - {0x3002, 0x00, 0, 0}, {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, - {0x3005, 0xff, 0, 0}, {0x3006, 0xff, 0, 0}, {0x3007, 0x3f, 0, 0}, - {0x3011, 0x08, 0, 0}, {0x3010, 0x10, 0, 0}, {0x3818, 0xc0, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, - {0x3602, 0xe4, 0, 0}, {0x3612, 0xac, 0, 0}, {0x3613, 0x44, 0, 0}, - {0x3622, 0x60, 0, 0}, {0x3623, 0x22, 0, 0}, {0x3604, 0x48, 0, 0}, - {0x3705, 0xda, 0, 0}, {0x370a, 0x80, 0, 0}, {0x3801, 0x95, 0, 0}, - {0x3803, 0x0e, 0, 0}, {0x3804, 0x0a, 0, 0}, {0x3805, 0x20, 0, 0}, - {0x3806, 0x07, 0, 0}, {0x3807, 0x98, 0, 0}, {0x3808, 0x0a, 0, 0}, - {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, - {0x380c, 0x0c, 0, 0}, {0x380d, 0x80, 0, 0}, {0x380e, 0x07, 0, 0}, - {0x380f, 0xd0, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3815, 0x44, 0, 0}, - {0x3824, 0x11, 0, 0}, {0x3825, 0xac, 0, 0}, {0x3827, 0x0c, 0, 0}, - {0x3a00, 0x78, 0, 0}, {0x3a0d, 0x10, 0, 0}, {0x3a0e, 0x0d, 0, 0}, - {0x5682, 0x0a, 0, 0}, {0x5683, 0x20, 0, 0}, {0x5686, 0x07, 0, 0}, - {0x5687, 0x98, 0, 0}, {0x5001, 0xff, 0, 0}, {0x589b, 0x00, 0, 0}, - {0x589a, 0xc0, 0, 0}, {0x4407, 0x04, 0, 0}, {0x3008, 0x02, 0, 0}, - {0x460b, 0x37, 0, 0}, {0x460c, 0x22, 0, 0}, {0x471d, 0x05, 0, 0}, - {0x4713, 0x03, 0, 0}, {0x471c, 0xd0, 0, 0}, {0x3815, 0x01, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3819, 0x80, 0, 0}, - {0x5002, 0xe0, 0, 0}, {0x530a, 0x01, 0, 0}, {0x530d, 0x10, 0, 0}, - {0x530c, 0x04, 0, 0}, {0x5312, 0x20, 0, 0}, {0x5282, 0x01, 0, 0}, - {0x3010, 0x10, 0, 0}, {0x3012, 0x00, 0, 0}, -}; - - -static struct reg_value ov5642_setting_VGA_2_QVGA[] = { - {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0xf0, 0, 0}, {0x3815, 0x04, 0, 0}, -}; - -static struct reg_value ov5642_setting_QSXGA_2_VGA[] = { - {0x3503, 0x00, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, - {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, - {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, {0x3007, 0x37, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x3818, 0xc1, 0, 0}, {0x3621, 0x87, 0, 0}, - {0x350c, 0x03, 0, 0}, {0x350d, 0xe8, 0, 0}, {0x3602, 0xfc, 0, 0}, - {0x3612, 0xff, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3622, 0x60, 0, 0}, - {0x3623, 0x01, 0, 0}, {0x3604, 0x48, 0, 0}, {0x3705, 0xdb, 0, 0}, - {0x370a, 0x81, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3803, 0x08, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, - {0x3807, 0xc0, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, - {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x0c, 0, 0}, - {0x380d, 0x80, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, - {0x3810, 0x40, 0, 0}, {0x3815, 0x04, 0, 0}, {0x3824, 0x11, 0, 0}, - {0x3825, 0xb4, 0, 0}, {0x3827, 0x08, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x5686, 0x03, 0, 0}, {0x5687, 0xbc, 0, 0}, - {0x5001, 0xff, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x4407, 0x0c, 0, 0}, {0x3008, 0x02, 0, 0}, {0x460b, 0x37, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x471d, 0x05, 0, 0}, {0x4713, 0x02, 0, 0}, - {0x471c, 0xd0, 0, 0}, {0x3815, 0x04, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x3002, 0x5c, 0, 0}, {0x3819, 0x80, 0, 0}, {0x5002, 0xe0, 0, 0}, - {0x530a, 0x01, 0, 0}, {0x530d, 0x0c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x5312, 0x40, 0, 0}, {0x5282, 0x00, 0, 0}, - {0x3012, 0x02, 0, 0}, {0x3010, 0x00, 0, 0}, -}; - -static struct reg_value ov5642_setting_30fps_VGA_640_480[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3615, 0xf0, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, - {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, - {0x3007, 0x37, 0, 0}, {0x3011, 0x09, 0, 0}, {0x3012, 0x02, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3825, 0xb0, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x07, 0, 0}, {0x380d, 0x2a, 0, 0}, {0x380e, 0x03, 0, 0}, - {0x380f, 0xe8, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0xc7, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x08, 0, 0}, {0x3810, 0x80, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3a00, 0x78, 0, 0}, -}; - -static struct reg_value ov5642_setting_15fps_VGA_640_480[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3615, 0xf0, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, - {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, - {0x3007, 0x37, 0, 0}, {0x3011, 0x09, 0, 0}, {0x3012, 0x02, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3825, 0xb0, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x07, 0, 0}, {0x380d, 0x2a, 0, 0}, {0x380e, 0x07, 0, 0}, - {0x380f, 0xd0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0xc7, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x08, 0, 0}, {0x3810, 0x80, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3a00, 0x78, 0, 0}, -}; - - -static struct reg_value ov5642_setting_30fps_XGA_1024_768[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3615, 0xf0, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, - {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, - {0x3007, 0x37, 0, 0}, {0x3011, 0x09, 0, 0}, {0x3012, 0x02, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3825, 0xb0, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x07, 0, 0}, {0x380d, 0x2a, 0, 0}, {0x380e, 0x03, 0, 0}, - {0x380f, 0xe8, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0xc7, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x08, 0, 0}, {0x3810, 0x80, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x03, 0, 0}, - {0x380b, 0x00, 0, 0}, {0x3815, 0x02, 0, 0}, {0x302c, 0x60, 0x60, 0}, -}; - -static struct reg_value ov5642_setting_15fps_XGA_1024_768[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3615, 0xf0, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, - {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, - {0x3007, 0x37, 0, 0}, {0x3011, 0x09, 0, 0}, {0x3012, 0x02, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3825, 0xb0, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x07, 0, 0}, {0x380d, 0x2a, 0, 0}, {0x380e, 0x07, 0, 0}, - {0x380f, 0xd0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0xc7, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x08, 0, 0}, {0x3810, 0x80, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x03, 0, 0}, - {0x380b, 0x00, 0, 0}, {0x3815, 0x02, 0, 0}, {0x302c, 0x60, 0x60, 0}, -}; - -static struct reg_value ov5642_setting_30fps_QVGA_320_240[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3615, 0xf0, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, - {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, - {0x3007, 0x37, 0, 0}, {0x3011, 0x09, 0, 0}, {0x3012, 0x02, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3825, 0xb0, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x07, 0, 0}, {0x380d, 0x2a, 0, 0}, {0x380e, 0x03, 0, 0}, - {0x380f, 0xe8, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0xc7, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x08, 0, 0}, {0x3810, 0x80, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3808, 0x01, 0, 0}, - {0x3809, 0x40, 0, 0}, {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, -}; - -static struct reg_value ov5642_setting_30fps_NTSC_720_480[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3615, 0xf0, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, - {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, - {0x3007, 0x37, 0, 0}, {0x3011, 0x09, 0, 0}, {0x3012, 0x02, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0xd0, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3825, 0xb0, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x07, 0, 0}, {0x380d, 0x2a, 0, 0}, {0x380e, 0x03, 0, 0}, - {0x380f, 0xe8, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0xc7, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x3c, 0, 0}, {0x3810, 0x80, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, - {0x5683, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0x58, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0x58, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x302c, 0x60, 0x60, 0}, -}; - -static struct reg_value ov5642_setting_30fps_PAL_720_576[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3615, 0xf0, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, {0x3003, 0x00, 0, 0}, - {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, {0x3006, 0x43, 0, 0}, - {0x3007, 0x37, 0, 0}, {0x3011, 0x09, 0, 0}, {0x3012, 0x02, 0, 0}, - {0x3010, 0x00, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0xd0, 0, 0}, {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3825, 0xd8, 0, 0}, - {0x3501, 0x1e, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, - {0x380c, 0x07, 0, 0}, {0x380d, 0x2a, 0, 0}, {0x380e, 0x03, 0, 0}, - {0x380f, 0xe8, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x3818, 0xc1, 0, 0}, {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, - {0x3801, 0x80, 0, 0}, {0x3621, 0xc7, 0, 0}, {0x3801, 0x50, 0, 0}, - {0x3803, 0x08, 0, 0}, {0x3827, 0x3c, 0, 0}, {0x3810, 0x80, 0, 0}, - {0x3804, 0x04, 0, 0}, {0x3805, 0xb0, 0, 0}, {0x5682, 0x04, 0, 0}, - {0x5683, 0xb0, 0, 0}, {0x3806, 0x03, 0, 0}, {0x3807, 0x58, 0, 0}, - {0x5686, 0x03, 0, 0}, {0x5687, 0x58, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a1a, 0x05, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, - {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, - {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, - {0x350d, 0xd0, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, - {0x528c, 0x08, 0, 0}, {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, - {0x528f, 0x10, 0, 0}, {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, - {0x5293, 0x02, 0, 0}, {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, - {0x5296, 0x00, 0, 0}, {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, - {0x5299, 0x02, 0, 0}, {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, - {0x529c, 0x00, 0, 0}, {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, - {0x529f, 0x02, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, - {0x3a1f, 0x10, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, - {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3621, 0x87, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x302c, 0x60, 0x60, 0}, -}; - -static struct reg_value ov5642_setting_15fps_720P_1280_720[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x00, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3030, 0x2b, 0, 0}, - {0x3011, 0x08, 0, 0}, {0x3010, 0x10, 0, 0}, {0x3604, 0x60, 0, 0}, - {0x3622, 0x60, 0, 0}, {0x3621, 0x09, 0, 0}, {0x3709, 0x00, 0, 0}, - {0x4000, 0x21, 0, 0}, {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, - {0x3605, 0x04, 0, 0}, {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, - {0x300d, 0x22, 0, 0}, {0x3623, 0x22, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5500, 0x0a, 0, 0}, - {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, {0x5080, 0x08, 0, 0}, - {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, {0x471d, 0x05, 0, 0}, - {0x4708, 0x06, 0, 0}, {0x370c, 0xa0, 0, 0}, {0x3808, 0x0a, 0, 0}, - {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, - {0x380c, 0x0c, 0, 0}, {0x380d, 0x80, 0, 0}, {0x380e, 0x07, 0, 0}, - {0x380f, 0xd0, 0, 0}, {0x5687, 0x94, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x5001, 0xcf, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x4300, 0x30, 0, 0}, {0x460b, 0x35, 0, 0}, {0x471d, 0x00, 0, 0}, - {0x3002, 0x0c, 0, 0}, {0x3002, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x471c, 0x50, 0, 0}, {0x4721, 0x02, 0, 0}, {0x4402, 0x90, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x3815, 0x44, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3818, 0xc8, 0, 0}, {0x3801, 0x88, 0, 0}, {0x3824, 0x11, 0, 0}, - {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x04, 0, 0}, {0x3a13, 0x30, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, - {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, - {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, {0x3a0d, 0x08, 0, 0}, - {0x3a0e, 0x06, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x32, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x32, 0, 0}, {0x3a11, 0x80, 0, 0}, - {0x3a1f, 0x20, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x09, 0, 0}, {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, - {0x3a0b, 0xd0, 0, 0}, {0x3a0d, 0x10, 0, 0}, {0x3a0e, 0x0d, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x589b, 0x00, 0, 0}, - {0x589a, 0xc0, 0, 0}, {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, - {0x401c, 0x06, 0, 0}, {0x3825, 0xac, 0, 0}, {0x3827, 0x0c, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3503, 0x07, 0, 0}, {0x3011, 0x08, 0, 0}, - {0x350c, 0x02, 0, 0}, {0x350d, 0xe4, 0, 0}, {0x3621, 0xc9, 0, 0}, - {0x370a, 0x81, 0, 0}, {0x3803, 0x08, 0, 0}, {0x3804, 0x05, 0, 0}, - {0x3805, 0x00, 0, 0}, {0x3806, 0x02, 0, 0}, {0x3807, 0xd0, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x08, 0, 0}, {0x380d, 0x72, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3810, 0xc0, 0, 0}, - {0x3818, 0xc9, 0, 0}, {0x381c, 0x10, 0, 0}, {0x381d, 0xa0, 0, 0}, - {0x381e, 0x05, 0, 0}, {0x381f, 0xb0, 0, 0}, {0x3820, 0x00, 0, 0}, - {0x3821, 0x00, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3a08, 0x1b, 0, 0}, - {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x17, 0, 0}, {0x3a0b, 0x20, 0, 0}, - {0x3a0d, 0x02, 0, 0}, {0x3a0e, 0x01, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, {0x5686, 0x02, 0, 0}, - {0x5687, 0xcc, 0, 0}, {0x5001, 0x7f, 0, 0}, {0x589b, 0x06, 0, 0}, - {0x589a, 0xc5, 0, 0}, {0x3503, 0x00, 0, 0}, {0x3010, 0x10, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x460b, 0x37, 0, 0}, {0x471c, 0xd0, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x3815, 0x01, 0, 0}, {0x3818, 0x00, 0x08, 0}, - {0x501f, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3002, 0x1c, 0, 0}, - {0x3819, 0x80, 0, 0}, {0x5002, 0xe0, 0, 0}, {0x3010, 0x30, 0, 0}, - {0x3a08, 0x06, 0, 0}, {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x05, 0, 0}, - {0x3a0b, 0x50, 0, 0}, {0x3a0d, 0x08, 0, 0}, {0x3a0e, 0x07, 0, 0}, -}; - -static struct reg_value ov5642_setting_30fps_720P_1280_720[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x00, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3030, 0x2b, 0, 0}, - {0x3011, 0x08, 0, 0}, {0x3010, 0x10, 0, 0}, {0x3604, 0x60, 0, 0}, - {0x3622, 0x60, 0, 0}, {0x3621, 0x09, 0, 0}, {0x3709, 0x00, 0, 0}, - {0x4000, 0x21, 0, 0}, {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, - {0x3605, 0x04, 0, 0}, {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, - {0x300d, 0x22, 0, 0}, {0x3623, 0x22, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5500, 0x0a, 0, 0}, - {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, {0x5080, 0x08, 0, 0}, - {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, {0x471d, 0x05, 0, 0}, - {0x4708, 0x06, 0, 0}, {0x370c, 0xa0, 0, 0}, {0x3808, 0x0a, 0, 0}, - {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, - {0x380c, 0x0c, 0, 0}, {0x380d, 0x80, 0, 0}, {0x380e, 0x07, 0, 0}, - {0x380f, 0xd0, 0, 0}, {0x5687, 0x94, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x5001, 0xcf, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x4300, 0x30, 0, 0}, {0x460b, 0x35, 0, 0}, {0x471d, 0x00, 0, 0}, - {0x3002, 0x0c, 0, 0}, {0x3002, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x471c, 0x50, 0, 0}, {0x4721, 0x02, 0, 0}, {0x4402, 0x90, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x3815, 0x44, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3818, 0xc8, 0, 0}, {0x3801, 0x88, 0, 0}, {0x3824, 0x11, 0, 0}, - {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x04, 0, 0}, {0x3a13, 0x30, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, - {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, - {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, {0x3a0d, 0x08, 0, 0}, - {0x3a0e, 0x06, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x32, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x32, 0, 0}, {0x3a11, 0x80, 0, 0}, - {0x3a1f, 0x20, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x09, 0, 0}, {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, - {0x3a0b, 0xd0, 0, 0}, {0x3a0d, 0x10, 0, 0}, {0x3a0e, 0x0d, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x589b, 0x00, 0, 0}, - {0x589a, 0xc0, 0, 0}, {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, - {0x401c, 0x06, 0, 0}, {0x3825, 0xac, 0, 0}, {0x3827, 0x0c, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3503, 0x07, 0, 0}, {0x3011, 0x08, 0, 0}, - {0x350c, 0x02, 0, 0}, {0x350d, 0xe4, 0, 0}, {0x3621, 0xc9, 0, 0}, - {0x370a, 0x81, 0, 0}, {0x3803, 0x08, 0, 0}, {0x3804, 0x05, 0, 0}, - {0x3805, 0x00, 0, 0}, {0x3806, 0x02, 0, 0}, {0x3807, 0xd0, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x380c, 0x08, 0, 0}, {0x380d, 0x72, 0, 0}, - {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3810, 0xc0, 0, 0}, - {0x3818, 0xc9, 0, 0}, {0x381c, 0x10, 0, 0}, {0x381d, 0xa0, 0, 0}, - {0x381e, 0x05, 0, 0}, {0x381f, 0xb0, 0, 0}, {0x3820, 0x00, 0, 0}, - {0x3821, 0x00, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3a08, 0x1b, 0, 0}, - {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x17, 0, 0}, {0x3a0b, 0x20, 0, 0}, - {0x3a0d, 0x02, 0, 0}, {0x3a0e, 0x01, 0, 0}, {0x401c, 0x04, 0, 0}, - {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, {0x5686, 0x02, 0, 0}, - {0x5687, 0xcc, 0, 0}, {0x5001, 0x7f, 0, 0}, {0x589b, 0x06, 0, 0}, - {0x589a, 0xc5, 0, 0}, {0x3503, 0x00, 0, 0}, {0x3010, 0x10, 0, 0}, - {0x460c, 0x20, 0, 0}, {0x460b, 0x37, 0, 0}, {0x471c, 0xd0, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x3815, 0x01, 0, 0}, {0x3818, 0x00, 0x08, 0}, - {0x501f, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3002, 0x1c, 0, 0}, - {0x3819, 0x80, 0, 0}, {0x5002, 0xe0, 0, 0}, -}; - -static struct reg_value ov5642_setting_15fps_1080P_1920_1080[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x00, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3030, 0x2b, 0, 0}, - {0x3011, 0x08, 0, 0}, {0x3010, 0x10, 0, 0}, {0x3604, 0x60, 0, 0}, - {0x3622, 0x60, 0, 0}, {0x3621, 0x09, 0, 0}, {0x3709, 0x00, 0, 0}, - {0x4000, 0x21, 0, 0}, {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, - {0x3605, 0x04, 0, 0}, {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, - {0x300d, 0x22, 0, 0}, {0x3623, 0x22, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5500, 0x0a, 0, 0}, - {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, {0x5080, 0x08, 0, 0}, - {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, {0x471d, 0x05, 0, 0}, - {0x4708, 0x06, 0, 0}, {0x370c, 0xa0, 0, 0}, {0x3808, 0x0a, 0, 0}, - {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, - {0x380c, 0x0c, 0, 0}, {0x380d, 0x80, 0, 0}, {0x380e, 0x07, 0, 0}, - {0x380f, 0xd0, 0, 0}, {0x5687, 0x94, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x5001, 0xcf, 0, 0}, {0x4300, 0x30, 0, 0}, - {0x4300, 0x30, 0, 0}, {0x460b, 0x35, 0, 0}, {0x471d, 0x00, 0, 0}, - {0x3002, 0x0c, 0, 0}, {0x3002, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, - {0x471c, 0x50, 0, 0}, {0x4721, 0x02, 0, 0}, {0x4402, 0x90, 0, 0}, - {0x460c, 0x22, 0, 0}, {0x3815, 0x44, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3818, 0xc8, 0, 0}, {0x3801, 0x88, 0, 0}, {0x3824, 0x11, 0, 0}, - {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x04, 0, 0}, {0x3a13, 0x30, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, {0x3a08, 0x12, 0, 0}, - {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, {0x3a0b, 0xa0, 0, 0}, - {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, {0x3a0d, 0x08, 0, 0}, - {0x3a0e, 0x06, 0, 0}, {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, - {0x3502, 0x00, 0, 0}, {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x32, 0, 0}, - {0x3a1b, 0x3c, 0, 0}, {0x3a1e, 0x32, 0, 0}, {0x3a11, 0x80, 0, 0}, - {0x3a1f, 0x20, 0, 0}, {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, - {0x3a03, 0x7d, 0, 0}, {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, - {0x3a15, 0x7d, 0, 0}, {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, - {0x3a08, 0x09, 0, 0}, {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, - {0x3a0b, 0xd0, 0, 0}, {0x3a0d, 0x10, 0, 0}, {0x3a0e, 0x0d, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x589b, 0x00, 0, 0}, - {0x589a, 0xc0, 0, 0}, {0x401e, 0x20, 0, 0}, {0x4001, 0x42, 0, 0}, - {0x401c, 0x06, 0, 0}, {0x3825, 0xac, 0, 0}, {0x3827, 0x0c, 0, 0}, - {0x528a, 0x01, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x10, 0, 0}, {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, - {0x5290, 0x30, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x08, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x28, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, - {0x5282, 0x00, 0, 0}, {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, - {0x5302, 0x00, 0, 0}, {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, - {0x530d, 0x0c, 0, 0}, {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, - {0x5310, 0x20, 0, 0}, {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, - {0x5309, 0x40, 0, 0}, {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, - {0x5306, 0x00, 0, 0}, {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, - {0x5315, 0x20, 0, 0}, {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, - {0x5317, 0x00, 0, 0}, {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, - {0x5381, 0x00, 0, 0}, {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, - {0x5384, 0x00, 0, 0}, {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, - {0x5387, 0x00, 0, 0}, {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, - {0x538a, 0x00, 0, 0}, {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, - {0x538d, 0x00, 0, 0}, {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, - {0x5390, 0x00, 0, 0}, {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, - {0x5393, 0xa2, 0, 0}, {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, - {0x5481, 0x21, 0, 0}, {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, - {0x5484, 0x65, 0, 0}, {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, - {0x5487, 0x87, 0, 0}, {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, - {0x548a, 0xaa, 0, 0}, {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, - {0x548d, 0xdd, 0, 0}, {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, - {0x5490, 0x05, 0, 0}, {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, - {0x5493, 0x20, 0, 0}, {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, - {0x5496, 0x02, 0, 0}, {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, - {0x5499, 0x86, 0, 0}, {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, - {0x549c, 0x02, 0, 0}, {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, - {0x549f, 0x1c, 0, 0}, {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, - {0x54a2, 0x01, 0, 0}, {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, - {0x54a5, 0xc5, 0, 0}, {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, - {0x54a8, 0x01, 0, 0}, {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, - {0x54ab, 0x41, 0, 0}, {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, - {0x54ae, 0x00, 0, 0}, {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, - {0x54b1, 0x20, 0, 0}, {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, - {0x54b4, 0x00, 0, 0}, {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, - {0x54b7, 0xdf, 0, 0}, {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, - {0x3406, 0x00, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, - {0x5182, 0x11, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, - {0x5188, 0x08, 0, 0}, {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, - {0x518b, 0xb2, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, - {0x518e, 0x3d, 0, 0}, {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, - {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, - {0x519d, 0x82, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, - {0x3a0f, 0x38, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, - {0x3a1e, 0x2e, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x5688, 0xa6, 0, 0}, {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, - {0x568b, 0xae, 0, 0}, {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, - {0x568e, 0x62, 0, 0}, {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, - {0x5584, 0x40, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, - {0x5800, 0x27, 0, 0}, {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, - {0x5803, 0x0f, 0, 0}, {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, - {0x5806, 0x1e, 0, 0}, {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, - {0x5809, 0x0d, 0, 0}, {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, - {0x580c, 0x0a, 0, 0}, {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, - {0x580f, 0x19, 0, 0}, {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, - {0x5812, 0x04, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, - {0x5815, 0x06, 0, 0}, {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, - {0x5818, 0x0a, 0, 0}, {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, - {0x581b, 0x00, 0, 0}, {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, - {0x581e, 0x08, 0, 0}, {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, - {0x5821, 0x05, 0, 0}, {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, - {0x5824, 0x00, 0, 0}, {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, - {0x5827, 0x0c, 0, 0}, {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, - {0x582a, 0x06, 0, 0}, {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, - {0x582d, 0x07, 0, 0}, {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, - {0x5830, 0x18, 0, 0}, {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, - {0x5833, 0x0a, 0, 0}, {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, - {0x5836, 0x15, 0, 0}, {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, - {0x5839, 0x1f, 0, 0}, {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, - {0x583c, 0x17, 0, 0}, {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, - {0x583f, 0x53, 0, 0}, {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, - {0x5842, 0x0d, 0, 0}, {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, - {0x5845, 0x09, 0, 0}, {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, - {0x5848, 0x10, 0, 0}, {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, - {0x584b, 0x0e, 0, 0}, {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, - {0x584e, 0x11, 0, 0}, {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, - {0x5851, 0x0c, 0, 0}, {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, - {0x5854, 0x10, 0, 0}, {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, - {0x5857, 0x0b, 0, 0}, {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, - {0x585a, 0x0d, 0, 0}, {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, - {0x585d, 0x0c, 0, 0}, {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, - {0x5860, 0x0c, 0, 0}, {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, - {0x5863, 0x08, 0, 0}, {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, - {0x5866, 0x18, 0, 0}, {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, - {0x5869, 0x19, 0, 0}, {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, - {0x586c, 0x13, 0, 0}, {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, - {0x586f, 0x16, 0, 0}, {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, - {0x5872, 0x10, 0, 0}, {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, - {0x5875, 0x16, 0, 0}, {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, - {0x5878, 0x10, 0, 0}, {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, - {0x587b, 0x14, 0, 0}, {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, - {0x587e, 0x11, 0, 0}, {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, - {0x5881, 0x15, 0, 0}, {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, - {0x5884, 0x15, 0, 0}, {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, - {0x5887, 0x17, 0, 0}, {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, - {0x3702, 0x10, 0, 0}, {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, - {0x370b, 0x40, 0, 0}, {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, - {0x3632, 0x52, 0, 0}, {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, - {0x5785, 0x07, 0, 0}, {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, - {0x3604, 0x48, 0, 0}, {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, - {0x370f, 0xc0, 0, 0}, {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, - {0x5007, 0x00, 0, 0}, {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, - {0x5013, 0x00, 0, 0}, {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, - {0x5087, 0x00, 0, 0}, {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, - {0x302b, 0x00, 0, 0}, {0x3503, 0x07, 0, 0}, {0x3011, 0x07, 0, 0}, - {0x350c, 0x04, 0, 0}, {0x350d, 0x58, 0, 0}, {0x3801, 0x8a, 0, 0}, - {0x3803, 0x0a, 0, 0}, {0x3804, 0x07, 0, 0}, {0x3805, 0x80, 0, 0}, - {0x3806, 0x04, 0, 0}, {0x3807, 0x39, 0, 0}, {0x3808, 0x07, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0}, - {0x380c, 0x09, 0, 0}, {0x380d, 0xd6, 0, 0}, {0x380e, 0x04, 0, 0}, - {0x380f, 0x58, 0, 0}, {0x381c, 0x11, 0, 0}, {0x381d, 0xba, 0, 0}, - {0x381e, 0x04, 0, 0}, {0x381f, 0x48, 0, 0}, {0x3820, 0x04, 0, 0}, - {0x3821, 0x18, 0, 0}, {0x3a08, 0x14, 0, 0}, {0x3a09, 0xe0, 0, 0}, - {0x3a0a, 0x11, 0, 0}, {0x3a0b, 0x60, 0, 0}, {0x3a0d, 0x04, 0, 0}, - {0x3a0e, 0x03, 0, 0}, {0x5682, 0x07, 0, 0}, {0x5683, 0x60, 0, 0}, - {0x5686, 0x04, 0, 0}, {0x5687, 0x1c, 0, 0}, {0x5001, 0x7f, 0, 0}, - {0x3503, 0x00, 0, 0}, {0x3010, 0x10, 0, 0}, {0x460c, 0x20, 0, 0}, - {0x460b, 0x37, 0, 0}, {0x471c, 0xd0, 0, 0}, {0x471d, 0x05, 0, 0}, - {0x3815, 0x01, 0, 0}, {0x3818, 0x00, 0x08, 0}, {0x501f, 0x00, 0, 0}, - {0x4300, 0x30, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3819, 0x80, 0, 0}, - {0x5002, 0xe0, 0, 0}, -}; - -static struct reg_value ov5642_setting_15fps_QVGA_320_240[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, - {0x3006, 0x43, 0, 0}, {0x3007, 0x37, 0, 0}, {0x3011, 0x08, 0, 0}, - {0x3010, 0x10, 0, 0}, {0x460c, 0x22, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3501, 0x1e, 0, 0}, - {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, {0x380c, 0x0c, 0, 0}, - {0x380d, 0x80, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3818, 0xc1, 0, 0}, - {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, {0x3801, 0x80, 0, 0}, - {0x3621, 0x87, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3803, 0x08, 0, 0}, - {0x3827, 0x08, 0, 0}, {0x3810, 0x40, 0, 0}, {0x3804, 0x05, 0, 0}, - {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, - {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, {0x5686, 0x03, 0, 0}, - {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x05, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, - {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, {0x3502, 0x00, 0, 0}, - {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, {0x3503, 0x00, 0, 0}, - {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, {0x528f, 0x10, 0, 0}, - {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x02, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x02, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x02, 0, 0}, - {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3c, 0, 0}, - {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, {0x3a03, 0x7d, 0, 0}, - {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, {0x3a15, 0x7d, 0, 0}, - {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a08, 0x09, 0, 0}, - {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, {0x3a0b, 0xd0, 0, 0}, - {0x3a0d, 0x08, 0, 0}, {0x3a0e, 0x06, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, {0x401e, 0x20, 0, 0}, - {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, {0x528a, 0x01, 0, 0}, - {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, {0x528d, 0x10, 0, 0}, - {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, {0x5290, 0x30, 0, 0}, - {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, {0x5294, 0x00, 0, 0}, - {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, {0x5297, 0x08, 0, 0}, - {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, {0x529a, 0x00, 0, 0}, - {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, {0x529d, 0x28, 0, 0}, - {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, {0x5282, 0x00, 0, 0}, - {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, {0x5302, 0x00, 0, 0}, - {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, {0x530d, 0x0c, 0, 0}, - {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, {0x5310, 0x20, 0, 0}, - {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, {0x5309, 0x40, 0, 0}, - {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, {0x5306, 0x00, 0, 0}, - {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, {0x5315, 0x20, 0, 0}, - {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, {0x5317, 0x00, 0, 0}, - {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, {0x5381, 0x00, 0, 0}, - {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, {0x5384, 0x00, 0, 0}, - {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, {0x5387, 0x00, 0, 0}, - {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, {0x538a, 0x00, 0, 0}, - {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, {0x538d, 0x00, 0, 0}, - {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, {0x5390, 0x00, 0, 0}, - {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, {0x5393, 0xa2, 0, 0}, - {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, {0x5481, 0x21, 0, 0}, - {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, {0x5484, 0x65, 0, 0}, - {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, {0x5487, 0x87, 0, 0}, - {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, {0x548a, 0xaa, 0, 0}, - {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, {0x548d, 0xdd, 0, 0}, - {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, {0x5490, 0x05, 0, 0}, - {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, {0x5493, 0x20, 0, 0}, - {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, {0x5496, 0x02, 0, 0}, - {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, {0x5499, 0x86, 0, 0}, - {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, {0x549c, 0x02, 0, 0}, - {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, {0x549f, 0x1c, 0, 0}, - {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, {0x54a2, 0x01, 0, 0}, - {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, {0x54a5, 0xc5, 0, 0}, - {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, {0x54a8, 0x01, 0, 0}, - {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, {0x54ab, 0x41, 0, 0}, - {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, {0x54ae, 0x00, 0, 0}, - {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, {0x54b1, 0x20, 0, 0}, - {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, {0x54b4, 0x00, 0, 0}, - {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, {0x54b7, 0xdf, 0, 0}, - {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, {0x3406, 0x00, 0, 0}, - {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, {0x5182, 0x11, 0, 0}, - {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, - {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, {0x5188, 0x08, 0, 0}, - {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, {0x518b, 0xb2, 0, 0}, - {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, {0x518e, 0x3d, 0, 0}, - {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, {0x5191, 0xf8, 0, 0}, - {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x5194, 0xf0, 0, 0}, - {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, {0x5197, 0x01, 0, 0}, - {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, {0x519a, 0x04, 0, 0}, - {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, {0x519d, 0x82, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, {0x3a0f, 0x38, 0, 0}, - {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, {0x3a1e, 0x2e, 0, 0}, - {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, {0x5688, 0xa6, 0, 0}, - {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, {0x568b, 0xae, 0, 0}, - {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, {0x568e, 0x62, 0, 0}, - {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x40, 0, 0}, - {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, {0x5800, 0x27, 0, 0}, - {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, {0x5803, 0x0f, 0, 0}, - {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, {0x5806, 0x1e, 0, 0}, - {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, {0x5809, 0x0d, 0, 0}, - {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, {0x580c, 0x0a, 0, 0}, - {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, {0x580f, 0x19, 0, 0}, - {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, {0x5812, 0x04, 0, 0}, - {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, {0x5815, 0x06, 0, 0}, - {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, {0x5818, 0x0a, 0, 0}, - {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, {0x581b, 0x00, 0, 0}, - {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, {0x581e, 0x08, 0, 0}, - {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, {0x5821, 0x05, 0, 0}, - {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, {0x5824, 0x00, 0, 0}, - {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, {0x5827, 0x0c, 0, 0}, - {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, {0x582a, 0x06, 0, 0}, - {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, {0x582d, 0x07, 0, 0}, - {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, {0x5830, 0x18, 0, 0}, - {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, {0x5833, 0x0a, 0, 0}, - {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, {0x5836, 0x15, 0, 0}, - {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, {0x5839, 0x1f, 0, 0}, - {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, {0x583c, 0x17, 0, 0}, - {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, {0x583f, 0x53, 0, 0}, - {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, {0x5842, 0x0d, 0, 0}, - {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, {0x5845, 0x09, 0, 0}, - {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, {0x5848, 0x10, 0, 0}, - {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, {0x584b, 0x0e, 0, 0}, - {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, {0x584e, 0x11, 0, 0}, - {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, {0x5851, 0x0c, 0, 0}, - {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, {0x5854, 0x10, 0, 0}, - {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, {0x5857, 0x0b, 0, 0}, - {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, {0x585a, 0x0d, 0, 0}, - {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, {0x585d, 0x0c, 0, 0}, - {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, {0x5860, 0x0c, 0, 0}, - {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, {0x5863, 0x08, 0, 0}, - {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, {0x5866, 0x18, 0, 0}, - {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, {0x5869, 0x19, 0, 0}, - {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, {0x586c, 0x13, 0, 0}, - {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, {0x586f, 0x16, 0, 0}, - {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, {0x5872, 0x10, 0, 0}, - {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, {0x5875, 0x16, 0, 0}, - {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, {0x5878, 0x10, 0, 0}, - {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, {0x587b, 0x14, 0, 0}, - {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, {0x587e, 0x11, 0, 0}, - {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, {0x5881, 0x15, 0, 0}, - {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, {0x5884, 0x15, 0, 0}, - {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, {0x5887, 0x17, 0, 0}, - {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, {0x3702, 0x10, 0, 0}, - {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, {0x370b, 0x40, 0, 0}, - {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, {0x3632, 0x52, 0, 0}, - {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, {0x5785, 0x07, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, {0x3604, 0x48, 0, 0}, - {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, {0x370f, 0xc0, 0, 0}, - {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, {0x5007, 0x00, 0, 0}, - {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, {0x5013, 0x00, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, {0x5087, 0x00, 0, 0}, - {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, {0x302b, 0x00, 0, 0}, - {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, {0x380a, 0x00, 0, 0}, - {0x380b, 0xf0, 0, 0}, {0x3a00, 0x78, 0, 0}, -}; - -static struct reg_value ov5642_setting_15fps_NTSC_720_480[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, - {0x3006, 0x43, 0, 0}, {0x3007, 0x37, 0, 0}, {0x3011, 0x08, 0, 0}, - {0x3010, 0x10, 0, 0}, {0x460c, 0x22, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3501, 0x1e, 0, 0}, - {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, {0x380c, 0x0c, 0, 0}, - {0x380d, 0x80, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3818, 0xc1, 0, 0}, - {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, {0x3801, 0x80, 0, 0}, - {0x3621, 0x87, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3803, 0x08, 0, 0}, - {0x3827, 0x08, 0, 0}, {0x3810, 0x40, 0, 0}, {0x3804, 0x05, 0, 0}, - {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, - {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, {0x5686, 0x03, 0, 0}, - {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x05, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, - {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, {0x3502, 0x00, 0, 0}, - {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, {0x3503, 0x00, 0, 0}, - {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, {0x528f, 0x10, 0, 0}, - {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x02, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x02, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x02, 0, 0}, - {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3c, 0, 0}, - {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, {0x3a03, 0x7d, 0, 0}, - {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, {0x3a15, 0x7d, 0, 0}, - {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a08, 0x09, 0, 0}, - {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, {0x3a0b, 0xd0, 0, 0}, - {0x3a0d, 0x08, 0, 0}, {0x3a0e, 0x06, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, {0x401e, 0x20, 0, 0}, - {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, {0x528a, 0x01, 0, 0}, - {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, {0x528d, 0x10, 0, 0}, - {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, {0x5290, 0x30, 0, 0}, - {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, {0x5294, 0x00, 0, 0}, - {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, {0x5297, 0x08, 0, 0}, - {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, {0x529a, 0x00, 0, 0}, - {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, {0x529d, 0x28, 0, 0}, - {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, {0x5282, 0x00, 0, 0}, - {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, {0x5302, 0x00, 0, 0}, - {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, {0x530d, 0x0c, 0, 0}, - {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, {0x5310, 0x20, 0, 0}, - {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, {0x5309, 0x40, 0, 0}, - {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, {0x5306, 0x00, 0, 0}, - {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, {0x5315, 0x20, 0, 0}, - {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, {0x5317, 0x00, 0, 0}, - {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, {0x5381, 0x00, 0, 0}, - {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, {0x5384, 0x00, 0, 0}, - {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, {0x5387, 0x00, 0, 0}, - {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, {0x538a, 0x00, 0, 0}, - {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, {0x538d, 0x00, 0, 0}, - {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, {0x5390, 0x00, 0, 0}, - {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, {0x5393, 0xa2, 0, 0}, - {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, {0x5481, 0x21, 0, 0}, - {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, {0x5484, 0x65, 0, 0}, - {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, {0x5487, 0x87, 0, 0}, - {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, {0x548a, 0xaa, 0, 0}, - {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, {0x548d, 0xdd, 0, 0}, - {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, {0x5490, 0x05, 0, 0}, - {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, {0x5493, 0x20, 0, 0}, - {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, {0x5496, 0x02, 0, 0}, - {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, {0x5499, 0x86, 0, 0}, - {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, {0x549c, 0x02, 0, 0}, - {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, {0x549f, 0x1c, 0, 0}, - {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, {0x54a2, 0x01, 0, 0}, - {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, {0x54a5, 0xc5, 0, 0}, - {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, {0x54a8, 0x01, 0, 0}, - {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, {0x54ab, 0x41, 0, 0}, - {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, {0x54ae, 0x00, 0, 0}, - {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, {0x54b1, 0x20, 0, 0}, - {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, {0x54b4, 0x00, 0, 0}, - {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, {0x54b7, 0xdf, 0, 0}, - {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, {0x3406, 0x00, 0, 0}, - {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, {0x5182, 0x11, 0, 0}, - {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, - {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, {0x5188, 0x08, 0, 0}, - {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, {0x518b, 0xb2, 0, 0}, - {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, {0x518e, 0x3d, 0, 0}, - {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, {0x5191, 0xf8, 0, 0}, - {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x5194, 0xf0, 0, 0}, - {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, {0x5197, 0x01, 0, 0}, - {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, {0x519a, 0x04, 0, 0}, - {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, {0x519d, 0x82, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, {0x3a0f, 0x38, 0, 0}, - {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, {0x3a1e, 0x2e, 0, 0}, - {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, {0x5688, 0xa6, 0, 0}, - {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, {0x568b, 0xae, 0, 0}, - {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, {0x568e, 0x62, 0, 0}, - {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x40, 0, 0}, - {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, {0x5800, 0x27, 0, 0}, - {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, {0x5803, 0x0f, 0, 0}, - {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, {0x5806, 0x1e, 0, 0}, - {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, {0x5809, 0x0d, 0, 0}, - {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, {0x580c, 0x0a, 0, 0}, - {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, {0x580f, 0x19, 0, 0}, - {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, {0x5812, 0x04, 0, 0}, - {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, {0x5815, 0x06, 0, 0}, - {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, {0x5818, 0x0a, 0, 0}, - {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, {0x581b, 0x00, 0, 0}, - {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, {0x581e, 0x08, 0, 0}, - {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, {0x5821, 0x05, 0, 0}, - {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, {0x5824, 0x00, 0, 0}, - {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, {0x5827, 0x0c, 0, 0}, - {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, {0x582a, 0x06, 0, 0}, - {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, {0x582d, 0x07, 0, 0}, - {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, {0x5830, 0x18, 0, 0}, - {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, {0x5833, 0x0a, 0, 0}, - {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, {0x5836, 0x15, 0, 0}, - {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, {0x5839, 0x1f, 0, 0}, - {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, {0x583c, 0x17, 0, 0}, - {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, {0x583f, 0x53, 0, 0}, - {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, {0x5842, 0x0d, 0, 0}, - {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, {0x5845, 0x09, 0, 0}, - {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, {0x5848, 0x10, 0, 0}, - {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, {0x584b, 0x0e, 0, 0}, - {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, {0x584e, 0x11, 0, 0}, - {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, {0x5851, 0x0c, 0, 0}, - {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, {0x5854, 0x10, 0, 0}, - {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, {0x5857, 0x0b, 0, 0}, - {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, {0x585a, 0x0d, 0, 0}, - {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, {0x585d, 0x0c, 0, 0}, - {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, {0x5860, 0x0c, 0, 0}, - {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, {0x5863, 0x08, 0, 0}, - {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, {0x5866, 0x18, 0, 0}, - {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, {0x5869, 0x19, 0, 0}, - {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, {0x586c, 0x13, 0, 0}, - {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, {0x586f, 0x16, 0, 0}, - {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, {0x5872, 0x10, 0, 0}, - {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, {0x5875, 0x16, 0, 0}, - {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, {0x5878, 0x10, 0, 0}, - {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, {0x587b, 0x14, 0, 0}, - {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, {0x587e, 0x11, 0, 0}, - {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, {0x5881, 0x15, 0, 0}, - {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, {0x5884, 0x15, 0, 0}, - {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, {0x5887, 0x17, 0, 0}, - {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, {0x3702, 0x10, 0, 0}, - {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, {0x370b, 0x40, 0, 0}, - {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, {0x3632, 0x52, 0, 0}, - {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, {0x5785, 0x07, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, {0x3604, 0x48, 0, 0}, - {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, {0x370f, 0xc0, 0, 0}, - {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, {0x5007, 0x00, 0, 0}, - {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, {0x5013, 0x00, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, {0x5087, 0x00, 0, 0}, - {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, {0x302b, 0x00, 0, 0}, - {0x3824, 0x11, 0, 0}, {0x3825, 0xb4, 0, 0}, {0x3826, 0x00, 0, 0}, - {0x3827, 0x3d, 0, 0}, {0x380c, 0x0c, 0, 0}, {0x380d, 0x80, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0xd0, 0, 0}, {0x380A, 0x01, 0, 0}, {0x380B, 0xe0, 0, 0}, - {0x3804, 0x05, 0, 0}, {0x3805, 0x00, 0, 0}, {0x3806, 0x03, 0, 0}, - {0x3807, 0x55, 0, 0}, {0x5686, 0x03, 0, 0}, {0x5687, 0x55, 0, 0}, - {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, -}; - -static struct reg_value ov5642_setting_15fps_PAL_720_576[] = { - {0x3103, 0x93, 0, 0}, {0x3008, 0x82, 0, 0}, {0x3017, 0x7f, 0, 0}, - {0x3018, 0xfc, 0, 0}, {0x3810, 0xc2, 0, 0}, {0x3615, 0xf0, 0, 0}, - {0x3000, 0x00, 0, 0}, {0x3001, 0x00, 0, 0}, {0x3002, 0x5c, 0, 0}, - {0x3003, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3005, 0xff, 0, 0}, - {0x3006, 0x43, 0, 0}, {0x3007, 0x37, 0, 0}, {0x3011, 0x08, 0, 0}, - {0x3010, 0x10, 0, 0}, {0x460c, 0x22, 0, 0}, {0x3815, 0x04, 0, 0}, - {0x370c, 0xa0, 0, 0}, {0x3602, 0xfc, 0, 0}, {0x3612, 0xff, 0, 0}, - {0x3634, 0xc0, 0, 0}, {0x3613, 0x00, 0, 0}, {0x3605, 0x7c, 0, 0}, - {0x3621, 0x09, 0, 0}, {0x3622, 0x60, 0, 0}, {0x3604, 0x40, 0, 0}, - {0x3603, 0xa7, 0, 0}, {0x3603, 0x27, 0, 0}, {0x4000, 0x21, 0, 0}, - {0x401d, 0x22, 0, 0}, {0x3600, 0x54, 0, 0}, {0x3605, 0x04, 0, 0}, - {0x3606, 0x3f, 0, 0}, {0x3c01, 0x80, 0, 0}, {0x5000, 0x4f, 0, 0}, - {0x5020, 0x04, 0, 0}, {0x5181, 0x79, 0, 0}, {0x5182, 0x00, 0, 0}, - {0x5185, 0x22, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5001, 0xff, 0, 0}, - {0x5500, 0x0a, 0, 0}, {0x5504, 0x00, 0, 0}, {0x5505, 0x7f, 0, 0}, - {0x5080, 0x08, 0, 0}, {0x300e, 0x18, 0, 0}, {0x4610, 0x00, 0, 0}, - {0x471d, 0x05, 0, 0}, {0x4708, 0x06, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, - {0x380e, 0x07, 0, 0}, {0x380f, 0xd0, 0, 0}, {0x501f, 0x00, 0, 0}, - {0x5000, 0x4f, 0, 0}, {0x4300, 0x30, 0, 0}, {0x3503, 0x07, 0, 0}, - {0x3501, 0x73, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350b, 0x00, 0, 0}, - {0x3503, 0x07, 0, 0}, {0x3824, 0x11, 0, 0}, {0x3501, 0x1e, 0, 0}, - {0x3502, 0x80, 0, 0}, {0x350b, 0x7f, 0, 0}, {0x380c, 0x0c, 0, 0}, - {0x380d, 0x80, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3818, 0xc1, 0, 0}, - {0x3705, 0xdb, 0, 0}, {0x370a, 0x81, 0, 0}, {0x3801, 0x80, 0, 0}, - {0x3621, 0x87, 0, 0}, {0x3801, 0x50, 0, 0}, {0x3803, 0x08, 0, 0}, - {0x3827, 0x08, 0, 0}, {0x3810, 0x40, 0, 0}, {0x3804, 0x05, 0, 0}, - {0x3805, 0x00, 0, 0}, {0x5682, 0x05, 0, 0}, {0x5683, 0x00, 0, 0}, - {0x3806, 0x03, 0, 0}, {0x3807, 0xc0, 0, 0}, {0x5686, 0x03, 0, 0}, - {0x5687, 0xbc, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a1a, 0x05, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, - {0x3a08, 0x12, 0, 0}, {0x3a09, 0xc0, 0, 0}, {0x3a0a, 0x0f, 0, 0}, - {0x3a0b, 0xa0, 0, 0}, {0x350c, 0x07, 0, 0}, {0x350d, 0xd0, 0, 0}, - {0x3500, 0x00, 0, 0}, {0x3501, 0x00, 0, 0}, {0x3502, 0x00, 0, 0}, - {0x350a, 0x00, 0, 0}, {0x350b, 0x00, 0, 0}, {0x3503, 0x00, 0, 0}, - {0x528a, 0x02, 0, 0}, {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, - {0x528d, 0x08, 0, 0}, {0x528e, 0x08, 0, 0}, {0x528f, 0x10, 0, 0}, - {0x5290, 0x10, 0, 0}, {0x5292, 0x00, 0, 0}, {0x5293, 0x02, 0, 0}, - {0x5294, 0x00, 0, 0}, {0x5295, 0x02, 0, 0}, {0x5296, 0x00, 0, 0}, - {0x5297, 0x02, 0, 0}, {0x5298, 0x00, 0, 0}, {0x5299, 0x02, 0, 0}, - {0x529a, 0x00, 0, 0}, {0x529b, 0x02, 0, 0}, {0x529c, 0x00, 0, 0}, - {0x529d, 0x02, 0, 0}, {0x529e, 0x00, 0, 0}, {0x529f, 0x02, 0, 0}, - {0x3a0f, 0x3c, 0, 0}, {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3c, 0, 0}, - {0x3a1e, 0x30, 0, 0}, {0x3a11, 0x70, 0, 0}, {0x3a1f, 0x10, 0, 0}, - {0x3030, 0x2b, 0, 0}, {0x3a02, 0x00, 0, 0}, {0x3a03, 0x7d, 0, 0}, - {0x3a04, 0x00, 0, 0}, {0x3a14, 0x00, 0, 0}, {0x3a15, 0x7d, 0, 0}, - {0x3a16, 0x00, 0, 0}, {0x3a00, 0x78, 0, 0}, {0x3a08, 0x09, 0, 0}, - {0x3a09, 0x60, 0, 0}, {0x3a0a, 0x07, 0, 0}, {0x3a0b, 0xd0, 0, 0}, - {0x3a0d, 0x08, 0, 0}, {0x3a0e, 0x06, 0, 0}, {0x5193, 0x70, 0, 0}, - {0x589b, 0x04, 0, 0}, {0x589a, 0xc5, 0, 0}, {0x401e, 0x20, 0, 0}, - {0x4001, 0x42, 0, 0}, {0x401c, 0x04, 0, 0}, {0x528a, 0x01, 0, 0}, - {0x528b, 0x04, 0, 0}, {0x528c, 0x08, 0, 0}, {0x528d, 0x10, 0, 0}, - {0x528e, 0x20, 0, 0}, {0x528f, 0x28, 0, 0}, {0x5290, 0x30, 0, 0}, - {0x5292, 0x00, 0, 0}, {0x5293, 0x01, 0, 0}, {0x5294, 0x00, 0, 0}, - {0x5295, 0x04, 0, 0}, {0x5296, 0x00, 0, 0}, {0x5297, 0x08, 0, 0}, - {0x5298, 0x00, 0, 0}, {0x5299, 0x10, 0, 0}, {0x529a, 0x00, 0, 0}, - {0x529b, 0x20, 0, 0}, {0x529c, 0x00, 0, 0}, {0x529d, 0x28, 0, 0}, - {0x529e, 0x00, 0, 0}, {0x529f, 0x30, 0, 0}, {0x5282, 0x00, 0, 0}, - {0x5300, 0x00, 0, 0}, {0x5301, 0x20, 0, 0}, {0x5302, 0x00, 0, 0}, - {0x5303, 0x7c, 0, 0}, {0x530c, 0x00, 0, 0}, {0x530d, 0x0c, 0, 0}, - {0x530e, 0x20, 0, 0}, {0x530f, 0x80, 0, 0}, {0x5310, 0x20, 0, 0}, - {0x5311, 0x80, 0, 0}, {0x5308, 0x20, 0, 0}, {0x5309, 0x40, 0, 0}, - {0x5304, 0x00, 0, 0}, {0x5305, 0x30, 0, 0}, {0x5306, 0x00, 0, 0}, - {0x5307, 0x80, 0, 0}, {0x5314, 0x08, 0, 0}, {0x5315, 0x20, 0, 0}, - {0x5319, 0x30, 0, 0}, {0x5316, 0x10, 0, 0}, {0x5317, 0x00, 0, 0}, - {0x5318, 0x02, 0, 0}, {0x5380, 0x01, 0, 0}, {0x5381, 0x00, 0, 0}, - {0x5382, 0x00, 0, 0}, {0x5383, 0x4e, 0, 0}, {0x5384, 0x00, 0, 0}, - {0x5385, 0x0f, 0, 0}, {0x5386, 0x00, 0, 0}, {0x5387, 0x00, 0, 0}, - {0x5388, 0x01, 0, 0}, {0x5389, 0x15, 0, 0}, {0x538a, 0x00, 0, 0}, - {0x538b, 0x31, 0, 0}, {0x538c, 0x00, 0, 0}, {0x538d, 0x00, 0, 0}, - {0x538e, 0x00, 0, 0}, {0x538f, 0x0f, 0, 0}, {0x5390, 0x00, 0, 0}, - {0x5391, 0xab, 0, 0}, {0x5392, 0x00, 0, 0}, {0x5393, 0xa2, 0, 0}, - {0x5394, 0x08, 0, 0}, {0x5480, 0x14, 0, 0}, {0x5481, 0x21, 0, 0}, - {0x5482, 0x36, 0, 0}, {0x5483, 0x57, 0, 0}, {0x5484, 0x65, 0, 0}, - {0x5485, 0x71, 0, 0}, {0x5486, 0x7d, 0, 0}, {0x5487, 0x87, 0, 0}, - {0x5488, 0x91, 0, 0}, {0x5489, 0x9a, 0, 0}, {0x548a, 0xaa, 0, 0}, - {0x548b, 0xb8, 0, 0}, {0x548c, 0xcd, 0, 0}, {0x548d, 0xdd, 0, 0}, - {0x548e, 0xea, 0, 0}, {0x548f, 0x1d, 0, 0}, {0x5490, 0x05, 0, 0}, - {0x5491, 0x00, 0, 0}, {0x5492, 0x04, 0, 0}, {0x5493, 0x20, 0, 0}, - {0x5494, 0x03, 0, 0}, {0x5495, 0x60, 0, 0}, {0x5496, 0x02, 0, 0}, - {0x5497, 0xb8, 0, 0}, {0x5498, 0x02, 0, 0}, {0x5499, 0x86, 0, 0}, - {0x549a, 0x02, 0, 0}, {0x549b, 0x5b, 0, 0}, {0x549c, 0x02, 0, 0}, - {0x549d, 0x3b, 0, 0}, {0x549e, 0x02, 0, 0}, {0x549f, 0x1c, 0, 0}, - {0x54a0, 0x02, 0, 0}, {0x54a1, 0x04, 0, 0}, {0x54a2, 0x01, 0, 0}, - {0x54a3, 0xed, 0, 0}, {0x54a4, 0x01, 0, 0}, {0x54a5, 0xc5, 0, 0}, - {0x54a6, 0x01, 0, 0}, {0x54a7, 0xa5, 0, 0}, {0x54a8, 0x01, 0, 0}, - {0x54a9, 0x6c, 0, 0}, {0x54aa, 0x01, 0, 0}, {0x54ab, 0x41, 0, 0}, - {0x54ac, 0x01, 0, 0}, {0x54ad, 0x20, 0, 0}, {0x54ae, 0x00, 0, 0}, - {0x54af, 0x16, 0, 0}, {0x54b0, 0x01, 0, 0}, {0x54b1, 0x20, 0, 0}, - {0x54b2, 0x00, 0, 0}, {0x54b3, 0x10, 0, 0}, {0x54b4, 0x00, 0, 0}, - {0x54b5, 0xf0, 0, 0}, {0x54b6, 0x00, 0, 0}, {0x54b7, 0xdf, 0, 0}, - {0x5402, 0x3f, 0, 0}, {0x5403, 0x00, 0, 0}, {0x3406, 0x00, 0, 0}, - {0x5180, 0xff, 0, 0}, {0x5181, 0x52, 0, 0}, {0x5182, 0x11, 0, 0}, - {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, - {0x5186, 0x06, 0, 0}, {0x5187, 0x08, 0, 0}, {0x5188, 0x08, 0, 0}, - {0x5189, 0x7c, 0, 0}, {0x518a, 0x60, 0, 0}, {0x518b, 0xb2, 0, 0}, - {0x518c, 0xb2, 0, 0}, {0x518d, 0x44, 0, 0}, {0x518e, 0x3d, 0, 0}, - {0x518f, 0x58, 0, 0}, {0x5190, 0x46, 0, 0}, {0x5191, 0xf8, 0, 0}, - {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, {0x5194, 0xf0, 0, 0}, - {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, {0x5197, 0x01, 0, 0}, - {0x5198, 0x04, 0, 0}, {0x5199, 0x12, 0, 0}, {0x519a, 0x04, 0, 0}, - {0x519b, 0x00, 0, 0}, {0x519c, 0x06, 0, 0}, {0x519d, 0x82, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5025, 0x80, 0, 0}, {0x3a0f, 0x38, 0, 0}, - {0x3a10, 0x30, 0, 0}, {0x3a1b, 0x3a, 0, 0}, {0x3a1e, 0x2e, 0, 0}, - {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x10, 0, 0}, {0x5688, 0xa6, 0, 0}, - {0x5689, 0x6a, 0, 0}, {0x568a, 0xea, 0, 0}, {0x568b, 0xae, 0, 0}, - {0x568c, 0xa6, 0, 0}, {0x568d, 0x6a, 0, 0}, {0x568e, 0x62, 0, 0}, - {0x568f, 0x26, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x40, 0, 0}, - {0x5580, 0x02, 0, 0}, {0x5000, 0xcf, 0, 0}, {0x5800, 0x27, 0, 0}, - {0x5801, 0x19, 0, 0}, {0x5802, 0x12, 0, 0}, {0x5803, 0x0f, 0, 0}, - {0x5804, 0x10, 0, 0}, {0x5805, 0x15, 0, 0}, {0x5806, 0x1e, 0, 0}, - {0x5807, 0x2f, 0, 0}, {0x5808, 0x15, 0, 0}, {0x5809, 0x0d, 0, 0}, - {0x580a, 0x0a, 0, 0}, {0x580b, 0x09, 0, 0}, {0x580c, 0x0a, 0, 0}, - {0x580d, 0x0c, 0, 0}, {0x580e, 0x12, 0, 0}, {0x580f, 0x19, 0, 0}, - {0x5810, 0x0b, 0, 0}, {0x5811, 0x07, 0, 0}, {0x5812, 0x04, 0, 0}, - {0x5813, 0x03, 0, 0}, {0x5814, 0x03, 0, 0}, {0x5815, 0x06, 0, 0}, - {0x5816, 0x0a, 0, 0}, {0x5817, 0x0f, 0, 0}, {0x5818, 0x0a, 0, 0}, - {0x5819, 0x05, 0, 0}, {0x581a, 0x01, 0, 0}, {0x581b, 0x00, 0, 0}, - {0x581c, 0x00, 0, 0}, {0x581d, 0x03, 0, 0}, {0x581e, 0x08, 0, 0}, - {0x581f, 0x0c, 0, 0}, {0x5820, 0x0a, 0, 0}, {0x5821, 0x05, 0, 0}, - {0x5822, 0x01, 0, 0}, {0x5823, 0x00, 0, 0}, {0x5824, 0x00, 0, 0}, - {0x5825, 0x03, 0, 0}, {0x5826, 0x08, 0, 0}, {0x5827, 0x0c, 0, 0}, - {0x5828, 0x0e, 0, 0}, {0x5829, 0x08, 0, 0}, {0x582a, 0x06, 0, 0}, - {0x582b, 0x04, 0, 0}, {0x582c, 0x05, 0, 0}, {0x582d, 0x07, 0, 0}, - {0x582e, 0x0b, 0, 0}, {0x582f, 0x12, 0, 0}, {0x5830, 0x18, 0, 0}, - {0x5831, 0x10, 0, 0}, {0x5832, 0x0c, 0, 0}, {0x5833, 0x0a, 0, 0}, - {0x5834, 0x0b, 0, 0}, {0x5835, 0x0e, 0, 0}, {0x5836, 0x15, 0, 0}, - {0x5837, 0x19, 0, 0}, {0x5838, 0x32, 0, 0}, {0x5839, 0x1f, 0, 0}, - {0x583a, 0x18, 0, 0}, {0x583b, 0x16, 0, 0}, {0x583c, 0x17, 0, 0}, - {0x583d, 0x1e, 0, 0}, {0x583e, 0x26, 0, 0}, {0x583f, 0x53, 0, 0}, - {0x5840, 0x10, 0, 0}, {0x5841, 0x0f, 0, 0}, {0x5842, 0x0d, 0, 0}, - {0x5843, 0x0c, 0, 0}, {0x5844, 0x0e, 0, 0}, {0x5845, 0x09, 0, 0}, - {0x5846, 0x11, 0, 0}, {0x5847, 0x10, 0, 0}, {0x5848, 0x10, 0, 0}, - {0x5849, 0x10, 0, 0}, {0x584a, 0x10, 0, 0}, {0x584b, 0x0e, 0, 0}, - {0x584c, 0x10, 0, 0}, {0x584d, 0x10, 0, 0}, {0x584e, 0x11, 0, 0}, - {0x584f, 0x10, 0, 0}, {0x5850, 0x0f, 0, 0}, {0x5851, 0x0c, 0, 0}, - {0x5852, 0x0f, 0, 0}, {0x5853, 0x10, 0, 0}, {0x5854, 0x10, 0, 0}, - {0x5855, 0x0f, 0, 0}, {0x5856, 0x0e, 0, 0}, {0x5857, 0x0b, 0, 0}, - {0x5858, 0x10, 0, 0}, {0x5859, 0x0d, 0, 0}, {0x585a, 0x0d, 0, 0}, - {0x585b, 0x0c, 0, 0}, {0x585c, 0x0c, 0, 0}, {0x585d, 0x0c, 0, 0}, - {0x585e, 0x0b, 0, 0}, {0x585f, 0x0c, 0, 0}, {0x5860, 0x0c, 0, 0}, - {0x5861, 0x0c, 0, 0}, {0x5862, 0x0d, 0, 0}, {0x5863, 0x08, 0, 0}, - {0x5864, 0x11, 0, 0}, {0x5865, 0x18, 0, 0}, {0x5866, 0x18, 0, 0}, - {0x5867, 0x19, 0, 0}, {0x5868, 0x17, 0, 0}, {0x5869, 0x19, 0, 0}, - {0x586a, 0x16, 0, 0}, {0x586b, 0x13, 0, 0}, {0x586c, 0x13, 0, 0}, - {0x586d, 0x12, 0, 0}, {0x586e, 0x13, 0, 0}, {0x586f, 0x16, 0, 0}, - {0x5870, 0x14, 0, 0}, {0x5871, 0x12, 0, 0}, {0x5872, 0x10, 0, 0}, - {0x5873, 0x11, 0, 0}, {0x5874, 0x11, 0, 0}, {0x5875, 0x16, 0, 0}, - {0x5876, 0x14, 0, 0}, {0x5877, 0x11, 0, 0}, {0x5878, 0x10, 0, 0}, - {0x5879, 0x0f, 0, 0}, {0x587a, 0x10, 0, 0}, {0x587b, 0x14, 0, 0}, - {0x587c, 0x13, 0, 0}, {0x587d, 0x12, 0, 0}, {0x587e, 0x11, 0, 0}, - {0x587f, 0x11, 0, 0}, {0x5880, 0x12, 0, 0}, {0x5881, 0x15, 0, 0}, - {0x5882, 0x14, 0, 0}, {0x5883, 0x15, 0, 0}, {0x5884, 0x15, 0, 0}, - {0x5885, 0x15, 0, 0}, {0x5886, 0x13, 0, 0}, {0x5887, 0x17, 0, 0}, - {0x3710, 0x10, 0, 0}, {0x3632, 0x51, 0, 0}, {0x3702, 0x10, 0, 0}, - {0x3703, 0xb2, 0, 0}, {0x3704, 0x18, 0, 0}, {0x370b, 0x40, 0, 0}, - {0x370d, 0x03, 0, 0}, {0x3631, 0x01, 0, 0}, {0x3632, 0x52, 0, 0}, - {0x3606, 0x24, 0, 0}, {0x3620, 0x96, 0, 0}, {0x5785, 0x07, 0, 0}, - {0x3a13, 0x30, 0, 0}, {0x3600, 0x52, 0, 0}, {0x3604, 0x48, 0, 0}, - {0x3606, 0x1b, 0, 0}, {0x370d, 0x0b, 0, 0}, {0x370f, 0xc0, 0, 0}, - {0x3709, 0x01, 0, 0}, {0x3823, 0x00, 0, 0}, {0x5007, 0x00, 0, 0}, - {0x5009, 0x00, 0, 0}, {0x5011, 0x00, 0, 0}, {0x5013, 0x00, 0, 0}, - {0x519e, 0x00, 0, 0}, {0x5086, 0x00, 0, 0}, {0x5087, 0x00, 0, 0}, - {0x5088, 0x00, 0, 0}, {0x5089, 0x00, 0, 0}, {0x302b, 0x00, 0, 0}, - {0x3824, 0x11, 0, 0}, {0x3825, 0xdc, 0, 0}, {0x3826, 0x00, 0, 0}, - {0x3827, 0x08, 0, 0}, {0x380c, 0x0c, 0, 0}, {0x380d, 0x80, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xe8, 0, 0}, {0x3808, 0x02, 0, 0}, - {0x3809, 0xd0, 0, 0}, {0x380A, 0x02, 0, 0}, {0x380B, 0x40, 0, 0}, - {0x3804, 0x04, 0, 0}, {0x3805, 0xb0, 0, 0}, {0x3806, 0x03, 0, 0}, - {0x3807, 0xc0, 0, 0}, {0x5686, 0x03, 0, 0}, {0x5687, 0xc0, 0, 0}, - {0x5682, 0x04, 0, 0}, {0x5683, 0xb0, 0, 0}, -}; - -static struct ov5642_mode_info ov5642_mode_info_data[2][ov5642_mode_MAX + 1] = { - { - {ov5642_mode_VGA_640_480, 640, 480, - ov5642_setting_15fps_VGA_640_480, - ARRAY_SIZE(ov5642_setting_15fps_VGA_640_480)}, - {ov5642_mode_QVGA_320_240, 320, 240, - ov5642_setting_15fps_QVGA_320_240, - ARRAY_SIZE(ov5642_setting_15fps_QVGA_320_240)}, - {ov5642_mode_NTSC_720_480, 720, 480, - ov5642_setting_15fps_NTSC_720_480, - ARRAY_SIZE(ov5642_setting_15fps_NTSC_720_480)}, - {ov5642_mode_PAL_720_576, 720, 576, - ov5642_setting_15fps_PAL_720_576, - ARRAY_SIZE(ov5642_setting_15fps_PAL_720_576)}, - {ov5642_mode_720P_1280_720, 1280, 720, - ov5642_setting_15fps_720P_1280_720, - ARRAY_SIZE(ov5642_setting_15fps_720P_1280_720)}, - {ov5642_mode_1080P_1920_1080, 1920, 1080, - ov5642_setting_15fps_1080P_1920_1080, - ARRAY_SIZE(ov5642_setting_15fps_1080P_1920_1080)}, - {ov5642_mode_QSXGA_2592_1944, 2592, 1944, - ov5642_setting_15fps_QSXGA_2592_1944, - ARRAY_SIZE(ov5642_setting_15fps_QSXGA_2592_1944)}, - {ov5642_mode_QCIF_176_144, 176, 144, - ov5642_setting_15fps_QCIF_176_144, - ARRAY_SIZE(ov5642_setting_15fps_QCIF_176_144)}, - {ov5642_mode_XGA_1024_768, 1024, 768, - ov5642_setting_15fps_XGA_1024_768, - ARRAY_SIZE(ov5642_setting_15fps_XGA_1024_768)}, - }, - { - {ov5642_mode_VGA_640_480, 640, 480, - ov5642_setting_30fps_VGA_640_480, - ARRAY_SIZE(ov5642_setting_30fps_VGA_640_480)}, - {ov5642_mode_QVGA_320_240, 320, 240, - ov5642_setting_30fps_QVGA_320_240, - ARRAY_SIZE(ov5642_setting_30fps_QVGA_320_240)}, - {ov5642_mode_NTSC_720_480, 720, 480, - ov5642_setting_30fps_NTSC_720_480, - ARRAY_SIZE(ov5642_setting_30fps_NTSC_720_480)}, - {ov5642_mode_PAL_720_576, 720, 576, - ov5642_setting_30fps_PAL_720_576, - ARRAY_SIZE(ov5642_setting_30fps_PAL_720_576)}, - {ov5642_mode_720P_1280_720, 1280, 720, - ov5642_setting_30fps_720P_1280_720, - ARRAY_SIZE(ov5642_setting_30fps_720P_1280_720)}, - {ov5642_mode_1080P_1920_1080, 0, 0, NULL, 0}, - {ov5642_mode_QSXGA_2592_1944, 0, 0, NULL, 0}, - {ov5642_mode_QCIF_176_144, 176, 144, - ov5642_setting_30fps_QCIF_176_144, - ARRAY_SIZE(ov5642_setting_30fps_QCIF_176_144)}, - {ov5642_mode_XGA_1024_768, 1024, 768, - ov5642_setting_30fps_XGA_1024_768, - ARRAY_SIZE(ov5642_setting_30fps_XGA_1024_768)}, - }, -}; - -static struct regulator *io_regulator; -static struct regulator *core_regulator; -static struct regulator *analog_regulator; -static struct regulator *gpo_regulator; - -static int ov5642_probe(struct i2c_client *adapter, - const struct i2c_device_id *device_id); -static int ov5642_remove(struct i2c_client *client); - -static s32 ov5642_read_reg(u16 reg, u8 *val); -static s32 ov5642_write_reg(u16 reg, u8 val); - -static const struct i2c_device_id ov5642_id[] = { - {"ov5642", 0}, - {"ov564x", 0}, - {}, -}; - -MODULE_DEVICE_TABLE(i2c, ov5642_id); - -static struct i2c_driver ov5642_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "ov5642", - }, - .probe = ov5642_probe, - .remove = ov5642_remove, - .id_table = ov5642_id, -}; - -static void ov5642_standby(s32 enable) -{ - if (enable) - gpio_set_value(pwn_gpio, 1); - else - gpio_set_value(pwn_gpio, 0); - - msleep(2); -} - -static void ov5642_reset(void) -{ - /* camera reset */ - gpio_set_value(rst_gpio, 1); - - /* camera power down */ - gpio_set_value(pwn_gpio, 1); - msleep(5); - - gpio_set_value(pwn_gpio, 0); - msleep(5); - - gpio_set_value(rst_gpio, 0); - msleep(1); - - gpio_set_value(rst_gpio, 1); - msleep(5); - - gpio_set_value(pwn_gpio, 1); -} - -static int ov5642_power_on(struct device *dev) -{ - int ret = 0; - - io_regulator = devm_regulator_get(dev, "DOVDD"); - if (!IS_ERR(io_regulator)) { - regulator_set_voltage(io_regulator, - OV5642_VOLTAGE_DIGITAL_IO, - OV5642_VOLTAGE_DIGITAL_IO); - ret = regulator_enable(io_regulator); - if (ret) { - pr_err("%s:io set voltage error\n", __func__); - return ret; - } else { - dev_dbg(dev, - "%s:io set voltage ok\n", __func__); - } - } else { - pr_err("%s: cannot get io voltage error\n", __func__); - io_regulator = NULL; - } - - core_regulator = devm_regulator_get(dev, "DVDD"); - if (!IS_ERR(core_regulator)) { - regulator_set_voltage(core_regulator, - OV5642_VOLTAGE_DIGITAL_CORE, - OV5642_VOLTAGE_DIGITAL_CORE); - ret = regulator_enable(core_regulator); - if (ret) { - pr_err("%s:core set voltage error\n", __func__); - return ret; - } else { - dev_dbg(dev, - "%s:core set voltage ok\n", __func__); - } - } else { - core_regulator = NULL; - pr_err("%s: cannot get core voltage error\n", __func__); - } - - analog_regulator = devm_regulator_get(dev, "AVDD"); - if (!IS_ERR(analog_regulator)) { - regulator_set_voltage(analog_regulator, - OV5642_VOLTAGE_ANALOG, - OV5642_VOLTAGE_ANALOG); - ret = regulator_enable(analog_regulator); - if (ret) { - pr_err("%s:analog set voltage error\n", - __func__); - return ret; - } else { - dev_dbg(dev, - "%s:analog set voltage ok\n", __func__); - } - } else { - analog_regulator = NULL; - pr_err("%s: cannot get analog voltage error\n", __func__); - } - - return ret; -} - -static s32 ov5642_write_reg(u16 reg, u8 val) -{ - u8 au8Buf[3] = {0}; - - au8Buf[0] = reg >> 8; - au8Buf[1] = reg & 0xff; - au8Buf[2] = val; - - if (i2c_master_send(ov5642_data.i2c_client, au8Buf, 3) < 0) { - pr_err("%s:write reg error:reg=%x,val=%x\n", - __func__, reg, val); - return -1; - } - - return 0; -} - -static s32 ov5642_read_reg(u16 reg, u8 *val) -{ - u8 au8RegBuf[2] = {0}; - u8 u8RdVal = 0; - - au8RegBuf[0] = reg >> 8; - au8RegBuf[1] = reg & 0xff; - - if (2 != i2c_master_send(ov5642_data.i2c_client, au8RegBuf, 2)) { - pr_err("%s:write reg error:reg=%x\n", - __func__, reg); - return -1; - } - - if (1 != i2c_master_recv(ov5642_data.i2c_client, &u8RdVal, 1)) { - pr_err("%s:read reg error:reg=%x,val=%x\n", - __func__, reg, u8RdVal); - return -1; - } - - *val = u8RdVal; - - return u8RdVal; -} - -static int ov5642_set_rot_mode(struct reg_value *rot_mode) -{ - s32 i = 0; - s32 iModeSettingArySize = 2; - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int retval = 0; - for (i = 0; i < iModeSettingArySize; ++i, ++rot_mode) { - Delay_ms = rot_mode->u32Delay_ms; - RegAddr = rot_mode->u16RegAddr; - Val = rot_mode->u8Val; - Mask = rot_mode->u8Mask; - - if (Mask) { - retval = ov5642_read_reg(RegAddr, &RegVal); - if (retval < 0) { - pr_err("%s, read reg 0x%x failed\n", - __func__, RegAddr); - goto err; - } - - Val |= RegVal; - Val &= Mask; - } - - retval = ov5642_write_reg(RegAddr, Val); - if (retval < 0) { - pr_err("%s, write reg 0x%x failed\n", - __func__, RegAddr); - goto err; - } - - if (Delay_ms) - mdelay(Delay_ms); - } -err: - return retval; -} -static int ov5642_init_mode(enum ov5642_frame_rate frame_rate, - enum ov5642_mode mode); -static int ov5642_write_snapshot_para(enum ov5642_frame_rate frame_rate, - enum ov5642_mode mode); -static int ov5642_change_mode(enum ov5642_frame_rate new_frame_rate, - enum ov5642_frame_rate old_frame_rate, - enum ov5642_mode new_mode, - enum ov5642_mode orig_mode) -{ - struct reg_value *pModeSetting = NULL; - s32 i = 0; - s32 iModeSettingArySize = 0; - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int retval = 0; - - if (new_mode > ov5642_mode_MAX || new_mode < ov5642_mode_MIN) { - pr_err("Wrong ov5642 mode detected!\n"); - return -1; - } - - if ((new_frame_rate == old_frame_rate) && - (new_mode == ov5642_mode_VGA_640_480) && - (orig_mode == ov5642_mode_QSXGA_2592_1944)) { - pModeSetting = ov5642_setting_QSXGA_2_VGA; - iModeSettingArySize = ARRAY_SIZE(ov5642_setting_QSXGA_2_VGA); - ov5642_data.pix.width = 640; - ov5642_data.pix.height = 480; - } else if ((new_frame_rate == old_frame_rate) && - (new_mode == ov5642_mode_QVGA_320_240) && - (orig_mode == ov5642_mode_VGA_640_480)) { - pModeSetting = ov5642_setting_VGA_2_QVGA; - iModeSettingArySize = ARRAY_SIZE(ov5642_setting_VGA_2_QVGA); - ov5642_data.pix.width = 320; - ov5642_data.pix.height = 240; - } else { - retval = ov5642_write_snapshot_para(new_frame_rate, new_mode); - goto err; - } - - if (ov5642_data.pix.width == 0 || ov5642_data.pix.height == 0 || - pModeSetting == NULL || iModeSettingArySize == 0) - return -EINVAL; - - for (i = 0; i < iModeSettingArySize; ++i, ++pModeSetting) { - Delay_ms = pModeSetting->u32Delay_ms; - RegAddr = pModeSetting->u16RegAddr; - Val = pModeSetting->u8Val; - Mask = pModeSetting->u8Mask; - - if (Mask) { - retval = ov5642_read_reg(RegAddr, &RegVal); - if (retval < 0) { - pr_err("read reg error addr=0x%x", RegAddr); - goto err; - } - - RegVal &= ~(u8)Mask; - Val &= Mask; - Val |= RegVal; - } - - retval = ov5642_write_reg(RegAddr, Val); - if (retval < 0) { - pr_err("write reg error addr=0x%x", RegAddr); - goto err; - } - - if (Delay_ms) - msleep(Delay_ms); - } -err: - return retval; -} -static int ov5642_init_mode(enum ov5642_frame_rate frame_rate, - enum ov5642_mode mode) -{ - struct reg_value *pModeSetting = NULL; - s32 i = 0; - s32 iModeSettingArySize = 0; - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int retval = 0; - - if (mode > ov5642_mode_MAX || mode < ov5642_mode_MIN) { - pr_err("Wrong ov5642 mode detected!\n"); - return -1; - } - - pModeSetting = ov5642_mode_info_data[frame_rate][mode].init_data_ptr; - iModeSettingArySize = - ov5642_mode_info_data[frame_rate][mode].init_data_size; - - ov5642_data.pix.width = ov5642_mode_info_data[frame_rate][mode].width; - ov5642_data.pix.height = ov5642_mode_info_data[frame_rate][mode].height; - - if (ov5642_data.pix.width == 0 || ov5642_data.pix.height == 0 || - pModeSetting == NULL || iModeSettingArySize == 0) - return -EINVAL; - - for (i = 0; i < iModeSettingArySize; ++i, ++pModeSetting) { - Delay_ms = pModeSetting->u32Delay_ms; - RegAddr = pModeSetting->u16RegAddr; - Val = pModeSetting->u8Val; - Mask = pModeSetting->u8Mask; - - if (Mask) { - retval = ov5642_read_reg(RegAddr, &RegVal); - if (retval < 0) { - pr_err("read reg error addr=0x%x", RegAddr); - goto err; - } - - RegVal &= ~(u8)Mask; - Val &= Mask; - Val |= RegVal; - } - - retval = ov5642_write_reg(RegAddr, Val); - if (retval < 0) { - pr_err("write reg error addr=0x%x", RegAddr); - goto err; - } - - if (Delay_ms) - msleep(Delay_ms); - } -err: - return retval; -} - -static int ov5642_write_snapshot_para(enum ov5642_frame_rate frame_rate, - enum ov5642_mode mode) -{ - int ret = 0; - bool m_60Hz = false; - u16 cap_frame_rate = 50; - u16 g_prev_frame_rate = 225; - - u8 ev_low, ev_mid, ev_high; - u8 ret_l, ret_m, ret_h, gain, lines_10ms; - u16 ulcap_ev, icap_gain, prev_maxlines; - u32 ulcap_ev_gain, cap_maxlines, g_prev_ev; - - ov5642_write_reg(0x3503, 0x07); - - ret_h = ret_m = ret_l = 0; - g_prev_ev = 0; - ov5642_read_reg(0x3500, &ret_h); - ov5642_read_reg(0x3501, &ret_m); - ov5642_read_reg(0x3502, &ret_l); - g_prev_ev = (ret_h << 12) + (ret_m << 4) + (ret_l >> 4); - - ret_h = ret_m = ret_l = 0; - prev_maxlines = 0; - ov5642_read_reg(0x380e, &ret_h); - ov5642_read_reg(0x380f, &ret_l); - prev_maxlines = (ret_h << 8) + ret_l; - /*Read back AGC Gain for preview*/ - gain = 0; - ov5642_read_reg(0x350b, &gain); - - ret = ov5642_init_mode(frame_rate, mode); - if (ret < 0) - return ret; - - ret_h = ret_m = ret_l = 0; - ov5642_read_reg(0x380e, &ret_h); - ov5642_read_reg(0x380f, &ret_l); - cap_maxlines = (ret_h << 8) + ret_l; - if (m_60Hz == true) - lines_10ms = cap_frame_rate * cap_maxlines/12000; - else - lines_10ms = cap_frame_rate * cap_maxlines/10000; - - if (prev_maxlines == 0) - prev_maxlines = 1; - - ulcap_ev = (g_prev_ev*(cap_frame_rate)*(cap_maxlines))/ - (((prev_maxlines)*(g_prev_frame_rate))); - icap_gain = (gain & 0x0f) + 16; - if (gain & 0x10) - icap_gain = icap_gain << 1; - - if (gain & 0x20) - icap_gain = icap_gain << 1; - - if (gain & 0x40) - icap_gain = icap_gain << 1; - - if (gain & 0x80) - icap_gain = icap_gain << 1; - - ulcap_ev_gain = 2 * ulcap_ev * icap_gain; - - if (ulcap_ev_gain < cap_maxlines*16) { - ulcap_ev = ulcap_ev_gain/16; - if (ulcap_ev > lines_10ms) { - ulcap_ev /= lines_10ms; - ulcap_ev *= lines_10ms; - } - } else - ulcap_ev = cap_maxlines; - - if (ulcap_ev == 0) - ulcap_ev = 1; - - icap_gain = (ulcap_ev_gain*2/ulcap_ev + 1)/2; - ev_low = ((unsigned char)ulcap_ev)<<4; - ev_mid = (unsigned char)(ulcap_ev >> 4) & 0xff; - ev_high = (unsigned char)(ulcap_ev >> 12); - - gain = 0; - if (icap_gain > 31) { - gain |= 0x10; - icap_gain = icap_gain >> 1; - } - if (icap_gain > 31) { - gain |= 0x20; - icap_gain = icap_gain >> 1; - } - if (icap_gain > 31) { - gain |= 0x40; - icap_gain = icap_gain >> 1; - } - if (icap_gain > 31) { - gain |= 0x80; - icap_gain = icap_gain >> 1; - } - if (icap_gain > 16) - gain |= ((icap_gain - 16) & 0x0f); - - if (gain == 0x10) - gain = 0x11; - - ov5642_write_reg(0x350b, gain); - ov5642_write_reg(0x3502, ev_low); - ov5642_write_reg(0x3501, ev_mid); - ov5642_write_reg(0x3500, ev_high); - msleep(500); - - return ret ; -} - - -/* --------------- IOCTL functions from v4l2_int_ioctl_desc --------------- */ - -static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) -{ - if (s == NULL) { - pr_err(" ERROR!! no slave device set!\n"); - return -1; - } - - memset(p, 0, sizeof(*p)); - p->u.bt656.clock_curr = ov5642_data.mclk; - pr_debug(" clock_curr=mclk=%d\n", ov5642_data.mclk); - p->if_type = V4L2_IF_TYPE_BT656; - p->u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT; - p->u.bt656.clock_min = OV5642_XCLK_MIN; - p->u.bt656.clock_max = OV5642_XCLK_MAX; - p->u.bt656.bt_sync_correct = 1; /* Indicate external vsync */ - - return 0; -} - -/*! - * ioctl_s_power - V4L2 sensor interface handler for VIDIOC_S_POWER ioctl - * @s: pointer to standard V4L2 device structure - * @on: indicates power mode (on or off) - * - * Turns the power on or off, depending on the value of on and returns the - * appropriate error code. - */ -static int ioctl_s_power(struct v4l2_int_device *s, int on) -{ - struct sensor_data *sensor = s->priv; - - if (on && !sensor->on) { - if (io_regulator) - if (regulator_enable(io_regulator) != 0) - return -EIO; - if (core_regulator) - if (regulator_enable(core_regulator) != 0) - return -EIO; - if (gpo_regulator) - if (regulator_enable(gpo_regulator) != 0) - return -EIO; - if (analog_regulator) - if (regulator_enable(analog_regulator) != 0) - return -EIO; - /* Make sure power on */ - ov5642_standby(0); - } else if (!on && sensor->on) { - if (analog_regulator) - regulator_disable(analog_regulator); - if (core_regulator) - regulator_disable(core_regulator); - if (io_regulator) - regulator_disable(io_regulator); - if (gpo_regulator) - regulator_disable(gpo_regulator); - - ov5642_standby(1); - } - - sensor->on = on; - - return 0; -} - -/*! - * ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure - * - * Returns the sensor's video CAPTURE parameters. - */ -static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - struct sensor_data *sensor = s->priv; - struct v4l2_captureparm *cparm = &a->parm.capture; - int ret = 0; - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - memset(a, 0, sizeof(*a)); - a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - cparm->capability = sensor->streamcap.capability; - cparm->timeperframe = sensor->streamcap.timeperframe; - cparm->capturemode = sensor->streamcap.capturemode; - ret = 0; - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl - * @s: pointer to standard V4L2 device structure - * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure - * - * Configures the sensor to use the input parameters, if possible. If - * not possible, reverts to the old parameters and returns the - * appropriate error code. - */ -static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) -{ - struct sensor_data *sensor = s->priv; - struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; - u32 tgt_fps, old_fps; /* target frames per secound */ - enum ov5642_frame_rate new_frame_rate, old_frame_rate; - int ret = 0; - - /* Make sure power on */ - ov5642_standby(0); - - switch (a->type) { - /* This is the only case currently handled. */ - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - /* Check that the new frame rate is allowed. */ - if ((timeperframe->numerator == 0) || - (timeperframe->denominator == 0)) { - timeperframe->denominator = DEFAULT_FPS; - timeperframe->numerator = 1; - } - - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps > MAX_FPS) { - timeperframe->denominator = MAX_FPS; - timeperframe->numerator = 1; - } else if (tgt_fps < MIN_FPS) { - timeperframe->denominator = MIN_FPS; - timeperframe->numerator = 1; - } - - /* Actual frame rate we use */ - tgt_fps = timeperframe->denominator / - timeperframe->numerator; - - if (tgt_fps == 15) - new_frame_rate = ov5642_15_fps; - else if (tgt_fps == 30) - new_frame_rate = ov5642_30_fps; - else { - pr_err(" The camera frame rate is not supported!\n"); - return -EINVAL; - } - - if (sensor->streamcap.timeperframe.numerator != 0) - old_fps = sensor->streamcap.timeperframe.denominator / - sensor->streamcap.timeperframe.numerator; - else - old_fps = 30; - - if (old_fps == 15) - old_frame_rate = ov5642_15_fps; - else if (old_fps == 30) - old_frame_rate = ov5642_30_fps; - else { - pr_warning(" No valid frame rate set!\n"); - old_frame_rate = ov5642_30_fps; - } - - ret = ov5642_change_mode(new_frame_rate, old_frame_rate, - a->parm.capture.capturemode, - sensor->streamcap.capturemode); - if (ret < 0) - return ret; - - sensor->streamcap.timeperframe = *timeperframe; - sensor->streamcap.capturemode = - (u32)a->parm.capture.capturemode; - break; - - /* These are all the possible cases. */ - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - case V4L2_BUF_TYPE_VBI_CAPTURE: - case V4L2_BUF_TYPE_VBI_OUTPUT: - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: - pr_debug(" type is not " \ - "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", - a->type); - ret = -EINVAL; - break; - - default: - pr_debug(" type is unknown - %d\n", a->type); - ret = -EINVAL; - break; - } - - return ret; -} - -/*! - * ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap - * @s: pointer to standard V4L2 device structure - * @f: pointer to standard V4L2 v4l2_format structure - * - * Returns the sensor's current pixel format in the v4l2_format - * parameter. - */ -static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) -{ - struct sensor_data *sensor = s->priv; - - f->fmt.pix = sensor->pix; - - return 0; -} - -/*! - * ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure - * - * If the requested control is supported, returns the control's current - * value from the video_control[] array. Otherwise, returns -EINVAL - * if the control is not supported. - */ -static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int ret = 0; - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - vc->value = ov5642_data.brightness; - break; - case V4L2_CID_HUE: - vc->value = ov5642_data.hue; - break; - case V4L2_CID_CONTRAST: - vc->value = ov5642_data.contrast; - break; - case V4L2_CID_SATURATION: - vc->value = ov5642_data.saturation; - break; - case V4L2_CID_RED_BALANCE: - vc->value = ov5642_data.red; - break; - case V4L2_CID_BLUE_BALANCE: - vc->value = ov5642_data.blue; - break; - case V4L2_CID_EXPOSURE: - vc->value = ov5642_data.ae_mode; - break; - default: - ret = -EINVAL; - } - - return ret; -} - -/*! - * ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl - * @s: pointer to standard V4L2 device structure - * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure - * - * If the requested control is supported, sets the control's current - * value in HW (and updates the video_control[] array). Otherwise, - * returns -EINVAL if the control is not supported. - */ -static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) -{ - int retval = 0; - struct sensor_data *sensor = s->priv; - __u32 captureMode = sensor->streamcap.capturemode; - struct reg_value *rot_mode = NULL; - - pr_debug("In ov5642:ioctl_s_ctrl %d\n", - vc->id); - - switch (vc->id) { - case V4L2_CID_BRIGHTNESS: - break; - case V4L2_CID_CONTRAST: - break; - case V4L2_CID_SATURATION: - break; - case V4L2_CID_HUE: - break; - case V4L2_CID_AUTO_WHITE_BALANCE: - break; - case V4L2_CID_DO_WHITE_BALANCE: - break; - case V4L2_CID_RED_BALANCE: - break; - case V4L2_CID_BLUE_BALANCE: - break; - case V4L2_CID_GAMMA: - break; - case V4L2_CID_EXPOSURE: - break; - case V4L2_CID_AUTOGAIN: - break; - case V4L2_CID_GAIN: - break; - case V4L2_CID_HFLIP: - break; - case V4L2_CID_VFLIP: - break; - case V4L2_CID_MXC_ROT: - case V4L2_CID_MXC_VF_ROT: - switch (vc->value) { - case V4L2_MXC_ROTATE_NONE: - if (captureMode == ov5642_mode_QSXGA_2592_1944) - rot_mode = ov5642_rot_none_FULL; - else - rot_mode = ov5642_rot_none_VGA; - - if (ov5642_set_rot_mode(rot_mode)) - retval = -EPERM; - break; - case V4L2_MXC_ROTATE_VERT_FLIP: - if (captureMode == ov5642_mode_QSXGA_2592_1944) - rot_mode = ov5642_rot_vert_flip_FULL; - else - rot_mode = ov5642_rot_vert_flip_VGA ; - - if (ov5642_set_rot_mode(rot_mode)) - retval = -EPERM; - break; - case V4L2_MXC_ROTATE_HORIZ_FLIP: - if (captureMode == ov5642_mode_QSXGA_2592_1944) - rot_mode = ov5642_rot_horiz_flip_FULL; - else - rot_mode = ov5642_rot_horiz_flip_VGA; - - if (ov5642_set_rot_mode(rot_mode)) - retval = -EPERM; - break; - case V4L2_MXC_ROTATE_180: - if (captureMode == ov5642_mode_QSXGA_2592_1944) - rot_mode = ov5642_rot_180_FULL; - else - rot_mode = ov5642_rot_180_VGA; - - if (ov5642_set_rot_mode(rot_mode)) - retval = -EPERM; - break; - default: - retval = -EPERM; - break; - } - break; - default: - retval = -EPERM; - break; - } - - return retval; -} - -/*! - * ioctl_enum_framesizes - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMESIZES ioctl - * @s: pointer to standard V4L2 device structure - * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_framesizes(struct v4l2_int_device *s, - struct v4l2_frmsizeenum *fsize) -{ - if (fsize->index > ov5642_mode_MAX) - return -EINVAL; - - fsize->pixel_format = ov5642_data.pix.pixelformat; - fsize->discrete.width = - max(ov5642_mode_info_data[0][fsize->index].width, - ov5642_mode_info_data[1][fsize->index].width); - fsize->discrete.height = - max(ov5642_mode_info_data[0][fsize->index].height, - ov5642_mode_info_data[1][fsize->index].height); - return 0; -} - -/*! - * ioctl_enum_frameintervals - V4L2 sensor interface handler for - * VIDIOC_ENUM_FRAMEINTERVALS ioctl - * @s: pointer to standard V4L2 device structure - * @fival: standard V4L2 VIDIOC_ENUM_FRAMEINTERVALS ioctl structure - * - * Return 0 if successful, otherwise -EINVAL. - */ -static int ioctl_enum_frameintervals(struct v4l2_int_device *s, - struct v4l2_frmivalenum *fival) -{ - int i, j, count; - - if (fival->index < 0 || fival->index > ov5642_mode_MAX) - return -EINVAL; - - if (fival->pixel_format == 0 || fival->width == 0 || - fival->height == 0) { - pr_warning("Please assign pixelformat, width and height.\n"); - return -EINVAL; - } - - fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; - fival->discrete.numerator = 1; - - count = 0; - for (i = 0; i < ARRAY_SIZE(ov5642_mode_info_data); i++) { - for (j = 0; j < (ov5642_mode_MAX + 1); j++) { - if (fival->pixel_format == ov5642_data.pix.pixelformat - && fival->width == ov5642_mode_info_data[i][j].width - && fival->height == ov5642_mode_info_data[i][j].height - && ov5642_mode_info_data[i][j].init_data_ptr != NULL) { - count++; - } - if (fival->index == (count - 1)) { - fival->discrete.denominator = - ov5642_framerates[i]; - return 0; - } - } - } - - return -EINVAL; -} - -/*! - * ioctl_g_chip_ident - V4L2 sensor interface handler for - * VIDIOC_DBG_G_CHIP_IDENT ioctl - * @s: pointer to standard V4L2 device structure - * @id: pointer to int - * - * Return 0. - */ -static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id) -{ - ((struct v4l2_dbg_chip_ident *)id)->match.type = - V4L2_CHIP_MATCH_I2C_DRIVER; - strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name, "ov5642_camera"); - - return 0; -} - -/*! - * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT - * @s: pointer to standard V4L2 device structure - */ -static int ioctl_init(struct v4l2_int_device *s) -{ - - return 0; -} - -/*! - * ioctl_enum_fmt_cap - V4L2 sensor interface handler for VIDIOC_ENUM_FMT - * @s: pointer to standard V4L2 device structure - * @fmt: pointer to standard V4L2 fmt description structure - * - * Return 0. - */ -static int ioctl_enum_fmt_cap(struct v4l2_int_device *s, - struct v4l2_fmtdesc *fmt) -{ - if (fmt->index > 0) /* only 1 pixelformat support so far */ - return -EINVAL; - - fmt->pixelformat = ov5642_data.pix.pixelformat; - - return 0; -} - -/*! - * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num - * @s: pointer to standard V4L2 device structure - * - * Initialise the device when slave attaches to the master. - */ -static int ioctl_dev_init(struct v4l2_int_device *s) -{ - struct reg_value *pModeSetting = NULL; - s32 i = 0; - s32 iModeSettingArySize = 0; - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int retval = 0; - - struct sensor_data *sensor = s->priv; - u32 tgt_xclk; /* target xclk */ - u32 tgt_fps; /* target frames per secound */ - enum ov5642_frame_rate frame_rate; - - ov5642_data.on = true; - - /* mclk */ - tgt_xclk = ov5642_data.mclk; - tgt_xclk = min(tgt_xclk, (u32)OV5642_XCLK_MAX); - tgt_xclk = max(tgt_xclk, (u32)OV5642_XCLK_MIN); - ov5642_data.mclk = tgt_xclk; - - pr_debug(" Setting mclk to %d MHz\n", tgt_xclk / 1000000); - - /* Default camera frame rate is set in probe */ - tgt_fps = sensor->streamcap.timeperframe.denominator / - sensor->streamcap.timeperframe.numerator; - - if (tgt_fps == 15) - frame_rate = ov5642_15_fps; - else if (tgt_fps == 30) - frame_rate = ov5642_30_fps; - else - return -EINVAL; /* Only support 15fps or 30fps now. */ - - pModeSetting = ov5642_initial_setting; - iModeSettingArySize = ARRAY_SIZE(ov5642_initial_setting); - - for (i = 0; i < iModeSettingArySize; ++i, ++pModeSetting) { - Delay_ms = pModeSetting->u32Delay_ms; - RegAddr = pModeSetting->u16RegAddr; - Val = pModeSetting->u8Val; - Mask = pModeSetting->u8Mask; - if (Mask) { - retval = ov5642_read_reg(RegAddr, &RegVal); - if (retval < 0) - goto err; - - RegVal &= ~(u8)Mask; - Val &= Mask; - Val |= RegVal; - } - - retval = ov5642_write_reg(RegAddr, Val); - if (retval < 0) - goto err; - - if (Delay_ms) - msleep(Delay_ms); - } -err: - return retval; -} - -/*! - * ioctl_dev_exit - V4L2 sensor interface handler for vidioc_int_dev_exit_num - * @s: pointer to standard V4L2 device structure - * - * Delinitialise the device when slave detaches to the master. - */ -static int ioctl_dev_exit(struct v4l2_int_device *s) -{ - return 0; -} - -/*! - * This structure defines all the ioctls for this module and links them to the - * enumeration. - */ -static struct v4l2_int_ioctl_desc ov5642_ioctl_desc[] = { - { vidioc_int_dev_init_num, - (v4l2_int_ioctl_func *)ioctl_dev_init }, - { vidioc_int_dev_exit_num, ioctl_dev_exit}, - { vidioc_int_s_power_num, - (v4l2_int_ioctl_func *)ioctl_s_power }, - { vidioc_int_g_ifparm_num, - (v4l2_int_ioctl_func *)ioctl_g_ifparm }, -/* { vidioc_int_g_needs_reset_num, - (v4l2_int_ioctl_func *)ioctl_g_needs_reset }, */ -/* { vidioc_int_reset_num, - (v4l2_int_ioctl_func *)ioctl_reset }, */ - { vidioc_int_init_num, - (v4l2_int_ioctl_func *)ioctl_init }, - { vidioc_int_enum_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap }, -/* { vidioc_int_try_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_try_fmt_cap }, */ - { vidioc_int_g_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_g_fmt_cap }, -/* { vidioc_int_s_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_s_fmt_cap }, */ - { vidioc_int_g_parm_num, - (v4l2_int_ioctl_func *)ioctl_g_parm }, - { vidioc_int_s_parm_num, - (v4l2_int_ioctl_func *)ioctl_s_parm }, -/* { vidioc_int_queryctrl_num, - (v4l2_int_ioctl_func *)ioctl_queryctrl }, */ - { vidioc_int_g_ctrl_num, - (v4l2_int_ioctl_func *)ioctl_g_ctrl }, - { vidioc_int_s_ctrl_num, - (v4l2_int_ioctl_func *)ioctl_s_ctrl }, - { vidioc_int_enum_framesizes_num, - (v4l2_int_ioctl_func *)ioctl_enum_framesizes }, - { vidioc_int_enum_frameintervals_num, - (v4l2_int_ioctl_func *)ioctl_enum_frameintervals }, - { vidioc_int_g_chip_ident_num, - (v4l2_int_ioctl_func *)ioctl_g_chip_ident }, -}; - -static struct v4l2_int_slave ov5642_slave = { - .ioctls = ov5642_ioctl_desc, - .num_ioctls = ARRAY_SIZE(ov5642_ioctl_desc), -}; - -static struct v4l2_int_device ov5642_int_device = { - .module = THIS_MODULE, - .name = "ov5642", - .type = v4l2_int_type_slave, - .u = { - .slave = &ov5642_slave, - }, -}; - -/*! - * ov5642 I2C probe function - * - * @param adapter struct i2c_adapter * - * @return Error code indicating success or failure - */ -static int ov5642_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct pinctrl *pinctrl; - struct device *dev = &client->dev; - int retval; - u8 chip_id_high, chip_id_low; - - /* ov5642 pinctrl */ - pinctrl = devm_pinctrl_get_select_default(dev); - if (IS_ERR(pinctrl)) { - dev_err(dev, "ov5642 setup pinctrl failed!"); - return PTR_ERR(pinctrl); - } - - /* request power down pin */ - pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); - if (!gpio_is_valid(pwn_gpio)) { - dev_warn(dev, "no sensor pwdn pin available"); - return -EINVAL; - } - retval = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, - "ov5642_pwdn"); - if (retval < 0) - return retval; - - /* request reset pin */ - rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0); - if (!gpio_is_valid(rst_gpio)) { - dev_warn(dev, "no sensor reset pin available"); - return -EINVAL; - } - retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_HIGH, - "ov5642_reset"); - if (retval < 0) - return retval; - - /* Set initial values for the sensor struct. */ - memset(&ov5642_data, 0, sizeof(ov5642_data)); - ov5642_data.sensor_clk = devm_clk_get(dev, "csi_mclk"); - if (IS_ERR(ov5642_data.sensor_clk)) { - /* assuming clock enabled by default */ - ov5642_data.sensor_clk = NULL; - dev_err(dev, "clock-frequency missing or invalid\n"); - return PTR_ERR(ov5642_data.sensor_clk); - } - - retval = of_property_read_u32(dev->of_node, "mclk", - (u32 *) &(ov5642_data.mclk)); - if (retval) { - dev_err(dev, "mclk missing or invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "mclk_source", - (u32 *) &(ov5642_data.mclk_source)); - if (retval) { - dev_err(dev, "mclk_source missing or invalid\n"); - return retval; - } - - retval = of_property_read_u32(dev->of_node, "csi_id", - &(ov5642_data.csi)); - if (retval) { - dev_err(dev, "csi_id missing or invalid\n"); - return retval; - } - - clk_prepare_enable(ov5642_data.sensor_clk); - - ov5642_data.io_init = ov5642_reset; - ov5642_data.i2c_client = client; - ov5642_data.pix.pixelformat = V4L2_PIX_FMT_YUYV; - ov5642_data.pix.width = 640; - ov5642_data.pix.height = 480; - ov5642_data.streamcap.capability = V4L2_MODE_HIGHQUALITY | - V4L2_CAP_TIMEPERFRAME; - ov5642_data.streamcap.capturemode = 0; - ov5642_data.streamcap.timeperframe.denominator = DEFAULT_FPS; - ov5642_data.streamcap.timeperframe.numerator = 1; - - ov5642_power_on(&client->dev); - - ov5642_reset(); - - ov5642_standby(0); - - retval = ov5642_read_reg(OV5642_CHIP_ID_HIGH_BYTE, &chip_id_high); - if (retval < 0 || chip_id_high != 0x56) { - pr_warning("camera ov5642 is not found\n"); - clk_disable_unprepare(ov5642_data.sensor_clk); - return -ENODEV; - } - retval = ov5642_read_reg(OV5642_CHIP_ID_LOW_BYTE, &chip_id_low); - if (retval < 0 || chip_id_low != 0x42) { - pr_warning("camera ov5642 is not found\n"); - clk_disable_unprepare(ov5642_data.sensor_clk); - return -ENODEV; - } - - ov5642_standby(1); - - ov5642_int_device.priv = &ov5642_data; - retval = v4l2_int_device_register(&ov5642_int_device); - - clk_disable_unprepare(ov5642_data.sensor_clk); - - pr_info("camera ov5642 is found\n"); - return retval; -} - -/*! - * ov5642 I2C detach function - * - * @param client struct i2c_client * - * @return Error code indicating success or failure - */ -static int ov5642_remove(struct i2c_client *client) -{ - v4l2_int_device_unregister(&ov5642_int_device); - - if (gpo_regulator) - regulator_disable(gpo_regulator); - - if (analog_regulator) - regulator_disable(analog_regulator); - - if (core_regulator) - regulator_disable(core_regulator); - - if (io_regulator) - regulator_disable(io_regulator); - - return 0; -} - -/*! - * ov5642 init function - * Called by insmod ov5642_camera.ko. - * - * @return Error code indicating success or failure - */ -static __init int ov5642_init(void) -{ - u8 err; - - err = i2c_add_driver(&ov5642_i2c_driver); - if (err != 0) - pr_err("%s:driver registration failed, error=%d\n", - __func__, err); - - return err; -} - -/*! - * OV5642 cleanup function - * Called on rmmod ov5642_camera.ko - * - * @return Error code indicating success or failure - */ -static void __exit ov5642_clean(void) -{ - i2c_del_driver(&ov5642_i2c_driver); -} - -module_init(ov5642_init); -module_exit(ov5642_clean); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("OV5642 Camera Driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("CSI"); diff --git a/drivers/media/platform/mxc/capture/ov5647_mipi.c b/drivers/media/platform/mxc/capture/ov5647_mipi.c deleted file mode 100644 index 109f77438f514cc7a4ac0a570d51bf2003769176..0000000000000000000000000000000000000000 --- a/drivers/media/platform/mxc/capture/ov5647_mipi.c +++ /dev/null @@ -1,1721 +0,0 @@ -/* - * Copyright (C) 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define OV5647_VOLTAGE_ANALOG 2800000 -#define OV5647_VOLTAGE_DIGITAL_CORE 1500000 -#define OV5647_VOLTAGE_DIGITAL_IO 1800000 - -#define MIN_FPS 15 -#define MAX_FPS 30 -#define DEFAULT_FPS 30 - -#define OV5647_XCLK_MIN 6000000 -#define OV5647_XCLK_MAX 24000000 - -#define OV5647_CHIP_ID_HIGH_BYTE 0x300A -#define OV5647_CHIP_ID_LOW_BYTE 0x300B - -enum ov5647_mode { - ov5647_mode_MIN = 0, - ov5647_mode_VGA_640_480 = 0, - ov5647_mode_720P_1280_720 = 1, - ov5647_mode_1080P_1920_1080 = 2, - ov5647_mode_QSXGA_2592_1944 = 3, - ov5647_mode_MAX = 3, - ov5647_mode_INIT = 0xff, /*only for sensor init*/ -}; - -enum ov5647_frame_rate { - ov5647_15_fps, - ov5647_30_fps -}; - -static int ov5647_framerates[] = { - [ov5647_15_fps] = 15, - [ov5647_30_fps] = 30, -}; - -struct ov5647_datafmt { - u32 code; - enum v4l2_colorspace colorspace; -}; - -/* image size under 1280 * 960 are SUBSAMPLING - * image size upper 1280 * 960 are SCALING - */ -enum ov5647_downsize_mode { - SUBSAMPLING, - SCALING, -}; - -struct reg_value { - u16 u16RegAddr; - u8 u8Val; - u8 u8Mask; - u32 u32Delay_ms; -}; - -struct ov5647_mode_info { - enum ov5647_mode mode; - enum ov5647_downsize_mode dn_mode; - u32 width; - u32 height; - struct reg_value *init_data_ptr; - u32 init_data_size; -}; - -struct otp_struct { - int customer_id; - int module_integrator_id; - int lens_id; - int rg_ratio; - int bg_ratio; - int user_data[3]; - int light_rg; - int light_bg; -}; - -struct ov5647 { - struct v4l2_subdev subdev; - struct i2c_client *i2c_client; - struct v4l2_pix_format pix; - const struct ov5647_datafmt *fmt; - struct v4l2_captureparm streamcap; - bool on; - - /* control settings */ - int brightness; - int hue; - int contrast; - int saturation; - int red; - int green; - int blue; - int ae_mode; - - u32 mclk; - u8 mclk_source; - struct clk *sensor_clk; - int csi; - - void (*io_init)(void); -}; -/*! - * Maintains the information on the current state of the sesor. - */ -static struct ov5647 ov5647_data; -static int pwn_gpio, rst_gpio; -static int prev_sysclk, prev_HTS; -static int AE_low, AE_high, AE_Target = 52; - -/* R/G and B/G of typical camera module is defined here, - * the typical camera module is selected by CameraAnalyzer. */ -static int RG_Ratio_Typical = 0x70; -static int BG_Ratio_Typical = 0x70; - - -static struct reg_value ov5647_init_setting[] = { - - {0x0100, 0x00, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x69, 0, 0}, {0x303c, 0x11, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x370c, 0x0f, 0, 0}, {0x3612, 0x59, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x5000, 0x06, 0, 0}, {0x5002, 0x40, 0, 0}, - {0x5003, 0x08, 0, 0}, {0x5a00, 0x08, 0, 0}, {0x3000, 0xff, 0, 0}, - {0x3001, 0xff, 0, 0}, {0x3002, 0xff, 0, 0}, {0x301d, 0xf0, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3c01, 0x80, 0, 0}, - {0x3b07, 0x0c, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, - {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3814, 0x31, 0, 0}, - {0x3815, 0x31, 0, 0}, {0x3708, 0x64, 0, 0}, {0x3709, 0x52, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x03, 0, 0}, - {0x380b, 0xc0, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x18, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x0e, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x27, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x95, 0, 0}, - {0x3630, 0x2e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x23, 0, 0}, - {0x3634, 0x44, 0, 0}, {0x3620, 0x64, 0, 0}, {0x3621, 0xe0, 0, 0}, - {0x3600, 0x37, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, - {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x3731, 0x02, 0, 0}, - {0x370b, 0x60, 0, 0}, {0x3705, 0x1a, 0, 0}, {0x3f05, 0x02, 0, 0}, - {0x3f06, 0x10, 0, 0}, {0x3f01, 0x0a, 0, 0}, {0x3a08, 0x01, 0, 0}, - {0x3a09, 0x27, 0, 0}, {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, - {0x3a0d, 0x04, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3a0f, 0x58, 0, 0}, - {0x3a10, 0x50, 0, 0}, {0x3a1b, 0x58, 0, 0}, {0x3a1e, 0x50, 0, 0}, - {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x28, 0, 0}, {0x4001, 0x02, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x4000, 0x09, 0, 0}, {0x4050, 0x6e, 0, 0}, - {0x4051, 0x8f, 0, 0}, {0x4837, 0x17, 0, 0}, {0x3503, 0x03, 0, 0}, - {0x3501, 0x44, 0, 0}, {0x3502, 0x80, 0, 0}, {0x350a, 0x00, 0, 0}, - {0x350b, 0x7f, 0, 0}, {0x5001, 0x01, 0, 0}, {0x5002, 0x41, 0, 0}, - {0x5180, 0x08, 0, 0}, {0x5186, 0x04, 0, 0}, {0x5187, 0x00, 0, 0}, - {0x5188, 0x04, 0, 0}, {0x5189, 0x00, 0, 0}, {0x518a, 0x04, 0, 0}, - {0x518b, 0x00, 0, 0}, {0x5000, 0x86, 0, 0}, {0x5800, 0x11, 0, 0}, - {0x5801, 0x0a, 0, 0}, {0x5802, 0x09, 0, 0}, {0x5803, 0x09, 0, 0}, - {0x5804, 0x0a, 0, 0}, {0x5805, 0x0f, 0, 0}, {0x5806, 0x07, 0, 0}, - {0x5807, 0x05, 0, 0}, {0x5808, 0x03, 0, 0}, {0x5809, 0x03, 0, 0}, - {0x580a, 0x05, 0, 0}, {0x580b, 0x07, 0, 0}, {0x580c, 0x05, 0, 0}, - {0x580d, 0x02, 0, 0}, {0x580e, 0x00, 0, 0}, {0x580f, 0x00, 0, 0}, - {0x5810, 0x02, 0, 0}, {0x5811, 0x05, 0, 0}, {0x5812, 0x05, 0, 0}, - {0x5813, 0x02, 0, 0}, {0x5814, 0x00, 0, 0}, {0x5815, 0x00, 0, 0}, - {0x5816, 0x01, 0, 0}, {0x5817, 0x05, 0, 0}, {0x5818, 0x08, 0, 0}, - {0x5819, 0x05, 0, 0}, {0x581a, 0x03, 0, 0}, {0x581b, 0x03, 0, 0}, - {0x581c, 0x04, 0, 0}, {0x581d, 0x07, 0, 0}, {0x581e, 0x10, 0, 0}, - {0x581f, 0x0b, 0, 0}, {0x5820, 0x09, 0, 0}, {0x5821, 0x09, 0, 0}, - {0x5822, 0x09, 0, 0}, {0x5823, 0x0e, 0, 0}, {0x5824, 0x28, 0, 0}, - {0x5825, 0x1a, 0, 0}, {0x5826, 0x1a, 0, 0}, {0x5827, 0x1a, 0, 0}, - {0x5828, 0x46, 0, 0}, {0x5829, 0x2a, 0, 0}, {0x582a, 0x26, 0, 0}, - {0x582b, 0x44, 0, 0}, {0x582c, 0x26, 0, 0}, {0x582d, 0x2a, 0, 0}, - {0x582e, 0x28, 0, 0}, {0x582f, 0x42, 0, 0}, {0x5830, 0x40, 0, 0}, - {0x5831, 0x42, 0, 0}, {0x5832, 0x28, 0, 0}, {0x5833, 0x0a, 0, 0}, - {0x5834, 0x16, 0, 0}, {0x5835, 0x44, 0, 0}, {0x5836, 0x26, 0, 0}, - {0x5837, 0x2a, 0, 0}, {0x5838, 0x28, 0, 0}, {0x5839, 0x0a, 0, 0}, - {0x583a, 0x0a, 0, 0}, {0x583b, 0x0a, 0, 0}, {0x583c, 0x26, 0, 0}, - {0x583d, 0xbe, 0, 0}, {0x0100, 0x01, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x00, 0, 0}, {0x3017, 0xe0, 0, 0}, - {0x301c, 0xfc, 0, 0}, {0x3636, 0x06, 0, 0}, {0x3016, 0x08, 0, 0}, - {0x3827, 0xec, 0, 0}, {0x3018, 0x44, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3106, 0xf5, 0, 0}, {0x3034, 0x18, 0, 0}, {0x301c, 0xf8, 0, 0}, -}; - -static struct reg_value ov5647_setting_60fps_VGA_640_480[] = { - {0x0100, 0x00, 0, 0}, {0x3035, 0x11, 0, 0}, - {0x3036, 0x46, 0, 0}, {0x303c, 0x11, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3820, 0x41, 0, 0}, {0x370c, 0x0f, 0, 0}, {0x3612, 0x59, 0, 0}, - {0x3618, 0x00, 0, 0}, {0x5000, 0x06, 0, 0}, {0x5002, 0x40, 0, 0}, - {0x5003, 0x08, 0, 0}, {0x5a00, 0x08, 0, 0}, {0x3000, 0xff, 0, 0}, - {0x3001, 0xff, 0, 0}, {0x3002, 0xff, 0, 0}, {0x301d, 0xf0, 0, 0}, - {0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3c01, 0x80, 0, 0}, - {0x3b07, 0x0c, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x3c, 0, 0}, - {0x380e, 0x01, 0, 0}, {0x380f, 0xf8, 0, 0}, {0x3814, 0x71, 0, 0}, - {0x3815, 0x71, 0, 0}, {0x3708, 0x64, 0, 0}, {0x3709, 0x52, 0, 0}, - {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, - {0x380b, 0xe0, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x10, 0, 0}, - {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, {0x3804, 0x0a, 0, 0}, - {0x3805, 0x2f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9f, 0, 0}, - {0x3630, 0x2e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x23, 0, 0}, - {0x3634, 0x44, 0, 0}, {0x3620, 0x64, 0, 0}, {0x3621, 0xe0, 0, 0}, - {0x3600, 0x37, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, - {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x3731, 0x02, 0, 0}, - {0x370b, 0x60, 0, 0}, {0x3705, 0x1a, 0, 0}, {0x3f05, 0x02, 0, 0}, - {0x3f06, 0x10, 0, 0}, {0x3f01, 0x0a, 0, 0}, {0x3a08, 0x01, 0, 0}, - {0x3a09, 0x2e, 0, 0}, {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xfb, 0, 0}, - {0x3a0d, 0x02, 0, 0}, {0x3a0e, 0x01, 0, 0}, {0x3a0f, 0x58, 0, 0}, - {0x3a10, 0x50, 0, 0}, {0x3a1b, 0x58, 0, 0}, {0x3a1e, 0x50, 0, 0}, - {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x28, 0, 0}, {0x4001, 0x02, 0, 0}, - {0x4004, 0x02, 0, 0}, {0x4000, 0x09, 0, 0}, {0x4050, 0x6e, 0, 0}, - {0x4051, 0x8f, 0, 0}, {0x0100, 0x01, 0, 0}, {0x3000, 0x00, 0, 0}, - {0x3001, 0x00, 0, 0}, {0x3002, 0x00, 0, 0}, {0x3017, 0xe0, 0, 0}, - {0x301c, 0xfc, 0, 0}, {0x3636, 0x06, 0, 0}, {0x3016, 0x08, 0, 0}, - {0x3827, 0xec, 0, 0}, {0x3018, 0x44, 0, 0}, {0x3035, 0x21, 0, 0}, - {0x3106, 0xf5, 0, 0}, {0x3034, 0x18, 0, 0}, {0x301c, 0xf8, 0, 0}, -}; - -static struct reg_value ov5647_setting_30fps_720P_1280_720[] = { - {0x0100, 0x00, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, - {0x3612, 0x59, 0, 0}, {0x3618, 0x00, 0, 0}, {0x380c, 0x09, 0, 0}, - {0x380d, 0xe8, 0, 0}, {0x380e, 0x04, 0, 0}, {0x380f, 0x50, 0, 0}, - {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3709, 0x52, 0, 0}, - {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, - {0x380b, 0xd0, 0, 0}, {0x3801, 0x18, 0, 0}, {0x3802, 0x00, 0, 0}, - {0x3803, 0xf8, 0, 0}, {0x3804, 0x0a, 0, 0}, {0x3805, 0x27, 0, 0}, - {0x3806, 0x06, 0, 0}, {0x3807, 0xa7, 0, 0}, {0x3a09, 0xbe, 0, 0}, - {0x3a0a, 0x01, 0, 0}, {0x3a0b, 0x74, 0, 0}, {0x3a0d, 0x02, 0, 0}, - {0x3a0e, 0x01, 0, 0}, {0x4004, 0x02, 0, 0}, {0x4005, 0x18, 0, 0}, - {0x0100, 0x01, 0, 0}, -}; - -static struct reg_value ov5647_setting_30fps_1080P_1920_1080[] = { - {0x0100, 0x00, 0, 0}, {0x3820, 0x00, 0, 0}, {0x3821, 0x06, 0, 0}, - {0x3612, 0x5b, 0, 0}, {0x3618, 0x04, 0, 0}, {0x380c, 0x09, 0, 0}, - {0x380d, 0xe8, 0, 0}, {0x380e, 0x04, 0, 0}, {0x380f, 0x50, 0, 0}, - {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3709, 0x12, 0, 0}, - {0x3808, 0x07, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x04, 0, 0}, - {0x380b, 0x38, 0, 0}, {0x3801, 0x5c, 0, 0}, {0x3802, 0x01, 0, 0}, - {0x3803, 0xb2, 0, 0}, {0x3804, 0x08, 0, 0}, {0x3805, 0xe3, 0, 0}, - {0x3806, 0x05, 0, 0}, {0x3807, 0xf1, 0, 0}, {0x3a09, 0x4b, 0, 0}, - {0x3a0a, 0x01, 0, 0}, {0x3a0b, 0x13, 0, 0}, {0x3a0d, 0x04, 0, 0}, - {0x3a0e, 0x03, 0, 0}, {0x4004, 0x04, 0, 0}, {0x4005, 0x18, 0, 0}, - {0x0100, 0x01, 0, 0}, -}; - -static struct reg_value ov5647_setting_15fps_QSXGA_2592_1944[] = { - {0x0100, 0x00, 0, 0}, {0x3820, 0x00, 0, 0}, {0x3821, 0x06, 0, 0}, - {0x3612, 0x5b, 0, 0}, {0x3618, 0x04, 0, 0}, {0x380c, 0x0b, 0, 0}, - {0x380d, 0x10, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb8, 0, 0}, - {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3709, 0x12, 0, 0}, - {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, {0x380a, 0x07, 0, 0}, - {0x380b, 0x98, 0, 0}, {0x3801, 0x0c, 0, 0}, {0x3802, 0x00, 0, 0}, - {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, {0x3805, 0x33, 0, 0}, - {0x3806, 0x07, 0, 0}, {0x3807, 0xa3, 0, 0}, {0x3a09, 0x28, 0, 0}, - {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0d, 0x08, 0, 0}, - {0x3a0e, 0x06, 0, 0}, {0x4004, 0x04, 0, 0}, {0x4005, 0x1a, 0, 0}, - {0x0100, 0x01, 0, 0}, -}; - -static struct ov5647_mode_info ov5647_mode_info_data[2][ov5647_mode_MAX + 1] = { - { - {ov5647_mode_VGA_640_480, -1, 0, 0, NULL, 0}, - {ov5647_mode_720P_1280_720, -1, 0, 0, NULL, 0}, - {ov5647_mode_1080P_1920_1080, -1, 0, 0, NULL, 0}, - {ov5647_mode_QSXGA_2592_1944, SCALING, 2592, 1944, - ov5647_setting_15fps_QSXGA_2592_1944, - ARRAY_SIZE(ov5647_setting_15fps_QSXGA_2592_1944)}, - }, - { - /* Actually VGA working in 60fps mode */ - {ov5647_mode_VGA_640_480, SUBSAMPLING, 640, 480, - ov5647_setting_60fps_VGA_640_480, - ARRAY_SIZE(ov5647_setting_60fps_VGA_640_480)}, - {ov5647_mode_720P_1280_720, SUBSAMPLING, 1280, 720, - ov5647_setting_30fps_720P_1280_720, - ARRAY_SIZE(ov5647_setting_30fps_720P_1280_720)}, - {ov5647_mode_1080P_1920_1080, SCALING, 1920, 1080, - ov5647_setting_30fps_1080P_1920_1080, - ARRAY_SIZE(ov5647_setting_30fps_1080P_1920_1080)}, - {ov5647_mode_QSXGA_2592_1944, -1, 0, 0, NULL, 0}, - }, -}; - -static struct regulator *io_regulator; -static struct regulator *core_regulator; -static struct regulator *analog_regulator; -static struct regulator *gpo_regulator; - -static int ov5647_probe(struct i2c_client *adapter, - const struct i2c_device_id *device_id); -static int ov5647_remove(struct i2c_client *client); - -static s32 ov5647_read_reg(u16 reg, u8 *val); -static s32 ov5647_write_reg(u16 reg, u8 val); - -static const struct i2c_device_id ov5647_id[] = { - {"ov5647_mipi", 0}, - {}, -}; - -MODULE_DEVICE_TABLE(i2c, ov5647_id); - -static struct i2c_driver ov5647_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "ov5647_mipi", - }, - .probe = ov5647_probe, - .remove = ov5647_remove, - .id_table = ov5647_id, -}; - -static const struct ov5647_datafmt ov5647_colour_fmts[] = { - {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_JPEG}, -}; - -static struct ov5647 *to_ov5647(const struct i2c_client *client) -{ - return container_of(i2c_get_clientdata(client), struct ov5647, subdev); -} - -/* Find a data format by a pixel code in an array */ -static const struct ov5647_datafmt - *ov5647_find_datafmt(u32 code) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(ov5647_colour_fmts); i++) - if (ov5647_colour_fmts[i].code == code) - return ov5647_colour_fmts + i; - - return NULL; -} - -static inline void ov5647_power_down(int enable) -{ - if (pwn_gpio < 0) - return; - - /* 19x19 pwdn pin invert by mipi daughter card */ - if (!enable) - gpio_set_value_cansleep(pwn_gpio, 1); - else - gpio_set_value_cansleep(pwn_gpio, 0); - - msleep(2); -} - -static void ov5647_reset(void) -{ - if (rst_gpio < 0 || pwn_gpio < 0) - return; - - /* camera reset */ - gpio_set_value_cansleep(rst_gpio, 1); - - /* camera power dowmn */ - gpio_set_value_cansleep(pwn_gpio, 1); - msleep(5); - - gpio_set_value_cansleep(pwn_gpio, 0); - msleep(5); - - gpio_set_value_cansleep(rst_gpio, 0); - msleep(1); - - gpio_set_value_cansleep(rst_gpio, 1); - msleep(5); - - gpio_set_value_cansleep(pwn_gpio, 1); -} - -static int ov5647_regulator_enable(struct device *dev) -{ - int ret = 0; - - io_regulator = devm_regulator_get(dev, "DOVDD"); - if (!IS_ERR(io_regulator)) { - regulator_set_voltage(io_regulator, - OV5647_VOLTAGE_DIGITAL_IO, - OV5647_VOLTAGE_DIGITAL_IO); - ret = regulator_enable(io_regulator); - if (ret) { - pr_err("%s:io set voltage error\n", __func__); - return ret; - } else { - dev_dbg(dev, - "%s:io set voltage ok\n", __func__); - } - } else { - pr_err("%s: cannot get io voltage error\n", __func__); - io_regulator = NULL; - } - - core_regulator = devm_regulator_get(dev, "DVDD"); - if (!IS_ERR(core_regulator)) { - regulator_set_voltage(core_regulator, - OV5647_VOLTAGE_DIGITAL_CORE, - OV5647_VOLTAGE_DIGITAL_CORE); - ret = regulator_enable(core_regulator); - if (ret) { - pr_err("%s:core set voltage error\n", __func__); - return ret; - } else { - dev_dbg(dev, - "%s:core set voltage ok\n", __func__); - } - } else { - core_regulator = NULL; - pr_err("%s: cannot get core voltage error\n", __func__); - } - - analog_regulator = devm_regulator_get(dev, "AVDD"); - if (!IS_ERR(analog_regulator)) { - regulator_set_voltage(analog_regulator, - OV5647_VOLTAGE_ANALOG, - OV5647_VOLTAGE_ANALOG); - ret = regulator_enable(analog_regulator); - if (ret) { - pr_err("%s:analog set voltage error\n", - __func__); - return ret; - } else { - dev_dbg(dev, - "%s:analog set voltage ok\n", __func__); - } - } else { - analog_regulator = NULL; - pr_err("%s: cannot get analog voltage error\n", __func__); - } - - return ret; -} - -static s32 ov5647_write_reg(u16 reg, u8 val) -{ - u8 au8Buf[3] = {0}; - - au8Buf[0] = reg >> 8; - au8Buf[1] = reg & 0xff; - au8Buf[2] = val; - - if (i2c_master_send(ov5647_data.i2c_client, au8Buf, 3) < 0) { - pr_err("%s:write reg error:reg=%x,val=%x\n", - __func__, reg, val); - return -1; - } - - return 0; -} - -static s32 ov5647_read_reg(u16 reg, u8 *val) -{ - u8 au8RegBuf[2] = {0}; - u8 u8RdVal = 0; - - au8RegBuf[0] = reg >> 8; - au8RegBuf[1] = reg & 0xff; - - if (2 != i2c_master_send(ov5647_data.i2c_client, au8RegBuf, 2)) { - pr_err("%s:write reg error:reg=%x\n", - __func__, reg); - return -1; - } - - if (1 != i2c_master_recv(ov5647_data.i2c_client, &u8RdVal, 1)) { - pr_err("%s:read reg error:reg=%x,val=%x\n", - __func__, reg, u8RdVal); - return -1; - } - - *val = u8RdVal; - - return u8RdVal; -} - -/* index: index of otp group. (0, 1, 2) - * return: - * 0, group index is empty - * 1, group index has invalid data - * 2, group index has valid data */ -static int ov5647_check_otp(int index) -{ - int i; - int address; - u8 temp; - - /* read otp into buffer */ - ov5647_write_reg(0x3d21, 0x01); - msleep(20); - address = 0x3d05 + index * 9; - temp = ov5647_read_reg(address, &temp); - - /* disable otp read */ - ov5647_write_reg(0x3d21, 0x00); - - /* clear otp buffer */ - for (i = 0; i < 32; i++) - ov5647_write_reg(0x3d00 + i, 0x00); - - if (!temp) - return 0; - else if ((!(temp & 0x80)) && (temp & 0x7f)) - return 2; - else - return 1; -} - -/* index: index of otp group. (0, 1, 2) - * return: 0 */ -static int ov5647_read_otp(int index, struct otp_struct *otp_ptr) -{ - int i; - int address; - u8 temp; - - /* read otp into buffer */ - ov5647_write_reg(0x3d21, 0x01); - msleep(2); - address = 0x3d05 + index * 9; - temp = ov5647_read_reg(address, &temp); - (*otp_ptr).customer_id = temp & 0x7f; - - (*otp_ptr).module_integrator_id = ov5647_read_reg(address, &temp); - (*otp_ptr).lens_id = ov5647_read_reg(address + 1, &temp); - (*otp_ptr).rg_ratio = ov5647_read_reg(address + 2, &temp); - (*otp_ptr).bg_ratio = ov5647_read_reg(address + 3, &temp); - (*otp_ptr).user_data[0] = ov5647_read_reg(address + 4, &temp); - (*otp_ptr).user_data[1] = ov5647_read_reg(address + 5, &temp); - (*otp_ptr).user_data[2] = ov5647_read_reg(address + 6, &temp); - (*otp_ptr).light_rg = ov5647_read_reg(address + 7, &temp); - (*otp_ptr).light_bg = ov5647_read_reg(address + 8, &temp); - - /* disable otp read */ - ov5647_write_reg(0x3d21, 0x00); - - /* clear otp buffer */ - for (i = 0; i < 32; i++) - ov5647_write_reg(0x3d00 + i, 0x00); - - return 0; -} - -/* R_gain, sensor red gain of AWB, 0x400 =1 - * G_gain, sensor green gain of AWB, 0x400 =1 - * B_gain, sensor blue gain of AWB, 0x400 =1 - * return 0 */ -static int ov5647_update_awb_gain(int R_gain, int G_gain, int B_gain) -{ - if (R_gain > 0x400) { - ov5647_write_reg(0x5186, R_gain >> 8); - ov5647_write_reg(0x5187, R_gain & 0x00ff); - } - if (G_gain > 0x400) { - ov5647_write_reg(0x5188, G_gain >> 8); - ov5647_write_reg(0x5189, G_gain & 0x00ff); - } - if (B_gain > 0x400) { - ov5647_write_reg(0x518a, B_gain >> 8); - ov5647_write_reg(0x518b, B_gain & 0x00ff); - } - - return 0; -} - -/* call this function after OV5647 initialization - * return value: - * 0 update success - * 1 no OTP */ -static int ov5647_update_otp(void) -{ - struct otp_struct current_otp; - int i; - int otp_index; - int temp; - int R_gain, G_gain, B_gain, G_gain_R, G_gain_B; - int rg, bg; - - /* R/G and B/G of current camera module is read out from sensor OTP - * check first OTP with valid data */ - for (i = 0; i < 3; i++) { - temp = ov5647_check_otp(i); - if (temp == 2) { - otp_index = i; - break; - } - } - if (i == 3) { - /* no valid wb OTP data */ - printk(KERN_WARNING "No valid wb otp data\n"); - return 1; - } - - ov5647_read_otp(otp_index, ¤t_otp); - if (current_otp.light_rg == 0) - rg = current_otp.rg_ratio; - else - rg = current_otp.rg_ratio * (current_otp.light_rg + 128) / 256; - - if (current_otp.light_bg == 0) - bg = current_otp.bg_ratio; - else - bg = current_otp.bg_ratio * (current_otp.light_bg + 128) / 256; - - /* calculate G gain - * 0x400 = 1x gain */ - if (bg < BG_Ratio_Typical) { - if (rg < RG_Ratio_Typical) { - /* current_otp.bg_ratio < BG_Ratio_typical && - * current_otp.rg_ratio < RG_Ratio_typical */ - G_gain = 0x400; - B_gain = 0x400 * BG_Ratio_Typical / bg; - R_gain = 0x400 * RG_Ratio_Typical / rg; - } else { - /* current_otp.bg_ratio < BG_Ratio_typical && - * current_otp.rg_ratio >= RG_Ratio_typical */ - R_gain = 0x400; - G_gain = 0x400 * rg / RG_Ratio_Typical; - B_gain = G_gain * BG_Ratio_Typical / bg; - } - } else { - if (rg < RG_Ratio_Typical) { - /* current_otp.bg_ratio >= BG_Ratio_typical && - * current_otp.rg_ratio < RG_Ratio_typical */ - B_gain = 0x400; - G_gain = 0x400 * bg / BG_Ratio_Typical; - R_gain = G_gain * RG_Ratio_Typical / rg; - } else { - /* current_otp.bg_ratio >= BG_Ratio_typical && - * current_otp.rg_ratio >= RG_Ratio_typical */ - G_gain_B = 0x400 * bg / BG_Ratio_Typical; - G_gain_R = 0x400 * rg / RG_Ratio_Typical; - if (G_gain_B > G_gain_R) { - B_gain = 0x400; - G_gain = G_gain_B; - R_gain = G_gain * RG_Ratio_Typical / rg; - } else { - R_gain = 0x400; - G_gain = G_gain_R; - B_gain = G_gain * BG_Ratio_Typical / bg; - } - } - } - ov5647_update_awb_gain(R_gain, G_gain, B_gain); - return 0; -} - -static void ov5647_stream_on(void) -{ - ov5647_write_reg(0x4202, 0x00); -} - -static void ov5647_stream_off(void) -{ - ov5647_write_reg(0x4202, 0x0f); - /* both clock and data lane in LP00 */ - ov5647_write_reg(0x0100, 0x00); -} - -static int ov5647_get_sysclk(void) -{ - /* calculate sysclk */ - int xvclk = ov5647_data.mclk / 10000; - int sysclk, temp1, temp2; - int pre_div02x, div_cnt7b, sdiv0, pll_rdiv, bit_div2x, sclk_div, VCO; - int pre_div02x_map[] = {2, 2, 4, 6, 8, 3, 12, 5, 16, 2, 2, 2, 2, 2, 2, 2}; - int sdiv0_map[] = {16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; - int pll_rdiv_map[] = {1, 2}; - int bit_div2x_map[] = {2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 5, 2, 2, 2, 2, 2}; - int sclk_div_map[] = {1, 2, 4, 1}; - u8 temp; - - temp1 = ov5647_read_reg(0x3037, &temp); - temp2 = temp1 & 0x0f; - pre_div02x = pre_div02x_map[temp2]; - temp2 = (temp1 >> 4) & 0x01; - pll_rdiv = pll_rdiv_map[temp2]; - temp1 = ov5647_read_reg(0x3036, &temp); - - div_cnt7b = temp1; - - VCO = xvclk * 2 / pre_div02x * div_cnt7b; - temp1 = ov5647_read_reg(0x3035, &temp); - temp2 = temp1 >> 4; - sdiv0 = sdiv0_map[temp2]; - temp1 = ov5647_read_reg(0x3034, &temp); - temp2 = temp1 & 0x0f; - bit_div2x = bit_div2x_map[temp2]; - temp1 = ov5647_read_reg(0x3106, &temp); - temp2 = (temp1 >> 2) & 0x03; - sclk_div = sclk_div_map[temp2]; - sysclk = VCO * 2 / sdiv0 / pll_rdiv / bit_div2x / sclk_div; - return sysclk; -} - -static void ov5647_set_night_mode(void) -{ - /* read HTS from register settings */ - u8 mode; - - ov5647_read_reg(0x3a00, &mode); - mode &= 0xfb; - ov5647_write_reg(0x3a00, mode); -} - -static int ov5647_get_HTS(void) -{ - /* read HTS from register settings */ - int HTS; - u8 temp; - - HTS = ov5647_read_reg(0x380c, &temp); - HTS = (HTS << 8) + ov5647_read_reg(0x380d, &temp); - - return HTS; -} - -static int ov5647_soft_reset(void) -{ - /* soft reset ov5647 */ - - ov5647_write_reg(0x0103, 0x1); - msleep(5); - - return 0; -} - -static int ov5647_get_VTS(void) -{ - /* read VTS from register settings */ - int VTS; - u8 temp; - - /* total vertical size[15:8] high byte */ - VTS = ov5647_read_reg(0x380e, &temp); - - VTS = (VTS << 8) + ov5647_read_reg(0x380f, &temp); - - return VTS; -} - -static int ov5647_set_VTS(int VTS) -{ - /* write VTS to registers */ - int temp; - - temp = VTS & 0xff; - ov5647_write_reg(0x380f, temp); - - temp = VTS >> 8; - ov5647_write_reg(0x380e, temp); - - return 0; -} - -static int ov5647_get_shutter(void) -{ - /* read shutter, in number of line period */ - int shutter; - u8 temp; - - shutter = (ov5647_read_reg(0x03500, &temp) & 0x0f); - shutter = (shutter << 8) + ov5647_read_reg(0x3501, &temp); - shutter = (shutter << 4) + (ov5647_read_reg(0x3502, &temp)>>4); - - return shutter; -} - -static int ov5647_set_shutter(int shutter) -{ - /* write shutter, in number of line period */ - int temp; - - shutter = shutter & 0xffff; - - temp = shutter & 0x0f; - temp = temp << 4; - ov5647_write_reg(0x3502, temp); - - temp = shutter & 0xfff; - temp = temp >> 4; - ov5647_write_reg(0x3501, temp); - - temp = shutter >> 12; - ov5647_write_reg(0x3500, temp); - - return 0; -} - -static int ov5647_get_gain16(void) -{ - /* read gain, 16 = 1x */ - int gain16; - u8 temp; - - gain16 = ov5647_read_reg(0x350a, &temp) & 0x03; - gain16 = (gain16 << 8) + ov5647_read_reg(0x350b, &temp); - - return gain16; -} - -static int ov5647_set_gain16(int gain16) -{ - /* write gain, 16 = 1x */ - u8 temp; - gain16 = gain16 & 0x3ff; - - temp = gain16 & 0xff; - ov5647_write_reg(0x350b, temp); - - temp = gain16 >> 8; - ov5647_write_reg(0x350a, temp); - - return 0; -} - -static int ov5647_get_light_freq(void) -{ - /* get banding filter value */ - int temp, temp1, light_freq = 0; - u8 tmp; - - temp = ov5647_read_reg(0x3c01, &tmp); - - if (temp & 0x80) { - /* manual */ - temp1 = ov5647_read_reg(0x3c00, &tmp); - if (temp1 & 0x04) { - /* 50Hz */ - light_freq = 50; - } else { - /* 60Hz */ - light_freq = 60; - } - } else { - /* auto */ - temp1 = ov5647_read_reg(0x3c0c, &tmp); - if (temp1 & 0x01) { - /* 50Hz */ - light_freq = 50; - } else { - /* 60Hz */ - } - } - return light_freq; -} - -static void ov5647_set_bandingfilter(void) -{ - int prev_VTS; - int band_step60, max_band60, band_step50, max_band50; - - /* read preview PCLK */ - prev_sysclk = ov5647_get_sysclk(); - /* read preview HTS */ - prev_HTS = ov5647_get_HTS(); - - /* read preview VTS */ - prev_VTS = ov5647_get_VTS(); - - /* calculate banding filter */ - /* 60Hz */ - band_step60 = prev_sysclk * 100/prev_HTS * 100/120; - ov5647_write_reg(0x3a0a, (band_step60 >> 8)); - ov5647_write_reg(0x3a0b, (band_step60 & 0xff)); - - max_band60 = (int)((prev_VTS-4)/band_step60); - ov5647_write_reg(0x3a0d, max_band60); - - /* 50Hz */ - band_step50 = prev_sysclk * 100/prev_HTS; - ov5647_write_reg(0x3a08, (band_step50 >> 8)); - ov5647_write_reg(0x3a09, (band_step50 & 0xff)); - - max_band50 = (int)((prev_VTS-4)/band_step50); - ov5647_write_reg(0x3a0e, max_band50); -} - -static int ov5647_set_AE_target(int target) -{ - /* stable in high */ - int fast_high, fast_low; - AE_low = target * 23 / 25; /* 0.92 */ - AE_high = target * 27 / 25; /* 1.08 */ - - fast_high = AE_high<<1; - if (fast_high > 255) - fast_high = 255; - - fast_low = AE_low >> 1; - - ov5647_write_reg(0x3a0f, AE_high); - ov5647_write_reg(0x3a10, AE_low); - ov5647_write_reg(0x3a1b, AE_high); - ov5647_write_reg(0x3a1e, AE_low); - ov5647_write_reg(0x3a11, fast_high); - ov5647_write_reg(0x3a1f, fast_low); - - return 0; -} - -static void ov5647_turn_on_AE_AG(int enable) -{ - u8 ae_ag_ctrl; - - ov5647_read_reg(0x3503, &ae_ag_ctrl); - if (enable) { - /* turn on auto AE/AG */ - ae_ag_ctrl = ae_ag_ctrl & ~(0x03); - } else { - /* turn off AE/AG */ - ae_ag_ctrl = ae_ag_ctrl | 0x03; - } - ov5647_write_reg(0x3503, ae_ag_ctrl); -} - -static void ov5647_set_virtual_channel(int channel) -{ - u8 channel_id; - - ov5647_read_reg(0x4814, &channel_id); - channel_id &= ~(3 << 6); - ov5647_write_reg(0x4814, channel_id | (channel << 6)); -} - -/* download ov5647 settings to sensor through i2c */ -static int ov5647_download_firmware(struct reg_value *pModeSetting, s32 ArySize) -{ - register u32 Delay_ms = 0; - register u16 RegAddr = 0; - register u8 Mask = 0; - register u8 Val = 0; - u8 RegVal = 0; - int i, retval = 0; - - for (i = 0; i < ArySize; ++i, ++pModeSetting) { - Delay_ms = pModeSetting->u32Delay_ms; - RegAddr = pModeSetting->u16RegAddr; - Val = pModeSetting->u8Val; - Mask = pModeSetting->u8Mask; - - if (Mask) { - retval = ov5647_read_reg(RegAddr, &RegVal); - if (retval < 0) - goto err; - - RegVal &= ~(u8)Mask; - Val &= Mask; - Val |= RegVal; - } - - retval = ov5647_write_reg(RegAddr, Val); - if (retval < 0) - goto err; - - if (Delay_ms) - msleep(Delay_ms); - } -err: - return retval; -} - -/* sensor changes between scaling and subsampling - * go through exposure calcualtion - */ -static int ov5647_change_mode_exposure_calc(enum ov5647_frame_rate frame_rate, - enum ov5647_mode mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int pre_shutter, pre_gain16; - int cap_shutter, cap_gain16; - int pre_sysclk, pre_HTS; - int cap_sysclk, cap_HTS, cap_VTS; - long cap_gain16_shutter; - int retval = 0; - - /* check if the input mode and frame rate is valid */ - pModeSetting = - ov5647_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5647_mode_info_data[frame_rate][mode].init_data_size; - - ov5647_data.pix.width = - ov5647_mode_info_data[frame_rate][mode].width; - ov5647_data.pix.height = - ov5647_mode_info_data[frame_rate][mode].height; - - if (ov5647_data.pix.width == 0 || ov5647_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - ov5647_stream_off(); - - /* turn off night mode for capture */ - ov5647_set_night_mode(); - - pre_shutter = ov5647_get_shutter(); - pre_gain16 = ov5647_get_gain16(); - pre_HTS = ov5647_get_HTS(); - pre_sysclk = ov5647_get_sysclk(); - - /* Write capture setting */ - retval = ov5647_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - /* read capture VTS */ - cap_VTS = ov5647_get_VTS(); - cap_HTS = ov5647_get_HTS(); - cap_sysclk = ov5647_get_sysclk(); - - /* calculate capture shutter/gain16 */ - cap_shutter = pre_shutter * cap_sysclk/pre_sysclk * pre_HTS / cap_HTS; - - if (cap_shutter < 16) { - cap_gain16_shutter = pre_shutter * pre_gain16 * - cap_sysclk / pre_sysclk * pre_HTS / cap_HTS; - cap_shutter = ((int)(cap_gain16_shutter / 16)); - if (cap_shutter < 1) - cap_shutter = 1; - cap_gain16 = ((int)(cap_gain16_shutter / cap_shutter)); - if (cap_gain16 < 16) - cap_gain16 = 16; - } else - cap_gain16 = pre_gain16; - - /* gain to shutter */ - while ((cap_gain16 > 32) && - (cap_shutter < ((int)((cap_VTS - 4) / 2)))) { - cap_gain16 = cap_gain16 / 2; - cap_shutter = cap_shutter * 2; - } - /* write capture gain */ - ov5647_set_gain16(cap_gain16); - - /* write capture shutter */ - if (cap_shutter > (cap_VTS - 4)) { - cap_VTS = cap_shutter + 4; - ov5647_set_VTS(cap_VTS); - } - ov5647_set_shutter(cap_shutter); - -err: - return retval; -} - -/* if sensor changes inside scaling or subsampling - * change mode directly - * */ -static int ov5647_change_mode_direct(enum ov5647_frame_rate frame_rate, - enum ov5647_mode mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - - /* check if the input mode and frame rate is valid */ - pModeSetting = - ov5647_mode_info_data[frame_rate][mode].init_data_ptr; - ArySize = - ov5647_mode_info_data[frame_rate][mode].init_data_size; - - ov5647_data.pix.width = - ov5647_mode_info_data[frame_rate][mode].width; - ov5647_data.pix.height = - ov5647_mode_info_data[frame_rate][mode].height; - - if (ov5647_data.pix.width == 0 || ov5647_data.pix.height == 0 || - pModeSetting == NULL || ArySize == 0) - return -EINVAL; - - /* turn off AE/AG */ - ov5647_turn_on_AE_AG(0); - - ov5647_stream_off(); - - /* Write capture setting */ - retval = ov5647_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - - ov5647_turn_on_AE_AG(1); - -err: - return retval; -} - -static int ov5647_init_mode(enum ov5647_frame_rate frame_rate, - enum ov5647_mode mode, enum ov5647_mode orig_mode) -{ - struct reg_value *pModeSetting = NULL; - s32 ArySize = 0; - int retval = 0; - u32 msec_wait4stable = 0; - enum ov5647_downsize_mode dn_mode, orig_dn_mode; - - if ((mode > ov5647_mode_MAX || mode < ov5647_mode_MIN) - && (mode != ov5647_mode_INIT)) { - pr_err("Wrong ov5647 mode detected!\n"); - return -1; - } - - dn_mode = ov5647_mode_info_data[frame_rate][mode].dn_mode; - orig_dn_mode = ov5647_mode_info_data[frame_rate][orig_mode].dn_mode; - if (mode == ov5647_mode_INIT) { - ov5647_soft_reset(); - pModeSetting = ov5647_init_setting; - ArySize = ARRAY_SIZE(ov5647_init_setting); - retval = ov5647_download_firmware(pModeSetting, ArySize); - if (retval < 0) - goto err; - pModeSetting = ov5647_setting_60f