Merge changes I34a35fe2,Ia3893fbd into msm-3.0

* changes:
  defconfig: 9615: include support for gpio-regulator
  msm: board-9615: add gpio-regulator wrapper around GPIO 18
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index 786f4fa..dbf3427 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -277,7 +277,8 @@
 	if (gic_arch_extn.irq_retrigger)
 		return gic_arch_extn.irq_retrigger(d);
 
-	return -ENXIO;
+	/* the retrigger expects 0 for failure */
+	return 0;
 }
 
 #ifdef CONFIG_SMP
diff --git a/arch/arm/kernel/perf_event_msm.c b/arch/arm/kernel/perf_event_msm.c
index ae8bfcb..fb53650 100644
--- a/arch/arm/kernel/perf_event_msm.c
+++ b/arch/arm/kernel/perf_event_msm.c
@@ -16,6 +16,11 @@
 #include "../vfp/vfpinstr.h"
 
 #ifdef CONFIG_CPU_V7
+#define SCORPION_EVT_PREFIX 1
+#define SCORPION_MAX_L1_REG 4
+
+static u32 scorpion_evt_type_base[] = {0x4c, 0x50, 0x54, 0x58, 0x5c};
+
 enum scorpion_perf_common {
 	SCORPION_EVT_START_IDX			= 0x4c,
 	SCORPION_ICACHE_EXPL_INV		= 0x4c,
@@ -356,6 +361,25 @@
 					struct scorpion_evt *evtinfo)
 {
 	u32 idx;
+	u8 prefix;
+	u8 reg;
+	u8 code;
+	u8 group;
+
+	prefix = (scorpion_evt_type & 0xF0000) >> 16;
+	if (prefix == SCORPION_EVT_PREFIX) {
+		reg   = (scorpion_evt_type & 0x0F000) >> 12;
+		code  = (scorpion_evt_type & 0x00FF0) >> 4;
+		group =  scorpion_evt_type & 0x0000F;
+
+		if ((group > 3) || (reg > SCORPION_MAX_L1_REG))
+			return -EINVAL;
+
+		evtinfo->group_setval = 0x80000000 | (code << (group * 8));
+		evtinfo->groupcode = reg;
+		evtinfo->armv7_evt_type = scorpion_evt_type_base[reg] | group;
+		return evtinfo->armv7_evt_type;
+	}
 
 	if (scorpion_evt_type < SCORPION_EVT_START_IDX || scorpion_evt_type >=
 		(ARRAY_SIZE(scorpion_event) + SCORPION_EVT_START_IDX))
@@ -561,7 +585,6 @@
 	 */
 	if (idx != ARMV7_CYCLE_COUNTER) {
 		val = hwc->config_base;
-		val &= ARMV7_EVTSEL_MASK;
 		if (val > 0x40) {
 			event = get_scorpion_evtinfo(val, &evtinfo);
 			if (event == -EINVAL)
@@ -601,7 +624,6 @@
 	 */
 	if (idx != ARMV7_CYCLE_COUNTER) {
 		val = hwc->config_base;
-		val &= ARMV7_EVTSEL_MASK;
 		if (val < 0x40) {
 			armv7_pmnc_write_evtsel(idx, hwc->config_base);
 		} else {
@@ -670,7 +692,7 @@
 	.disable		= scorpion_pmu_disable_event,
 	.read_counter		= armv7pmu_read_counter,
 	.write_counter		= armv7pmu_write_counter,
-	.raw_event_mask		= 0xFF,
+	.raw_event_mask		= 0xFFFFF,
 	.get_event_idx		= armv7pmu_get_event_idx,
 	.start			= armv7pmu_start,
 	.stop			= armv7pmu_stop,
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index d5f727d..756603e 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -134,7 +134,38 @@
 	select MSM_SPM_V2
 	select MSM_L2_SPM
 	select MSM_NATIVE_RESTART
-        select DONT_MAP_HOLE_AFTER_MEMBANK0
+	select DONT_MAP_HOLE_AFTER_MEMBANK0
+	select MSM_REMOTE_SPINLOCK_SFPB
+	select ARCH_POPULATES_NODE_MAP
+	select ARCH_SPARSEMEM_ENABLE
+	select ARCH_HAS_HOLES_MEMORYMODEL
+	select MEMORY_HOTPLUG
+	select MEMORY_HOTREMOVE
+	select MIGRATION
+	select ARCH_MEMORY_PROBE
+	select ARCH_MEMORY_REMOVE
+	select DONT_RESERVE_FROM_MOVABLE_ZONE
+
+config ARCH_MSM8930
+	bool "MSM8930"
+	select ARCH_MSM_KRAITMP
+	select ARM_GIC
+	select CPU_V7
+	select MSM_V2_TLMM
+	select MSM_GPIOMUX
+	select MSM_SCM if SMP
+	select MSM_DIRECT_SCLK_ACCESS
+	select REGULATOR
+	select MSM_RPM
+	select MSM_XO
+	select MSM_QDSP6_APR
+	select MSM_PIL
+	select MSM_AUDIO_QDSP6 if SND_SOC
+	select CPU_HAS_L2_PMU
+	select MSM_SPM_V2
+	select MSM_L2_SPM
+	select MSM_NATIVE_RESTART
+	select DONT_MAP_HOLE_AFTER_MEMBANK0
 	select MSM_REMOTE_SPINLOCK_SFPB
 	select ARCH_POPULATES_NODE_MAP
 	select ARCH_SPARSEMEM_ENABLE
@@ -551,6 +582,24 @@
 	help
 	  Support for the Qualcomm MSM8960 LIQUID device.
 
+config MACH_MSM8930_CDP
+	depends on ARCH_MSM8930
+	bool "MSM8930 CDP"
+	help
+	  Support for the Qualcomm MSM8930 CDP device.
+
+config MACH_MSM8930_MTP
+	depends on ARCH_MSM8930
+	bool "MSM8930 MTP"
+	help
+	  Support for the Qualcomm MSM8930 MTP device.
+
+config MACH_MSM8930_FLUID
+	depends on ARCH_MSM8930
+	bool "MSM8930 FLUID"
+	help
+	  Support for the Qualcomm MSM8930 FLUID device.
+
 config MACH_MSM9615_CDP
 	depends on ARCH_MSM9615
 	bool "MSM9615 CDP"
@@ -608,6 +657,7 @@
 	default "0x40800000" if ARCH_MSM9615
 	default "0x80200000" if ARCH_APQ8064
 	default "0x80200000" if ARCH_MSM8960
+	default "0x80200000" if ARCH_MSM8930
 	default "0x80200000" if ARCH_MSMCOPPER
 	default "0x10000000" if ARCH_FSM9XXX
 	default "0x00200000" if !MSM_STACKED_MEMORY
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 3419f164..8693875 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -73,7 +73,7 @@
 obj-$(CONFIG_MSM_BAM_DMUX) += bam_dmux.o
 obj-$(CONFIG_MSM_SMD_LOGGING) += smem_log.o
 obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o remote_spinlock.o
-        obj-y += socinfo.o
+obj-y += socinfo.o
 ifndef CONFIG_ARCH_MSM9615
 ifndef CONFIG_ARCH_APQ8064
 ifndef CONFIG_ARCH_MSM8960
@@ -222,6 +222,9 @@
 obj-$(CONFIG_MACH_MSM8960_CDP) += board-msm8960.o devices-8960.o board-msm8960-regulator.o
 obj-$(CONFIG_MACH_MSM8960_MTP) += board-msm8960.o devices-8960.o board-msm8960-regulator.o
 obj-$(CONFIG_MACH_MSM8960_FLUID) += board-msm8960.o devices-8960.o board-msm8960-regulator.o
+obj-$(CONFIG_MACH_MSM8930_CDP) += board-msm8960.o devices-8960.o board-msm8960-regulator.o
+obj-$(CONFIG_MACH_MSM8930_MTP) += board-msm8960.o devices-8960.o board-msm8960-regulator.o
+obj-$(CONFIG_MACH_MSM8930_FLUID) += board-msm8960.o devices-8960.o board-msm8960-regulator.o
 obj-$(CONFIG_ARCH_MSM8960) += bms-batterydata.o
 obj-$(CONFIG_ARCH_APQ8064) += board-apq8064.o devices-8064.o board-apq8064-regulator.o
 obj-$(CONFIG_ARCH_MSM9615) += board-9615.o devices-9615.o board-9615-regulator.o
diff --git a/arch/arm/mach-msm/Makefile.boot b/arch/arm/mach-msm/Makefile.boot
index 24a3e49..bc15a01 100644
--- a/arch/arm/mach-msm/Makefile.boot
+++ b/arch/arm/mach-msm/Makefile.boot
@@ -35,6 +35,9 @@
 # MSM8960
    zreladdr-$(CONFIG_ARCH_MSM8960)	:= 0x80208000
 
+# MSM8930
+   zreladdr-$(CONFIG_ARCH_MSM8930)	:= 0x80208000
+
 # APQ8064
    zreladdr-$(CONFIG_ARCH_APQ8064)	:= 0x80208000
 
diff --git a/arch/arm/mach-msm/acpuclock-8960.c b/arch/arm/mach-msm/acpuclock-8960.c
index 8d5e84b..93629d1 100644
--- a/arch/arm/mach-msm/acpuclock-8960.c
+++ b/arch/arm/mach-msm/acpuclock-8960.c
@@ -545,7 +545,7 @@
 			unsigned int vdd_dig, enum setrate_reason reason)
 {
 	struct scalable *sc = &scalable[cpu];
-	int rc;
+	int rc = 0;
 
 	/*
 	 * Increase vdd_mem active-set before vdd_dig.
diff --git a/arch/arm/mach-msm/board-msm8960.c b/arch/arm/mach-msm/board-msm8960.c
index b94a5cb..2262ba3 100644
--- a/arch/arm/mach-msm/board-msm8960.c
+++ b/arch/arm/mach-msm/board-msm8960.c
@@ -3111,8 +3111,7 @@
 	}
 
 	dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
-	strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
-	dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
+	strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
 out:
 	iounmap(dload);
 	return 0;
diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c
index 7fc06bd..ca91931 100644
--- a/arch/arm/mach-msm/board-msm8x60.c
+++ b/arch/arm/mach-msm/board-msm8x60.c
@@ -2210,6 +2210,10 @@
 #endif
 
 #ifdef CONFIG_IMX074
+static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
+	.mount_angle = 180
+};
+
 static struct msm_camera_sensor_flash_data flash_imx074 = {
 	.flash_type		= MSM_CAMERA_FLASH_LED,
 	.flash_src		= &msm_flash_src
@@ -2226,7 +2230,7 @@
 	.num_resources		= ARRAY_SIZE(msm_camera_resources),
 	.flash_data		= &flash_imx074,
 	.strobe_flash_data	= &strobe_flash_xenon,
-	.sensor_platform_info = &sensor_board_info,
+	.sensor_platform_info = &imx074_sensor_board_info,
 	.csi_if			= 1
 };
 struct platform_device msm_camera_sensor_imx074 = {
@@ -2809,21 +2813,21 @@
 	.name = "pmem_smi",
 };
 
-void pmem_request_smi_region(void *data)
+void request_smi_region(void *data)
 {
 	int bus_id = (int) data;
 
 	msm_bus_scale_client_update_request(bus_id, 1);
 }
 
-void pmem_release_smi_region(void *data)
+void release_smi_region(void *data)
 {
 	int bus_id = (int) data;
 
 	msm_bus_scale_client_update_request(bus_id, 0);
 }
 
-void *pmem_setup_smi_region(void)
+void *setup_smi_region(void)
 {
 	return (void *)msm_bus_scale_register_client(&smi_client_pdata);
 }
@@ -2832,9 +2836,9 @@
 	.allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
 	.cached = 0,
 	.memory_type = MEMTYPE_SMI,
-	.request_region = pmem_request_smi_region,
-	.release_region = pmem_release_smi_region,
-	.setup_region = pmem_setup_smi_region,
+	.request_region = request_smi_region,
+	.release_region = release_smi_region,
+	.setup_region = setup_smi_region,
 	.map_on_demand = 1,
 };
 static struct platform_device android_pmem_smipool_device = {
diff --git a/arch/arm/mach-msm/board-qrd7627a.c b/arch/arm/mach-msm/board-qrd7627a.c
index 5c11af3..e46da5b 100644
--- a/arch/arm/mach-msm/board-qrd7627a.c
+++ b/arch/arm/mach-msm/board-qrd7627a.c
@@ -64,10 +64,13 @@
 	GPIO_BT_SYS_REST_EN	= 114,
 	GPIO_WAKE_ON_WIRELESS,
 	GPIO_BACKLIGHT_EN,
-	GPIO_CAM_3MP_PWDN,
+	GPIO_NC,
+	GPIO_CAM_3MP_PWDN,	/* CAM_VGA */
 	GPIO_WLAN_EN,
 	GPIO_CAM_5MP_SHDN_EN,
 	GPIO_CAM_5MP_RESET,
+	GPIO_TP,
+	GPIO_CAM_GP_CAMIF_RESET,
 };
 
 	/* FM Platform power and shutdown routines */
@@ -1872,6 +1875,334 @@
 	.dev.platform_data  = &msm_psy_batt_data,
 };
 
+#ifdef CONFIG_MSM_CAMERA
+static uint32_t camera_off_gpio_table[] = {
+	GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
+};
+
+static uint32_t camera_on_gpio_table[] = {
+	GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
+};
+
+static void qrd1_camera_gpio_cfg(void)
+{
+
+	int rc = 0;
+
+	rc = gpio_request(GPIO_CAM_5MP_SHDN_EN, "ov5640");
+	if (rc < 0)
+		pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
+				__func__);
+
+
+	rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_SHDN_EN, 0,
+				GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
+				GPIO_CFG_2MA), GPIO_CFG_ENABLE);
+	if (rc < 0) {
+		pr_err("%s: unable to enable Power Down gpio for main"
+				"camera!\n", __func__);
+		gpio_free(GPIO_CAM_5MP_SHDN_EN);
+	}
+
+
+	rc = gpio_request(GPIO_CAM_5MP_RESET, "ov5640");
+	if (rc < 0) {
+		pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
+				__func__);
+		gpio_free(GPIO_CAM_5MP_SHDN_EN);
+	}
+
+
+	rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_RESET, 0,
+				GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
+				GPIO_CFG_2MA), GPIO_CFG_ENABLE);
+	if (rc < 0) {
+		pr_err("%s: unable to enable reset gpio for main camera!\n",
+				__func__);
+		gpio_free(GPIO_CAM_5MP_RESET);
+	}
+
+	rc = gpio_request(GPIO_CAM_3MP_PWDN, "ov7692");
+	if (rc < 0)
+		pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
+				__func__);
+
+	rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_3MP_PWDN, 0,
+				GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
+				GPIO_CFG_2MA), GPIO_CFG_ENABLE);
+	if (rc < 0) {
+		pr_err("%s: unable to enable Power Down gpio for front"
+				"camera!\n", __func__);
+		gpio_free(GPIO_CAM_3MP_PWDN);
+	}
+
+	gpio_direction_output(GPIO_CAM_5MP_SHDN_EN, 1);
+	gpio_direction_output(GPIO_CAM_5MP_RESET, 1);
+	gpio_direction_output(GPIO_CAM_3MP_PWDN, 1);
+}
+
+#endif
+static struct vreg *vreg_gp1;
+static struct vreg *vreg_gp2;
+static struct vreg *vreg_gp3;
+static void msm_camera_vreg_config(int vreg_en)
+{
+	int rc;
+
+	if (vreg_gp1 == NULL) {
+		vreg_gp1 = vreg_get(NULL, "msme1");
+		if (IS_ERR(vreg_gp1)) {
+			pr_err("%s: vreg_get(%s) failed (%ld)\n",
+				__func__, "msme1", PTR_ERR(vreg_gp1));
+			return;
+		}
+
+		rc = vreg_set_level(vreg_gp1, 1800);
+		if (rc) {
+			pr_err("%s: GP1 set_level failed (%d)\n",
+				__func__, rc);
+			return;
+		}
+	}
+
+	if (vreg_gp2 == NULL) {
+		vreg_gp2 = vreg_get(NULL, "gp2");
+		if (IS_ERR(vreg_gp2)) {
+			pr_err("%s: vreg_get(%s) failed (%ld)\n",
+				__func__, "gp2", PTR_ERR(vreg_gp2));
+			return;
+		}
+
+		rc = vreg_set_level(vreg_gp2, 2850);
+		if (rc) {
+			pr_err("%s: GP2 set_level failed (%d)\n",
+				__func__, rc);
+		}
+	}
+
+	if (vreg_gp3 == NULL) {
+		vreg_gp3 = vreg_get(NULL, "usb2");
+		if (IS_ERR(vreg_gp3)) {
+			pr_err("%s: vreg_get(%s) failed (%ld)\n",
+				__func__, "gp3", PTR_ERR(vreg_gp3));
+			return;
+		}
+
+		rc = vreg_set_level(vreg_gp3, 1800);
+		if (rc) {
+			pr_err("%s: GP3 set level failed (%d)\n",
+				__func__, rc);
+		}
+	}
+
+	if (vreg_en) {
+		rc = vreg_enable(vreg_gp1);
+		if (rc) {
+			pr_err("%s: GP1 enable failed (%d)\n",
+				__func__, rc);
+			return;
+		}
+
+		rc = vreg_enable(vreg_gp2);
+		if (rc) {
+			pr_err("%s: GP2 enable failed (%d)\n",
+				__func__, rc);
+		}
+
+		rc = vreg_enable(vreg_gp3);
+		if (rc) {
+			pr_err("%s: GP3 enable failed (%d)\n",
+				__func__, rc);
+		}
+	} else {
+		rc = vreg_disable(vreg_gp1);
+		if (rc)
+			pr_err("%s: GP1 disable failed (%d)\n",
+				__func__, rc);
+
+		rc = vreg_disable(vreg_gp2);
+		if (rc) {
+			pr_err("%s: GP2 disable failed (%d)\n",
+				__func__, rc);
+		}
+
+		rc = vreg_disable(vreg_gp3);
+		if (rc) {
+			pr_err("%s: GP3 disable failed (%d)\n",
+				__func__, rc);
+		}
+	}
+}
+
+static int config_gpio_table(uint32_t *table, int len)
+{
+	int rc = 0, i = 0;
+
+	for (i = 0; i < len; i++) {
+		rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
+		if (rc) {
+			pr_err("%s not able to get gpio\n", __func__);
+			for (i--; i >= 0; i--)
+				gpio_tlmm_config(camera_off_gpio_table[i],
+							GPIO_CFG_ENABLE);
+			break;
+		}
+	}
+	return rc;
+}
+
+static int config_camera_on_gpios_rear(void)
+{
+	int rc = 0;
+
+	msm_camera_vreg_config(1);
+
+	rc = config_gpio_table(camera_on_gpio_table,
+			ARRAY_SIZE(camera_on_gpio_table));
+	if (rc < 0) {
+		pr_err("%s: CAMSENSOR gpio table request"
+		"failed\n", __func__);
+		return rc;
+	}
+
+	return rc;
+}
+
+static void config_camera_off_gpios_rear(void)
+{
+	msm_camera_vreg_config(0);
+	config_gpio_table(camera_off_gpio_table,
+			ARRAY_SIZE(camera_off_gpio_table));
+}
+
+static int config_camera_on_gpios_front(void)
+{
+	int rc = 0;
+
+	msm_camera_vreg_config(1);
+
+	rc = config_gpio_table(camera_on_gpio_table,
+			ARRAY_SIZE(camera_on_gpio_table));
+	if (rc < 0) {
+		pr_err("%s: CAMSENSOR gpio table request"
+			"failed\n", __func__);
+		return rc;
+	}
+
+	return rc;
+}
+
+static void config_camera_off_gpios_front(void)
+{
+	msm_camera_vreg_config(0);
+
+	config_gpio_table(camera_off_gpio_table,
+			ARRAY_SIZE(camera_off_gpio_table));
+}
+
+struct msm_camera_device_platform_data msm_camera_data_rear = {
+	.camera_gpio_on		= config_camera_on_gpios_rear,
+	.camera_gpio_off	= config_camera_off_gpios_rear,
+	.ioext.csiphy		= 0xA1000000,
+	.ioext.csisz		= 0x00100000,
+	.ioext.csiirq		= INT_CSI_IRQ_1,
+	.ioclk.mclk_clk_rate	= 24000000,
+	.ioclk.vfe_clk_rate	= 192000000,
+	.ioext.appphy		= MSM_CLK_CTL_PHYS,
+	.ioext.appsz		= MSM_CLK_CTL_SIZE,
+};
+
+struct msm_camera_device_platform_data msm_camera_data_front = {
+	.camera_gpio_on		= config_camera_on_gpios_front,
+	.camera_gpio_off	= config_camera_off_gpios_front,
+	.ioext.csiphy		= 0xA0F00000,
+	.ioext.csisz		= 0x00100000,
+	.ioext.csiirq		= INT_CSI_IRQ_0,
+	.ioclk.mclk_clk_rate	= 24000000,
+	.ioclk.vfe_clk_rate	= 192000000,
+	.ioext.appphy		= MSM_CLK_CTL_PHYS,
+	.ioext.appsz		= MSM_CLK_CTL_SIZE,
+};
+
+#ifdef CONFIG_OV5640
+static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
+	.mount_angle	= 90
+};
+
+static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
+	.flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
+	._fsrc.led_src.led_name = "flashlight",
+	._fsrc.led_src.led_name_len = 10,
+};
+
+static struct msm_camera_sensor_flash_data flash_ov5640 = {
+	.flash_type	= MSM_CAMERA_FLASH_LED,
+	.flash_src	= &msm_flash_src_ov5640,
+};
+
+static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
+	.sensor_name		= "ov5640",
+	.sensor_reset_enable	= 1,
+	.sensor_reset		= GPIO_CAM_5MP_RESET,
+	.sensor_pwd		= GPIO_CAM_5MP_SHDN_EN,
+	.vcm_pwd		= 0,
+	.vcm_enable		= 0,
+	.pdata			= &msm_camera_data_rear,
+	.flash_data		= &flash_ov5640,
+	.sensor_platform_info	= &ov5640_sensor_info,
+	.csi_if			= 1,
+};
+
+static struct platform_device msm_camera_sensor_ov5640 = {
+	.name	= "msm_camera_ov5640",
+	.dev	= {
+		.platform_data = &msm_camera_sensor_ov5640_data,
+	},
+};
+#endif
+
+#ifdef CONFIG_WEBCAM_OV7692_QRD
+static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
+	.mount_angle = 90
+};
+
+static struct msm_camera_sensor_flash_data flash_ov7692 = {
+	.flash_type	= MSM_CAMERA_FLASH_NONE,
+};
+
+static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
+	.sensor_name		= "ov7692",
+	.sensor_reset_enable	= 0,
+	.sensor_reset		= 0,
+	.sensor_pwd		= GPIO_CAM_3MP_PWDN,
+	.vcm_pwd		= 0,
+	.vcm_enable		= 0,
+	.pdata			= &msm_camera_data_front,
+	.flash_data		= &flash_ov7692,
+	.sensor_platform_info   = &ov7692_sensor_7627a_info,
+	.csi_if			= 1,
+};
+
+static struct platform_device msm_camera_sensor_ov7692 = {
+	.name	= "msm_camera_ov7692",
+	.dev	= {
+		.platform_data = &msm_camera_sensor_ov7692_data,
+	},
+};
+#endif
+
+static struct i2c_board_info i2c_camera_devices[] = {
+	#ifdef CONFIG_OV5640
+	{
+		I2C_BOARD_INFO("ov5640", 0x78 >> 1),
+	},
+	#endif
+	#ifdef CONFIG_WEBCAM_OV7692_QRD
+	{
+		I2C_BOARD_INFO("ov7692", 0x78),
+	},
+	#endif
+};
 static struct platform_device *qrd1_devices[] __initdata = {
 	&msm_device_dmov,
 	&msm_device_smd,
@@ -1889,6 +2220,12 @@
 	&msm_device_snd,
 	&msm_device_adspdec,
 	&msm_batt_device,
+#ifdef CONFIG_OV5640
+	&msm_camera_sensor_ov5640,
+#endif
+#ifdef CONFIG_WEBCAM_OV7692_QRD
+	&msm_camera_sensor_ov7692,
+#endif
 	&msm_kgsl_3d0,
 #ifdef CONFIG_BT
 	&msm_bt_power_device,
@@ -2166,6 +2503,7 @@
 	msm_device_i2c_init();
 	msm7627a_init_mmc();
 
+	qrd1_camera_gpio_cfg();
 #ifdef CONFIG_SERIAL_MSM_HS
 	msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
 	msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
@@ -2177,9 +2515,9 @@
 	msm_device_otg.dev.platform_data = &msm_otg_pdata;
 #endif
 	msm_device_gadget_peripheral.dev.platform_data =
-						&msm_gadget_pdata;
+		&msm_gadget_pdata;
 	platform_add_devices(qrd1_devices,
-				ARRAY_SIZE(qrd1_devices));
+			ARRAY_SIZE(qrd1_devices));
 #ifdef CONFIG_USB_EHCI_MSM_72K
 	msm7627a_init_host();
 #endif
@@ -2189,18 +2527,20 @@
 
 #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
 	i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
-				bahama_devices,
-				ARRAY_SIZE(bahama_devices));
+			bahama_devices,
+			ARRAY_SIZE(bahama_devices));
 	bt_power_init();
 #endif
 
+	i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, i2c_camera_devices,
+			ARRAY_SIZE(i2c_camera_devices));
+
 #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
 	defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
 	i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
 				synaptic_i2c_clearpad3k,
 				ARRAY_SIZE(synaptic_i2c_clearpad3k));
 #endif
-
 	platform_device_register(&hs_pdev);
 
 #ifdef CONFIG_MSM_RPC_VIBRATOR
diff --git a/arch/arm/mach-msm/clock-pcom-lookup.c b/arch/arm/mach-msm/clock-pcom-lookup.c
index b176301..d1a257d 100644
--- a/arch/arm/mach-msm/clock-pcom-lookup.c
+++ b/arch/arm/mach-msm/clock-pcom-lookup.c
@@ -263,6 +263,9 @@
 	CLK_LOOKUP("csi_clk",		csi0_clk.c,	"msm_camera_ov9726.0"),
 	CLK_LOOKUP("csi_pclk",		csi0_p_clk.c,	"msm_camera_ov9726.0"),
 	CLK_LOOKUP("csi_vfe_clk",	csi0_vfe_clk.c,	"msm_camera_ov9726.0"),
+	CLK_LOOKUP("csi_clk",		csi0_clk.c,	"msm_camera_ov7692.0"),
+	CLK_LOOKUP("csi_pclk",		csi0_p_clk.c,	"msm_camera_ov7692.0"),
+	CLK_LOOKUP("csi_vfe_clk",	csi0_vfe_clk.c,	"msm_camera_ov7692.0"),
 	CLK_LOOKUP("csi_clk",		csi1_clk.c,	NULL),
 	CLK_LOOKUP("csi_pclk",		csi1_p_clk.c,	NULL),
 	CLK_LOOKUP("csi_vfe_clk",	csi1_vfe_clk.c,	NULL),
diff --git a/arch/arm/mach-msm/clock-voter.c b/arch/arm/mach-msm/clock-voter.c
index 1c742b1..e754752 100644
--- a/arch/arm/mach-msm/clock-voter.c
+++ b/arch/arm/mach-msm/clock-voter.c
@@ -75,7 +75,7 @@
 
 static int voter_clk_enable(struct clk *clk)
 {
-	int ret;
+	int ret = 0;
 	unsigned long flags;
 	unsigned cur_rate;
 	struct clk *parent;
diff --git a/arch/arm/mach-msm/include/mach/board.h b/arch/arm/mach-msm/include/mach/board.h
index 2b9343e..e7f156e 100644
--- a/arch/arm/mach-msm/include/mach/board.h
+++ b/arch/arm/mach-msm/include/mach/board.h
@@ -93,7 +93,7 @@
 #define MSM_CAMERA_FLASH_SRC_PWM  (0x00000001<<1)
 #define MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER	(0x00000001<<2)
 #define MSM_CAMERA_FLASH_SRC_EXT     (0x00000001<<3)
-
+#define MSM_CAMERA_FLASH_SRC_LED (0x00000001<<3)
 
 struct msm_camera_sensor_flash_pmic {
 	uint8_t num_of_src;
@@ -125,6 +125,11 @@
 	struct msm_cam_expander_info *expander_info;
 };
 
+struct msm_camera_sensor_flash_led {
+	const char *led_name;
+	const int led_name_len;
+};
+
 struct msm_camera_sensor_flash_src {
 	int flash_sr_type;
 
@@ -135,6 +140,7 @@
 			current_driver_src;
 		struct msm_camera_sensor_flash_external
 			ext_driver_src;
+		struct msm_camera_sensor_flash_led led_src;
 	} _fsrc;
 };
 
diff --git a/arch/arm/mach-msm/smd.c b/arch/arm/mach-msm/smd.c
index 9b7dd45..eeaab60 100644
--- a/arch/arm/mach-msm/smd.c
+++ b/arch/arm/mach-msm/smd.c
@@ -172,7 +172,8 @@
 #define MSM_TRIG_A2DSPS_SMSM_INT
 #define MSM_TRIG_A2WCNSS_SMD_INT
 #define MSM_TRIG_A2WCNSS_SMSM_INT
-#elif defined(CONFIG_ARCH_MSM8960)
+#elif defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_MSM8930) || \
+	defined(CONFIG_ARCH_APQ8064)
 #define MSM_TRIG_A2M_SMD_INT     \
 			(smd_write_intr(1 << 3, MSM_APCS_GCC_BASE + 0x8))
 #define MSM_TRIG_A2Q6_SMD_INT    \
@@ -202,23 +203,6 @@
 #define MSM_TRIG_A2DSPS_SMSM_INT
 #define MSM_TRIG_A2WCNSS_SMD_INT
 #define MSM_TRIG_A2WCNSS_SMSM_INT
-#elif defined(CONFIG_ARCH_APQ8064)
-#define MSM_TRIG_A2M_SMD_INT     \
-			(smd_write_intr(1 << 3, MSM_APCS_GCC_BASE + 0x8))
-#define MSM_TRIG_A2Q6_SMD_INT    \
-			(smd_write_intr(1 << 15, MSM_APCS_GCC_BASE + 0x8))
-#define MSM_TRIG_A2M_SMSM_INT    \
-			(smd_write_intr(1 << 4, MSM_APCS_GCC_BASE + 0x8))
-#define MSM_TRIG_A2Q6_SMSM_INT   \
-			(smd_write_intr(1 << 14, MSM_APCS_GCC_BASE + 0x8))
-#define MSM_TRIG_A2DSPS_SMD_INT  \
-			(smd_write_intr(1, MSM_SIC_NON_SECURE_BASE + 0x4080))
-#define MSM_TRIG_A2DSPS_SMSM_INT \
-			(smd_write_intr(1, MSM_SIC_NON_SECURE_BASE + 0x4094))
-#define MSM_TRIG_A2WCNSS_SMD_INT  \
-			(smd_write_intr(1 << 25, MSM_APCS_GCC_BASE + 0x8))
-#define MSM_TRIG_A2WCNSS_SMSM_INT  \
-			(smd_write_intr(1 << 23, MSM_APCS_GCC_BASE + 0x8))
 #elif defined(CONFIG_ARCH_FSM9XXX)
 #define MSM_TRIG_A2Q6_SMD_INT	\
 			(smd_write_intr(1 << 10, MSM_GCC_BASE + 0x8))
@@ -277,8 +261,10 @@
 	 * trigger GPIO 40 to wake up RIVA from power collaspe
 	 * not to be sent to customers
 	 */
-	__raw_writel(0x0, MSM_TLMM_BASE + 0x1284);
-	__raw_writel(0x2, MSM_TLMM_BASE + 0x1284);
+	if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1) {
+		__raw_writel(0x0, MSM_TLMM_BASE + 0x1284);
+		__raw_writel(0x2, MSM_TLMM_BASE + 0x1284);
+	}
 	/* end workaround */
 }
 #else
diff --git a/drivers/bluetooth/hci_smd.c b/drivers/bluetooth/hci_smd.c
index f3e0f6c..2ecddcf 100644
--- a/drivers/bluetooth/hci_smd.c
+++ b/drivers/bluetooth/hci_smd.c
@@ -147,7 +147,7 @@
 			goto out_data;
 		}
 
-		rc = smd_read_from_cb(hsmd->data_channel, (void *)buf, len);
+		rc = smd_read(hsmd->data_channel, (void *)buf, len);
 		if (rc < len) {
 			BT_ERR("Error in reading from the channel");
 			goto out_data;
@@ -220,7 +220,7 @@
 			rc = -ENOMEM;
 			goto out_event;
 		}
-		rc = smd_read_from_cb(hsmd->event_channel, (void *)buf, len);
+		rc = smd_read(hsmd->event_channel, (void *)buf, len);
 		if (rc < len) {
 			BT_ERR("Error in reading from the event channel");
 			goto out_event;
diff --git a/drivers/crypto/msm/qcedev.c b/drivers/crypto/msm/qcedev.c
index 405d021..3ae1647 100644
--- a/drivers/crypto/msm/qcedev.c
+++ b/drivers/crypto/msm/qcedev.c
@@ -439,7 +439,7 @@
 		creq.alg = CIPHER_ALG_AES;
 		break;
 	default:
-		break;
+		return -EINVAL;
 	};
 
 	switch (qcedev_areq->cipher_op_req.mode) {
@@ -458,7 +458,7 @@
 		creq.mode = QCE_MODE_XTS;
 		break;
 	default:
-		break;
+		return -EINVAL;
 	};
 
 	if ((creq.alg == CIPHER_ALG_AES) &&
diff --git a/drivers/crypto/msm/qcrypto.c b/drivers/crypto/msm/qcrypto.c
index 73627d4..67301877 100644
--- a/drivers/crypto/msm/qcrypto.c
+++ b/drivers/crypto/msm/qcrypto.c
@@ -889,6 +889,9 @@
 	if (areq->assoclen)
 		qreq->nonce[0] |= 64;
 
+	if (i > MAX_NONCE)
+		return -EINVAL;
+
 	return aead_ccm_set_msg_len(qreq->nonce + 16 - i, qreq->cryptlen, i);
 }
 
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index b9520c8..b76b6d9 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -20,53 +20,12 @@
 #include <linux/err.h>
 #include <linux/ctype.h>
 #include <linux/leds.h>
-#include <linux/slab.h>
 #include "leds.h"
 
 #define LED_BUFF_SIZE 50
 
 static struct class *leds_class;
 
-#ifdef CONFIG_HAS_EARLYSUSPEND
-
-static void change_brightness(struct work_struct *brightness_change_data)
-{
-	struct deferred_brightness_change *brightness_change = container_of(
-			brightness_change_data,
-			struct deferred_brightness_change,
-			brightness_change_work);
-	struct led_classdev *led_cdev = brightness_change->led_cdev;
-	enum led_brightness value = brightness_change->value;
-
-	led_cdev->brightness_set(led_cdev, value);
-
-	/* Free up memory for the brightness_change structure. */
-	kfree(brightness_change);
-}
-
-int queue_brightness_change(struct led_classdev *led_cdev,
-	enum led_brightness value)
-{
-	/* Initialize the brightness_change_work and its super-struct. */
-	struct deferred_brightness_change *brightness_change =
-		kzalloc(sizeof(struct deferred_brightness_change), GFP_KERNEL);
-
-	if (!brightness_change)
-		return -ENOMEM;
-
-	brightness_change->led_cdev = led_cdev;
-	brightness_change->value = value;
-
-	INIT_WORK(&(brightness_change->brightness_change_work),
-		change_brightness);
-	queue_work(suspend_work_queue,
-		&(brightness_change->brightness_change_work));
-
-	return 0;
-}
-
-#endif
-
 static void led_update_brightness(struct led_classdev *led_cdev)
 {
 	if (led_cdev->brightness_get)
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index 593a63c..e77c7f8 100644
--- a/drivers/leds/leds.h
+++ b/drivers/leds/leds.h
@@ -16,21 +16,6 @@
 #include <linux/device.h>
 #include <linux/rwsem.h>
 #include <linux/leds.h>
-#include <linux/workqueue.h>
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-
-extern struct workqueue_struct *suspend_work_queue;
-extern int queue_brightness_change(struct led_classdev *led_cdev,
-	enum led_brightness value);
-
-struct deferred_brightness_change {
-	struct work_struct brightness_change_work;
-	struct led_classdev *led_cdev;
-	enum led_brightness value;
-};
-
-#endif
 
 static inline void led_set_brightness(struct led_classdev *led_cdev,
 					enum led_brightness value)
@@ -38,12 +23,8 @@
 	if (value > led_cdev->max_brightness)
 		value = led_cdev->max_brightness;
 	led_cdev->brightness = value;
-	if (!(led_cdev->flags & LED_SUSPENDED)) {
-#ifdef CONFIG_HAS_EARLYSUSPEND
-		if (queue_brightness_change(led_cdev, value) != 0)
-#endif
-			led_cdev->brightness_set(led_cdev, value);
-	}
+	if (!(led_cdev->flags & LED_SUSPENDED))
+		led_cdev->brightness_set(led_cdev, value);
 }
 
 static inline int led_get_brightness(struct led_classdev *led_cdev)
diff --git a/drivers/media/video/msm/Kconfig b/drivers/media/video/msm/Kconfig
index a86460b..9361f5a9 100644
--- a/drivers/media/video/msm/Kconfig
+++ b/drivers/media/video/msm/Kconfig
@@ -37,6 +37,18 @@
 	default y
 	---help---
 	SONY 13.5 MP Bayer Sensor
+config OV5640
+	bool "Sensor OV5640 (YUV 5M)"
+	depends on MSM_CAMERA && !MSM_CAMERA_V4L2
+	default n
+	---help---
+	Omni 5M YUV Sensor
+config WEBCAM_OV7692_QRD
+	bool "Sensor OV7692 QRD(VGA YUV)"
+	depends on MSM_CAMERA && ARCH_MSM7X27A && !MSM_CAMERA_V4L2
+	default n
+	---help---
+	  Omni Vision VGA YUV Sensor for QRD Devices
 config WEBCAM_OV7692
 	bool "Sensor OV7692 (VGA YUV)"
 	depends on MSM_CAMERA && ARCH_MSM8X60 && !MSM_CAMERA_V4L2
diff --git a/drivers/media/video/msm/Makefile b/drivers/media/video/msm/Makefile
index bd3fffe..3f41d43 100644
--- a/drivers/media/video/msm/Makefile
+++ b/drivers/media/video/msm/Makefile
@@ -39,6 +39,8 @@
 obj-$(CONFIG_IMX072) += imx072.o imx072_reg.o
 obj-$(CONFIG_WEBCAM_OV9726) += ov9726.o ov9726_reg.o
 obj-$(CONFIG_WEBCAM_OV7692) += ov7692.o
+obj-$(CONFIG_WEBCAM_OV7692_QRD) += ov7692_qrd.o
+obj-$(CONFIG_OV5640) += ov5640.o
 obj-$(CONFIG_MT9D112) += mt9d112.o mt9d112_reg.o
 
 obj-$(CONFIG_MT9D113) += mt9d113.o mt9d113_reg.o
diff --git a/drivers/media/video/msm/msm.c b/drivers/media/video/msm/msm.c
index 5d9112e..40a273a 100644
--- a/drivers/media/video/msm/msm.c
+++ b/drivers/media/video/msm/msm.c
@@ -1574,10 +1574,12 @@
 
 
 	mutex_lock(&pcam->vid_lock);
+	pcam_inst->streamon = 0;
 	pcam->use_count--;
 	pcam->dev_inst_map[pcam_inst->image_mode] = NULL;
 	if (pcam_inst->vbqueue_initialized)
 		vb2_queue_release(&pcam_inst->vid_bufq);
+	D("%s Closing down instance %p ", __func__, pcam_inst);
 	pcam->dev_inst[pcam_inst->my_index] = NULL;
 	if (pcam_inst->my_index == 0) {
 		v4l2_fh_del(&pcam_inst->eventHandle);
diff --git a/drivers/media/video/msm/msm_isp.c b/drivers/media/video/msm/msm_isp.c
index 6983d70..56fbc41 100644
--- a/drivers/media/video/msm/msm_isp.c
+++ b/drivers/media/video/msm/msm_isp.c
@@ -81,7 +81,11 @@
 	struct msm_cam_v4l2_device *pcam = sync->pcam_sync;
 
 	int vfe_id = vdata->evt_msg.msg_id;
-
+	if (!pcam) {
+		pr_err("%s pcam is null. return\n", __func__);
+		msm_isp_sync_free(vdata);
+		return rc;
+	}
 	switch (vdata->type) {
 	case VFE_MSG_V32_START:
 	case VFE_MSG_V32_START_RECORDING:
diff --git a/drivers/media/video/msm/msm_mctl_buf.c b/drivers/media/video/msm/msm_mctl_buf.c
index a8554ee..1bbb029 100644
--- a/drivers/media/video/msm/msm_mctl_buf.c
+++ b/drivers/media/video/msm/msm_mctl_buf.c
@@ -368,23 +368,28 @@
 int msm_mctl_out_type_to_inst_index(struct msm_cam_v4l2_device *pcam,
 					int out_type)
 {
+	int image_mode;
 	switch (out_type) {
 	case VFE_MSG_OUTPUT_P:
-		return pcam->dev_inst_map
-			[MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW]->my_index;
+		image_mode = MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW;
+		break;
 	case VFE_MSG_OUTPUT_V:
-		return pcam->dev_inst_map
-			[MSM_V4L2_EXT_CAPTURE_MODE_VIDEO]->my_index;
+		image_mode = MSM_V4L2_EXT_CAPTURE_MODE_VIDEO;
+		break;
 	case VFE_MSG_OUTPUT_S:
-		return pcam->dev_inst_map
-			[MSM_V4L2_EXT_CAPTURE_MODE_MAIN]->my_index;
+		image_mode = MSM_V4L2_EXT_CAPTURE_MODE_MAIN;
+		break;
 	case VFE_MSG_OUTPUT_T:
-		return pcam->dev_inst_map
-			[MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL]->my_index;
+		image_mode = MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL;
+		break;
 	default:
-		return 0;
+		image_mode = -1;
+		break;
 	}
-	return 0;
+	if ((image_mode >= 0) && pcam->dev_inst_map[image_mode])
+		return pcam->dev_inst_map[image_mode]->my_index;
+	else
+		return -EINVAL;
 }
 
 void msm_mctl_gettimeofday(struct timeval *tv)
@@ -482,6 +487,11 @@
 	else {
 		idx = msm_mctl_out_type_to_inst_index(
 				p_mctl->sync.pcam_sync, msg_type);
+		if (idx < 0) {
+			pr_err("%s Invalid instance, dropping buffer\n",
+				__func__);
+			return idx;
+		}
 		pcam_inst = p_mctl->sync.pcam_sync->dev_inst[idx];
 		rc = msm_mctl_buf_done_proc(p_mctl, pcam_inst,
 				msg_type, fbuf,
@@ -508,16 +518,20 @@
 	int rc = -EINVAL, idx, i;
 	uint32_t buf_idx, plane_offset = 0;
 
-	if (!free_buf) {
-		pr_err("%s: free_buf= null\n", __func__);
+	if (!free_buf || !pmctl) {
+		pr_err("%s: free_buf/pmctl is null\n", __func__);
 		return rc;
 	}
 	memset(free_buf, 0, sizeof(struct msm_free_buf));
 	idx = msm_mctl_out_type_to_inst_index(pmctl->sync.pcam_sync,
 		msg_type);
+	if (idx < 0) {
+		pr_err("%s Invalid instance, returning\n", __func__);
+		return idx;
+	}
 	pcam_inst = pmctl->sync.pcam_sync->dev_inst[idx];
 	if (!pcam_inst || !pcam_inst->streamon) {
-		D("%s: stream is turned off\n", __func__);
+		pr_err("%s: stream is turned off\n", __func__);
 		return rc;
 	}
 	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
@@ -582,6 +596,10 @@
 		return rc;
 
 	idx = msm_mctl_out_type_to_inst_index(pmctl->sync.pcam_sync, msg_type);
+	if (idx < 0) {
+		pr_err("%s Invalid instance, buffer not released\n", __func__);
+		return idx;
+	}
 	pcam_inst = pmctl->sync.pcam_sync->dev_inst[idx];
 	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
 	list_for_each_entry(buf, &pcam_inst->free_vq, list) {
@@ -611,6 +629,10 @@
 
 	idx = msm_mctl_out_type_to_inst_index(
 		pmctl->sync.pcam_sync, msg_type);
+	if (idx < 0) {
+		pr_err("%s Invalid instance, buffer dropped\n", __func__);
+		return idx;
+	}
 	pcam_inst = pmctl->sync.pcam_sync->dev_inst[idx];
 	D("%s:inst=0x%p, paddr=0x%x, dirty=%d",
 		__func__, pcam_inst, frame->ch_paddr[0], dirty);
@@ -634,6 +656,10 @@
 
 	idx = msm_mctl_out_type_to_inst_index(pmctl->sync.pcam_sync,
 		msg_type);
+	if (idx < 0) {
+		pr_err("%s Invalid instance, cant get buffer\n", __func__);
+		return NULL;
+	}
 	pcam_inst = pmctl->sync.pcam_sync->dev_inst[idx];
 	if (!pcam_inst->streamon) {
 		D("%s: stream 0x%p is off\n", __func__, pcam_inst);
@@ -669,6 +695,10 @@
 
 	idx = msm_mctl_out_type_to_inst_index(pmctl->sync.pcam_sync,
 		msg_type);
+	if (idx < 0) {
+		pr_err("%s Invalid instance, cant put buffer\n", __func__);
+		return idx;
+	}
 	pcam_inst = pmctl->sync.pcam_sync->dev_inst[idx];
 	if (!pcam_inst->streamon) {
 		D("%s: stream 0x%p is off\n", __func__, pcam_inst);
@@ -700,6 +730,10 @@
 
 	idx = msm_mctl_out_type_to_inst_index(pmctl->sync.pcam_sync,
 		msg_type);
+	if (idx < 0) {
+		pr_err("%s Invalid instance, cant delete buffer\n", __func__);
+		return idx;
+	}
 	pcam_inst = pmctl->sync.pcam_sync->dev_inst[idx];
 	D("%s: idx = %d, pinst=0x%p", __func__, idx, pcam_inst);
 	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
diff --git a/drivers/media/video/msm/msm_vfe7x27a.c b/drivers/media/video/msm/msm_vfe7x27a.c
index c8bfacc..9f7dff7 100644
--- a/drivers/media/video/msm/msm_vfe7x27a.c
+++ b/drivers/media/video/msm/msm_vfe7x27a.c
@@ -287,8 +287,7 @@
 	kfree(extdata);
 	extlen = 0;
 
-	/* set back the AXI frequency to default */
-	/* TODO msm_camio_set_perf_lvl(S_DEFAULT); */
+	msm_camio_set_perf_lvl(S_EXIT);
 }
 
 static int vfe_7x_init(struct msm_vfe_callback *presp,
diff --git a/drivers/media/video/msm/ov5640.c b/drivers/media/video/msm/ov5640.c
new file mode 100644
index 0000000..1380bcf
--- /dev/null
+++ b/drivers/media/video/msm/ov5640.c
@@ -0,0 +1,1477 @@
+/* Copyright (c) 2011, Code Aurora Forum. 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 version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/* #define DEBUG */
+
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <linux/i2c.h>
+#include <linux/uaccess.h>
+#include <linux/miscdevice.h>
+#include <linux/leds.h>
+#include <linux/slab.h>
+#include <media/msm_camera.h>
+#include <mach/gpio.h>
+#include <mach/camera.h>
+#include "ov5640.h"
+
+#define FALSE 0
+#define TRUE 1
+
+struct ov5640_work {
+	struct work_struct work;
+};
+
+struct __ov5640_ctrl {
+	const struct msm_camera_sensor_info *sensordata;
+	int sensormode;
+	uint fps_divider; /* init to 1 * 0x00000400 */
+	uint pict_fps_divider; /* init to 1 * 0x00000400 */
+	u16 curr_step_pos;
+	u16 curr_lens_pos;
+	u16 init_curr_lens_pos;
+	u16 my_reg_gain;
+	u16 my_reg_line_count;
+	enum msm_s_resolution prev_res;
+	enum msm_s_resolution pict_res;
+	enum msm_s_resolution curr_res;
+	enum msm_s_test_mode  set_test;
+};
+
+static DECLARE_WAIT_QUEUE_HEAD(ov5640_wait_queue);
+DEFINE_MUTEX(ov5640_mutex);
+
+static int ov5640_pwdn_gpio;
+static int ov5640_reset_gpio;
+static int ov5640_driver_pwdn_gpio;
+static int OV5640_CSI_CONFIG;
+static struct ov5640_work *ov5640_sensorw;
+static struct i2c_client    *ov5640_client;
+static u8 ov5640_i2c_buf[4];
+static u8 ov5640_counter;
+static int16_t ov5640_effect;
+static int is_autoflash;
+static int effect_value;
+unsigned int ov5640_SAT_U = 0x40;
+unsigned int ov5640_SAT_V = 0x40;
+
+static struct __ov5640_ctrl *ov5640_ctrl;
+static int ov5640_afinit = 1;
+
+struct rw_semaphore ov_leds_list_lock;
+struct list_head ov_leds_list;
+
+static int ov5640_i2c_remove(struct i2c_client *client);
+static int ov5640_i2c_probe(struct i2c_client *client,
+		const struct i2c_device_id *id);
+
+static int ov5640_i2c_txdata(u16 saddr, u8 *txdata, int length)
+{
+	struct i2c_msg msg[] = {
+		{
+			.addr	= saddr,
+			.flags	= 0,
+			.len	= length,
+			.buf	= txdata,
+		},
+	};
+
+	if (i2c_transfer(ov5640_client->adapter, msg, 1) < 0)
+		return -EIO;
+	else
+		return 0;
+}
+
+static int ov5640_i2c_write(unsigned short saddr, unsigned int waddr,
+		unsigned short bdata, u8 trytimes)
+{
+	int rc = -EIO;
+
+	ov5640_counter = 0;
+	ov5640_i2c_buf[0] = (waddr & 0xFF00) >> 8;
+	ov5640_i2c_buf[1] = (waddr & 0x00FF);
+	ov5640_i2c_buf[2] = (bdata & 0x00FF);
+
+	while ((ov5640_counter < trytimes) && (rc != 0)) {
+		rc = ov5640_i2c_txdata(saddr, ov5640_i2c_buf, 3);
+
+		if (rc < 0) {
+			ov5640_counter++;
+			CDBG("***--CAMERA i2c_write_w failed,i2c addr=0x%x,"
+				"command addr = 0x%x, val = 0x%x,s=%d,"
+					"rc=%d!\n", saddr, waddr, bdata,
+					ov5640_counter, rc);
+			msleep(20);
+		}
+	}
+	return rc;
+}
+
+static int ov5640_i2c_rxdata(unsigned short saddr, unsigned char *rxdata,
+		int length)
+{
+	struct i2c_msg msgs[] = {
+		{
+			.addr	= saddr,
+			.flags	= 0,
+			.len	= 2,
+			.buf	= rxdata,
+		},
+		{
+			.addr	= saddr,
+			.flags	= I2C_M_RD,
+			.len	= length,
+			.buf	= rxdata,
+		},
+	};
+
+	if (i2c_transfer(ov5640_client->adapter, msgs, 2) < 0) {
+		CDBG("ov5640_i2c_rxdata failed!\n");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int32_t ov5640_i2c_read_byte(unsigned short  saddr,
+		unsigned int raddr, unsigned int *rdata)
+{
+	int rc = 0;
+	unsigned char buf[2];
+
+	memset(buf, 0, sizeof(buf));
+
+	buf[0] = (raddr & 0xFF00)>>8;
+	buf[1] = (raddr & 0x00FF);
+
+	rc = ov5640_i2c_rxdata(saddr, buf, 1);
+	if (rc < 0) {
+		CDBG("ov5640_i2c_read_byte failed!\n");
+		return rc;
+	}
+
+	*rdata = buf[0];
+
+	return rc;
+}
+
+static int32_t ov5640_writepregs(struct ov5640_sensor *ptb, int32_t len)
+{
+	int32_t i, ret = 0;
+	uint32_t regv;
+
+	for (i = 0; i < len; i++) {
+		if (0 == ptb[i].mask) {
+			ov5640_i2c_write(ov5640_client->addr, ptb[i].addr,
+					ptb[i].data, 10);
+		} else {
+			ov5640_i2c_read_byte(ov5640_client->addr, ptb[i].addr,
+					&regv);
+			regv &= ptb[i].mask;
+			regv |= (ptb[i].data & (~ptb[i].mask));
+			ov5640_i2c_write(ov5640_client->addr, ptb[i].addr,
+					regv, 10);
+		}
+	}
+	return ret;
+}
+
+static void camera_sw_power_onoff(int v)
+{
+	if (v == 0) {
+		CDBG("camera_sw_power_onoff: down\n");
+		ov5640_i2c_write(ov5640_client->addr, 0x3008, 0x42, 10);
+	} else {
+		CDBG("camera_sw_power_onoff: on\n");
+		ov5640_i2c_write(ov5640_client->addr, 0x3008, 0x02, 10);
+	}
+}
+
+static void ov5640_power_off(void)
+{
+	CDBG("--CAMERA-- %s ... (Start...)\n", __func__);
+	gpio_set_value(ov5640_pwdn_gpio, 1);
+	CDBG("--CAMERA-- %s ... (End...)\n", __func__);
+}
+
+static void ov5640_power_on(void)
+{
+	CDBG("--CAMERA-- %s ... (Start...)\n", __func__);
+	gpio_set_value(ov5640_pwdn_gpio, 0);
+	CDBG("--CAMERA-- %s ... (End...)\n", __func__);
+}
+
+static void ov5640_power_reset(void)
+{
+	CDBG("--CAMERA-- %s ... (Start...)\n", __func__);
+	gpio_set_value(ov5640_reset_gpio, 1);   /* reset camera reset pin */
+	msleep(20);
+	gpio_set_value(ov5640_reset_gpio, 0);
+	msleep(20);
+	gpio_set_value(ov5640_reset_gpio, 1);
+	msleep(20);
+
+	CDBG("--CAMERA-- %s ... (End...)\n", __func__);
+}
+
+static int ov5640_probe_readID(const struct msm_camera_sensor_info *data)
+{
+	int rc = 0;
+	u32 device_id_high = 0;
+	u32 device_id_low = 0;
+
+	CDBG("--CAMERA-- %s (Start...)\n", __func__);
+	CDBG("--CAMERA-- %s sensor poweron,begin to read ID!\n", __func__);
+
+	/* 0x300A ,sensor ID register */
+	rc = ov5640_i2c_read_byte(ov5640_client->addr, 0x300A,
+			&device_id_high);
+
+	if (rc < 0) {
+		CDBG("--CAMERA-- %s ok , readI2C failed, rc = 0x%x\r\n",
+				__func__, rc);
+		return rc;
+	}
+	CDBG("--CAMERA-- %s  readID high byte, data = 0x%x\r\n",
+			__func__, device_id_high);
+
+	/* 0x300B ,sensor ID register */
+	rc = ov5640_i2c_read_byte(ov5640_client->addr, 0x300B,
+			&device_id_low);
+	if (rc < 0) {
+		CDBG("--CAMERA-- %s ok , readI2C failed,rc = 0x%x\r\n",
+				__func__, rc);
+		return rc;
+	}
+
+	CDBG("--CAMERA-- %s  readID low byte, data = 0x%x\r\n",
+			__func__, device_id_low);
+	CDBG("--CAMERA-- %s return ID :0x%x\n", __func__,
+			(device_id_high << 8) + device_id_low);
+
+	/* 0x5640, ov5640 chip id */
+	if ((device_id_high << 8) + device_id_low != OV5640_SENSOR_ID) {
+		CDBG("--CAMERA-- %s ok , device id error, should be 0x%x\r\n",
+				__func__, OV5640_SENSOR_ID);
+		return -EINVAL;
+	} else {
+		CDBG("--CAMERA-- %s ok , device id=0x%x\n", __func__,
+				OV5640_SENSOR_ID);
+		return 0;
+	}
+}
+
+static int ov5640_af_setting(void)
+{
+	int rc = 0;
+	int lens = sizeof(ov5640_afinit_tbl) / sizeof(ov5640_afinit_tbl[0]);
+
+	CDBG("--CAMERA-- ov5640_af_setting\n");
+
+	ov5640_i2c_write(ov5640_client->addr, 0x3000, 0x20, 10);
+
+	rc = ov5640_i2c_txdata(ov5640_client->addr, ov5640_afinit_tbl, lens);
+	if (rc < 0) {
+		CDBG("--CAMERA-- AF_init failed\n");
+		return rc;
+	}
+
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_MAIN, 0x00, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_ACK, 0x00, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_PARA0, 0x00, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_PARA1, 0x00, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_PARA2, 0x00, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_PARA3, 0x00, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_PARA4, 0x00, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_FW_STATUS, 0x7f, 10);
+	ov5640_i2c_write(ov5640_client->addr, 0x3000, 0x00, 10);
+
+	return rc;
+}
+
+static int ov5640_set_flash_light(enum led_brightness brightness)
+{
+	struct led_classdev *led_cdev;
+
+	CDBG("ov5640_set_flash_light brightness = %d\n", brightness);
+
+	down_read(&ov_leds_list_lock);
+	list_for_each_entry(led_cdev, &ov_leds_list, node) {
+		if (!strncmp(led_cdev->name, "flashlight", 10))
+			break;
+	}
+	up_read(&ov_leds_list_lock);
+
+	if (led_cdev) {
+		led_brightness_set(led_cdev, brightness);
+	} else {
+		CDBG("get flashlight device failed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int ov5640_video_config(void)
+{
+	int rc = 0;
+
+	CDBG("--CAMERA-- ov5640_video_config\n");
+	CDBG("--CAMERA-- preview in, is_autoflash - 0x%x\n", is_autoflash);
+
+	/* autoflash setting */
+	if (is_autoflash == 1)
+		ov5640_set_flash_light(LED_OFF);
+
+	/* preview setting */
+	rc = OV5640CORE_WRITEPREG(ov5640_preview_tbl);
+	return rc;
+}
+
+static int ov5640_snapshot_config(void)
+{
+	int rc = 0;
+	unsigned int tmp;
+
+	CDBG("--CAMERA-- SENSOR_SNAPSHOT_MODE\n");
+	CDBG("--CAMERA-- %s, snapshot in, is_autoflash - 0x%x\n", __func__,
+			is_autoflash);
+
+	if (is_autoflash == 1) {
+		ov5640_i2c_read_byte(ov5640_client->addr, 0x350b, &tmp);
+		CDBG("--CAMERA-- GAIN VALUE : %x\n", tmp);
+		if ((tmp & 0x80) == 0)
+			ov5640_set_flash_light(LED_OFF);
+		else
+			ov5640_set_flash_light(LED_FULL);
+	}
+
+	rc = OV5640CORE_WRITEPREG(ov5640_capture_tbl);
+
+	return rc;
+}
+
+static int ov5640_setting(enum msm_s_reg_update rupdate,
+		enum msm_s_setting rt)
+{
+	int rc = -EINVAL, tmp;
+	struct msm_camera_csi_params ov5640_csi_params;
+
+	CDBG("--CAMERA-- %s (Start...), rupdate=%d\n", __func__, rupdate);
+
+	switch (rupdate) {
+	case S_UPDATE_PERIODIC:
+		if (!OV5640_CSI_CONFIG) {
+			camera_sw_power_onoff(0); /* standby */
+			msleep(20);
+
+			ov5640_csi_params.lane_cnt = 2;
+			ov5640_csi_params.data_format = CSI_8BIT;
+			ov5640_csi_params.lane_assign = 0xe4;
+			ov5640_csi_params.dpcm_scheme = 0;
+			ov5640_csi_params.settle_cnt = 0x6;
+
+			CDBG("%s: msm_camio_csi_config\n", __func__);
+
+			rc = msm_camio_csi_config(&ov5640_csi_params);
+			msleep(20);
+			camera_sw_power_onoff(1); /* on */
+			msleep(20);
+
+			OV5640_CSI_CONFIG = 1;
+
+		} else {
+			rc = 0;
+		}
+
+		if (S_RES_PREVIEW == rt)
+			rc = ov5640_video_config();
+		else if (S_RES_CAPTURE == rt)
+			rc = ov5640_snapshot_config();
+
+		break; /* UPDATE_PERIODIC */
+
+	case S_REG_INIT:
+		CDBG("--CAMERA-- S_REG_INIT (Start)\n");
+
+		rc = ov5640_i2c_write(ov5640_client->addr, 0x3103, 0x11, 10);
+		rc = ov5640_i2c_write(ov5640_client->addr, 0x3008, 0x82, 10);
+		msleep(20);
+
+		/* set sensor init setting */
+		CDBG("set sensor init setting\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_init_tbl);
+		if (rc < 0) {
+			CDBG("sensor init setting failed\n");
+			break;
+		}
+
+		/* set image quality setting */
+		rc = OV5640CORE_WRITEPREG(ov5640_init_iq_tbl);
+		rc = ov5640_i2c_read_byte(ov5640_client->addr, 0x4740, &tmp);
+		CDBG("--CAMERA-- init 0x4740 value=0x%x\n", tmp);
+
+		if (tmp != 0x21) {
+			rc = ov5640_i2c_write(ov5640_client->addr, 0x4740,
+					0x21, 10);
+			msleep(20);
+			rc = ov5640_i2c_read_byte(ov5640_client->addr,
+					0x4740, &tmp);
+			CDBG("--CAMERA-- WG 0x4740 value=0x%x\n", tmp);
+		}
+
+		CDBG("--CAMERA-- AF_init: ov5640_afinit = %d\n",
+				ov5640_afinit);
+		if (ov5640_afinit == 1) {
+			rc = ov5640_af_setting();
+			if (rc < 0) {
+				CDBG("--CAMERA-- ov5640_af_setting failed\n");
+				break;
+			}
+			ov5640_afinit = 0;
+		}
+
+		/* reset fps_divider */
+		ov5640_ctrl->fps_divider = 1 * 0x0400;
+		CDBG("--CAMERA-- S_REG_INIT (End)\n");
+		break; /* case REG_INIT: */
+
+	default:
+		break;
+	} /* switch (rupdate) */
+
+	CDBG("--CAMERA-- %s (End), rupdate=%d\n", __func__, rupdate);
+
+	return rc;
+}
+
+static int ov5640_sensor_open_init(const struct msm_camera_sensor_info *data)
+{
+	int rc = -ENOMEM;
+
+	CDBG("--CAMERA-- %s\n", __func__);
+	ov5640_ctrl = kzalloc(sizeof(struct __ov5640_ctrl), GFP_KERNEL);
+	if (!ov5640_ctrl) {
+		CDBG("--CAMERA-- kzalloc ov5640_ctrl error !!\n");
+		kfree(ov5640_ctrl);
+		return rc;
+	}
+
+	ov5640_ctrl->fps_divider = 1 * 0x00000400;
+	ov5640_ctrl->pict_fps_divider = 1 * 0x00000400;
+	ov5640_ctrl->set_test = S_TEST_OFF;
+	ov5640_ctrl->prev_res = S_QTR_SIZE;
+	ov5640_ctrl->pict_res = S_FULL_SIZE;
+
+	if (data)
+		ov5640_ctrl->sensordata = data;
+
+	ov5640_power_off();
+
+	CDBG("%s: msm_camio_clk_rate_set\n", __func__);
+
+	msm_camio_clk_rate_set(24000000);
+	msleep(20);
+
+	ov5640_power_on();
+	ov5640_power_reset();
+
+	CDBG("%s: init sequence\n", __func__);
+
+	if (ov5640_ctrl->prev_res == S_QTR_SIZE)
+		rc = ov5640_setting(S_REG_INIT, S_RES_PREVIEW);
+	else
+		rc = ov5640_setting(S_REG_INIT, S_RES_CAPTURE);
+
+	if (rc < 0) {
+		CDBG("--CAMERA-- %s : ov5640_setting failed. rc = %d\n",
+				__func__, rc);
+		kfree(ov5640_ctrl);
+		return rc;
+	}
+
+	OV5640_CSI_CONFIG = 0;
+
+	CDBG("--CAMERA--re_init_sensor ok!!\n");
+	return rc;
+}
+
+static int ov5640_sensor_release(void)
+{
+	CDBG("--CAMERA--ov5640_sensor_release!!\n");
+
+	mutex_lock(&ov5640_mutex);
+
+	ov5640_power_off();
+
+	kfree(ov5640_ctrl);
+	ov5640_ctrl = NULL;
+
+	OV5640_CSI_CONFIG = 0;
+
+	mutex_unlock(&ov5640_mutex);
+	return 0;
+}
+
+static const struct i2c_device_id ov5640_i2c_id[] = {
+	{"ov5640",  0}, {}
+};
+
+static int ov5640_i2c_remove(struct i2c_client *client)
+{
+	return 0;
+}
+
+static int ov5640_init_client(struct i2c_client *client)
+{
+	/* Initialize the MSM_CAMI2C Chip */
+	init_waitqueue_head(&ov5640_wait_queue);
+	return 0;
+}
+
+static long ov5640_set_effect(int mode, int effect)
+{
+	int rc = 0;
+
+	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
+
+	switch (mode) {
+	case SENSOR_PREVIEW_MODE:
+		/* Context A Special Effects */
+		CDBG("--CAMERA-- %s ...SENSOR_PREVIEW_MODE\n", __func__);
+		break;
+
+	case SENSOR_SNAPSHOT_MODE:
+		/* Context B Special Effects */
+		CDBG("--CAMERA-- %s ...SENSOR_SNAPSHOT_MODE\n", __func__);
+		break;
+
+	default:
+		break;
+	}
+
+	effect_value = effect;
+
+	switch (effect)	{
+	case CAMERA_EFFECT_OFF:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_OFF\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_normal_tbl);
+		/* for recover saturation level when change special effect */
+		ov5640_i2c_write(ov5640_client->addr, 0x5583, ov5640_SAT_U,
+				10);
+		/* for recover saturation level when change special effect */
+		ov5640_i2c_write(ov5640_client->addr, 0x5584, ov5640_SAT_V,
+				10);
+		break;
+
+	case CAMERA_EFFECT_MONO:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_MONO\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_mono_tbl);
+		break;
+
+	case CAMERA_EFFECT_BW:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_BW\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_bw_tbl);
+		break;
+
+	case CAMERA_EFFECT_BLUISH:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_BLUISH\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_bluish_tbl);
+		break;
+
+	case CAMERA_EFFECT_SOLARIZE:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_NEGATIVE\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_solarize_tbl);
+		break;
+
+	case CAMERA_EFFECT_SEPIA:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_SEPIA\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_sepia_tbl);
+		break;
+
+	case CAMERA_EFFECT_REDDISH:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_REDDISH\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_reddish_tbl);
+		break;
+
+	case CAMERA_EFFECT_GREENISH:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_GREENISH\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_greenish_tbl);
+		break;
+
+	case CAMERA_EFFECT_NEGATIVE:
+		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_NEGATIVE\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_effect_negative_tbl);
+		break;
+
+	default:
+		CDBG("--CAMERA-- %s ...Default(Not Support)\n", __func__);
+	}
+
+	ov5640_effect = effect;
+	/* Refresh Sequencer */
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+	return rc;
+}
+
+static int ov5640_set_brightness(int8_t brightness)
+{
+	int rc = 0;
+
+	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
+	CDBG("--CAMERA-- %s ...brightness = %d\n", __func__ , brightness);
+
+	switch (brightness) {
+	case CAMERA_BRIGHTNESS_LV0:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV0\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv0_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV1:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV1\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv1_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV2:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV2\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv2_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV3:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV3\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv3_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV4:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV4\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_default_lv4_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV5:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV5\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv5_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV6:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV6\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv6_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV7:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV7\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv7_tbl);
+		break;
+
+	case CAMERA_BRIGHTNESS_LV8:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_LV8\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_brightness_lv8_tbl);
+		break;
+
+	default:
+		CDBG("--CAMERA--CAMERA_BRIGHTNESS_ERROR COMMAND\n");
+		break;
+	}
+
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+	return rc;
+}
+
+static int ov5640_set_contrast(int contrast)
+{
+	int rc = 0;
+
+	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
+	CDBG("--CAMERA-- %s ...contrast = %d\n", __func__ , contrast);
+
+	if (effect_value == CAMERA_EFFECT_OFF) {
+		switch (contrast) {
+		case CAMERA_CONTRAST_LV0:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV0\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv0_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV1:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV1\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv1_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV2:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV2\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv2_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV3:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV3\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv3_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV4:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV4\n");
+			rc = OV5640CORE_WRITEPREG(
+					ov5640_contrast_default_lv4_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV5:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV5\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv5_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV6:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV6\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv6_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV7:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV7\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv7_tbl);
+			break;
+
+		case CAMERA_CONTRAST_LV8:
+			CDBG("--CAMERA--CAMERA_CONTRAST_LV8\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_contrast_lv8_tbl);
+			break;
+
+		default:
+			CDBG("--CAMERA--CAMERA_CONTRAST_ERROR COMMAND\n");
+			break;
+		}
+	}
+
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+	return rc;
+}
+
+static int ov5640_set_sharpness(int sharpness)
+{
+	int rc = 0;
+
+	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
+	CDBG("--CAMERA-- %s ...sharpness = %d\n", __func__ , sharpness);
+
+	if (effect_value == CAMERA_EFFECT_OFF) {
+		switch (sharpness) {
+		case CAMERA_SHARPNESS_LV0:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV0\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv0_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV1:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV1\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv1_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV2:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV2\n");
+			rc = OV5640CORE_WRITEPREG(
+					ov5640_sharpness_default_lv2_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV3:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV3\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv3_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV4:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV4\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv4_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV5:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV5\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv5_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV6:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV6\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv6_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV7:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV7\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv7_tbl);
+			break;
+
+		case CAMERA_SHARPNESS_LV8:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_LV8\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_sharpness_lv8_tbl);
+			break;
+
+		default:
+			CDBG("--CAMERA--CAMERA_SHARPNESS_ERROR COMMAND\n");
+			break;
+		}
+	}
+
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+	return rc;
+}
+
+static int ov5640_set_saturation(int saturation)
+{
+	long rc = 0;
+
+	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
+	CDBG("--CAMERA-- %s ...saturation = %d\n", __func__ , saturation);
+
+	if (effect_value == CAMERA_EFFECT_OFF) {
+		switch (saturation) {
+		case CAMERA_SATURATION_LV0:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV0\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv0_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV1:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV1\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv1_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV2:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV2\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv2_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV3:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV3\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv3_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV4:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV4\n");
+			rc = OV5640CORE_WRITEPREG(
+					ov5640_saturation_default_lv4_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV5:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV5\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv5_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV6:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV6\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv6_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV7:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV7\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv7_tbl);
+			break;
+
+		case CAMERA_SATURATION_LV8:
+			CDBG("--CAMERA--CAMERA_SATURATION_LV8\n");
+			rc = OV5640CORE_WRITEPREG(ov5640_saturation_lv8_tbl);
+			break;
+
+		default:
+			CDBG("--CAMERA--CAMERA_SATURATION_ERROR COMMAND\n");
+			break;
+		}
+	}
+
+	/* for recover saturation level when change special effect */
+	switch (saturation) {
+	case CAMERA_SATURATION_LV0:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV0\n");
+		ov5640_SAT_U = 0x00;
+		ov5640_SAT_V = 0x00;
+		break;
+	case CAMERA_SATURATION_LV1:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV1\n");
+		ov5640_SAT_U = 0x10;
+		ov5640_SAT_V = 0x10;
+		break;
+	case CAMERA_SATURATION_LV2:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV2\n");
+		ov5640_SAT_U = 0x20;
+		ov5640_SAT_V = 0x20;
+		break;
+	case CAMERA_SATURATION_LV3:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV3\n");
+		ov5640_SAT_U = 0x30;
+		ov5640_SAT_V = 0x30;
+		break;
+	case CAMERA_SATURATION_LV4:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV4\n");
+		ov5640_SAT_U = 0x40;
+		ov5640_SAT_V = 0x40;            break;
+	case CAMERA_SATURATION_LV5:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV5\n");
+		ov5640_SAT_U = 0x50;
+		ov5640_SAT_V = 0x50;            break;
+	case CAMERA_SATURATION_LV6:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV6\n");
+		ov5640_SAT_U = 0x60;
+		ov5640_SAT_V = 0x60;
+		break;
+	case CAMERA_SATURATION_LV7:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV7\n");
+		ov5640_SAT_U = 0x70;
+		ov5640_SAT_V = 0x70;            break;
+	case CAMERA_SATURATION_LV8:
+		CDBG("--CAMERA--CAMERA_SATURATION_LV8\n");
+		ov5640_SAT_U = 0x80;
+		ov5640_SAT_V = 0x80;
+		break;
+	default:
+		CDBG("--CAMERA--CAMERA_SATURATION_ERROR COMMAND\n");
+		break;
+	}
+
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+	return rc;
+}
+
+static long ov5640_set_antibanding(int antibanding)
+{
+	long rc = 0;
+
+	CDBG("--CAMERA-- %s ...(Start)\n",  __func__);
+	CDBG("--CAMERA-- %s ...antibanding = %d\n",  __func__, antibanding);
+
+	switch (antibanding) {
+	case CAMERA_ANTIBANDING_OFF:
+		CDBG("--CAMERA--CAMERA_ANTIBANDING_OFF\n");
+		break;
+
+	case CAMERA_ANTIBANDING_60HZ:
+		CDBG("--CAMERA--CAMERA_ANTIBANDING_60HZ\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_antibanding_60z_tbl);
+		break;
+
+	case CAMERA_ANTIBANDING_50HZ:
+		CDBG("--CAMERA--CAMERA_ANTIBANDING_50HZ\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_antibanding_50z_tbl);
+		break;
+
+	case CAMERA_ANTIBANDING_AUTO:
+		CDBG("--CAMERA--CAMERA_ANTIBANDING_AUTO\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_antibanding_auto_tbl);
+		break;
+
+	default:
+		CDBG("--CAMERA--CAMERA_ANTIBANDING_ERROR COMMAND\n");
+		break;
+	}
+
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+	return rc;
+}
+
+static long ov5640_set_exposure_mode(int mode)
+{
+	long rc = 0;
+	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
+	CDBG("--CAMERA-- %s ...mode = %d\n", __func__ , mode);
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+	return rc;
+}
+
+static int32_t ov5640_lens_shading_enable(uint8_t is_enable)
+{
+	int32_t rc = 0;
+	CDBG("--CAMERA--%s: ...(Start). enable = %d\n",  __func__, is_enable);
+
+	if (is_enable) {
+		CDBG("%s: enable~!!\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_lens_shading_on_tbl);
+	} else {
+		CDBG("%s: disable~!!\n", __func__);
+		rc = OV5640CORE_WRITEPREG(ov5640_lens_shading_off_tbl);
+	}
+	CDBG("--CAMERA--%s: ...(End). rc = %d\n", __func__, rc);
+	return rc;
+}
+
+static int ov5640_set_sensor_mode(int mode, int res)
+{
+	int rc = 0;
+
+	CDBG("--CAMERA-- ov5640_set_sensor_mode mode = %d, res = %d\n",
+			mode, res);
+
+	switch (mode) {
+	case SENSOR_PREVIEW_MODE:
+		CDBG("--CAMERA-- SENSOR_PREVIEW_MODE\n");
+		rc = ov5640_setting(S_UPDATE_PERIODIC, S_RES_PREVIEW);
+		break;
+
+	case SENSOR_SNAPSHOT_MODE:
+		CDBG("--CAMERA-- SENSOR_SNAPSHOT_MODE\n");
+		rc = ov5640_setting(S_UPDATE_PERIODIC, S_RES_CAPTURE);
+		break;
+
+	case SENSOR_RAW_SNAPSHOT_MODE:
+		CDBG("--CAMERA-- SENSOR_RAW_SNAPSHOT_MODE\n");
+		rc = ov5640_setting(S_UPDATE_PERIODIC, S_RES_CAPTURE);
+		break;
+
+	default:
+		CDBG("--CAMERA--ov5640_set_sensor_mode no support\n");
+		rc = -EINVAL;
+		break;
+	}
+
+	return rc;
+}
+
+static int ov5640_set_wb_oem(uint8_t param)
+{
+	int rc = 0;
+	unsigned int tmp2;
+
+	CDBG("[kylin] %s \r\n", __func__);
+
+	ov5640_i2c_read_byte(ov5640_client->addr, 0x350b, &tmp2);
+	CDBG("--CAMERA-- GAIN VALUE : %x\n", tmp2);
+
+	switch (param) {
+	case CAMERA_WB_AUTO:
+
+		CDBG("--CAMERA--CAMERA_WB_AUTO\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_wb_def);
+		break;
+
+	case CAMERA_WB_CUSTOM:
+		CDBG("--CAMERA--CAMERA_WB_CUSTOM\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_wb_custom);
+		break;
+	case CAMERA_WB_INCANDESCENT:
+		CDBG("--CAMERA--CAMERA_WB_INCANDESCENT\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_wb_inc);
+		break;
+	case CAMERA_WB_DAYLIGHT:
+		CDBG("--CAMERA--CAMERA_WB_DAYLIGHT\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_wb_daylight);
+		break;
+	case CAMERA_WB_CLOUDY_DAYLIGHT:
+		CDBG("--CAMERA--CAMERA_WB_CLOUDY_DAYLIGHT\n");
+		rc = OV5640CORE_WRITEPREG(ov5640_wb_cloudy);
+		break;
+	default:
+		break;
+	}
+	return rc;
+}
+
+static int ov5640_set_touchaec(uint32_t x, uint32_t y)
+{
+	uint8_t aec_arr[8] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11};
+	int idx = 0;
+	int i;
+
+	CDBG("[kylin] %s x: %d ,y: %d\r\n", __func__ , x, y);
+	idx = x / 2 + y * 2;
+	CDBG("[kylin] idx: %d\r\n", idx);
+
+	if (x % 2 == 0)
+		aec_arr[idx] = 0x10 | 0x0a;
+	else
+		aec_arr[idx] = 0x01 | 0xa0;
+
+	for (i = 0; i < 8; i++) {
+		CDBG("write : %x val : %x ", 0x5688 + i, aec_arr[i]);
+		ov5640_i2c_write(ov5640_client->addr, 0x5688 + i,
+				aec_arr[i], 10);
+	}
+
+	return 1;
+}
+
+static int ov5640_set_exposure_compensation(int compensation)
+{
+	long rc = 0;
+
+	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
+
+	CDBG("--CAMERA-- %s ...exposure_compensation = %d\n", __func__ ,
+			    compensation);
+
+	switch (compensation) {
+	case CAMERA_EXPOSURE_COMPENSATION_LV0:
+		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV0\n");
+		rc = OV5640CORE_WRITEPREG(
+				ov5640_exposure_compensation_lv0_tbl);
+		break;
+
+	case CAMERA_EXPOSURE_COMPENSATION_LV1:
+		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV1\n");
+		rc = OV5640CORE_WRITEPREG(
+				ov5640_exposure_compensation_lv1_tbl);
+		break;
+
+	case CAMERA_EXPOSURE_COMPENSATION_LV2:
+		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV2\n");
+		rc = OV5640CORE_WRITEPREG(
+			    ov5640_exposure_compensation_lv2_default_tbl);
+		break;
+
+	case CAMERA_EXPOSURE_COMPENSATION_LV3:
+		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV3\n");
+		rc = OV5640CORE_WRITEPREG(
+				ov5640_exposure_compensation_lv3_tbl);
+		break;
+
+	case CAMERA_EXPOSURE_COMPENSATION_LV4:
+		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV3\n");
+		rc = OV5640CORE_WRITEPREG(
+				ov5640_exposure_compensation_lv4_tbl);
+		break;
+
+	default:
+		CDBG("--CAMERA--ERROR CAMERA_EXPOSURE_COMPENSATION\n");
+		break;
+	}
+
+	CDBG("--CAMERA-- %s ...(End)\n", __func__);
+
+	return rc;
+}
+
+static int ov5640_sensor_start_af(void)
+{
+	int i;
+	unsigned int af_st = 0;
+	unsigned int af_ack = 0;
+	unsigned int tmp = 0;
+	int rc = 0;
+
+	CDBG("--CAMERA-- %s (Start...)\n", __func__);
+
+	ov5640_i2c_read_byte(ov5640_client->addr,
+			OV5640_CMD_FW_STATUS, &af_st);
+	CDBG("--CAMERA-- %s af_st = %d\n", __func__, af_st);
+
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_ACK, 0x01, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_MAIN, 0x03, 10);
+
+	for (i = 0; i < 50; i++) {
+		ov5640_i2c_read_byte(ov5640_client->addr,
+				OV5640_CMD_ACK, &af_ack);
+		if (af_ack == 0)
+			break;
+		msleep(50);
+	}
+	CDBG("--CAMERA-- %s af_ack = 0x%x\n", __func__, af_ack);
+
+	ov5640_i2c_read_byte(ov5640_client->addr, OV5640_CMD_FW_STATUS,
+			&af_st);
+	CDBG("--CAMERA-- %s af_st = %d\n", __func__, af_st);
+
+	if (af_st == 0x10) {
+		CDBG("--CAMERA-- %s AF ok and release AF setting~!!\n",
+				__func__);
+	} else {
+		CDBG("--CAMERA-- %s AF not ready!!\n", __func__);
+	}
+
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_ACK, 0x01, 10);
+	ov5640_i2c_write(ov5640_client->addr, OV5640_CMD_MAIN, 0x07, 10);
+
+	for (i = 0; i < 70; i++) {
+		ov5640_i2c_read_byte(ov5640_client->addr, OV5640_CMD_ACK,
+				&af_ack);
+		if (af_ack == 0)
+			break;
+		msleep(25);
+	}
+
+	ov5640_i2c_read_byte(ov5640_client->addr, OV5640_CMD_PARA0, &tmp);
+	CDBG("0x3024 = %x\n", tmp);
+	rc = ((tmp == 0) ? 1 : 0);
+
+	ov5640_i2c_read_byte(ov5640_client->addr, OV5640_CMD_PARA1, &tmp);
+	CDBG("0x3025 = %x\n", tmp);
+	rc = ((tmp == 0) ? 1 : 0);
+
+	ov5640_i2c_read_byte(ov5640_client->addr, OV5640_CMD_PARA2, &tmp);
+	CDBG("0x3026 = %x\n", tmp);
+	rc = ((tmp == 0) ? 1 : 0);
+
+	ov5640_i2c_read_byte(ov5640_client->addr, OV5640_CMD_PARA3, &tmp);
+	CDBG("0x3027 = %x\n", tmp);
+	rc = ((tmp == 0) ? 1 : 0) ;
+
+	ov5640_i2c_read_byte(ov5640_client->addr, OV5640_CMD_PARA4, &tmp);
+	CDBG("0x3028 = %x\n", tmp);
+	rc = ((tmp == 0) ? 1 : 0) ;
+
+	CDBG("--CAMERA-- %s rc = %d(End...)\n", __func__, rc);
+	return rc;
+}
+
+static int ov5640_sensor_config(void __user *argp)
+{
+	struct sensor_cfg_data cdata;
+	long rc = 0;
+
+	if (copy_from_user(&cdata, (void *)argp,
+				sizeof(struct sensor_cfg_data)))
+		return -EFAULT;
+
+	CDBG("--CAMERA-- %s %d\n", __func__, cdata.cfgtype);
+
+	mutex_lock(&ov5640_mutex);
+
+	switch (cdata.cfgtype) {
+	case CFG_SET_MODE:
+		rc = ov5640_set_sensor_mode(cdata.mode, cdata.rs);
+		break;
+
+	case CFG_SET_EFFECT:
+		CDBG("--CAMERA-- CFG_SET_EFFECT mode=%d,"
+				"effect = %d !!\n", cdata.mode,
+				cdata.cfg.effect);
+		rc = ov5640_set_effect(cdata.mode, cdata.cfg.effect);
+		break;
+
+	case CFG_START:
+		CDBG("--CAMERA-- CFG_START (Not Support) !!\n");
+		/* Not Support */
+		break;
+
+	case CFG_PWR_UP:
+		CDBG("--CAMERA-- CFG_PWR_UP (Not Support) !!\n");
+		/* Not Support */
+		break;
+
+	case CFG_PWR_DOWN:
+		CDBG("--CAMERA-- CFG_PWR_DOWN (Not Support)\n");
+		ov5640_power_off();
+		break;
+
+	case CFG_SET_DEFAULT_FOCUS:
+		CDBG("--CAMERA-- CFG_SET_DEFAULT_FOCUS (Not Implement) !!\n");
+		break;
+
+	case CFG_MOVE_FOCUS:
+		CDBG("--CAMERA-- CFG_MOVE_FOCUS (Not Implement) !!\n");
+		break;
+
+	case CFG_SET_BRIGHTNESS:
+		CDBG("--CAMERA-- CFG_SET_BRIGHTNESS  !!\n");
+		rc = ov5640_set_brightness(cdata.cfg.brightness);
+		break;
+
+	case CFG_SET_CONTRAST:
+		CDBG("--CAMERA-- CFG_SET_CONTRAST  !!\n");
+		rc = ov5640_set_contrast(cdata.cfg.contrast);
+		break;
+
+	case CFG_SET_EXPOSURE_MODE:
+		CDBG("--CAMERA-- CFG_SET_EXPOSURE_MODE !!\n");
+		rc = ov5640_set_exposure_mode(cdata.cfg.ae_mode);
+		break;
+
+	case CFG_SET_ANTIBANDING:
+		CDBG("--CAMERA-- CFG_SET_ANTIBANDING antibanding = %d!!\n",
+				cdata.cfg.antibanding);
+		rc = ov5640_set_antibanding(cdata.cfg.antibanding);
+		break;
+
+	case CFG_SET_LENS_SHADING:
+		CDBG("--CAMERA-- CFG_SET_LENS_SHADING !!\n");
+		rc = ov5640_lens_shading_enable(
+				cdata.cfg.lens_shading);
+		break;
+
+	case CFG_SET_SATURATION:
+		CDBG("--CAMERA-- CFG_SET_SATURATION !!\n");
+		rc = ov5640_set_saturation(cdata.cfg.saturation);
+		break;
+
+	case CFG_SET_SHARPNESS:
+		CDBG("--CAMERA-- CFG_SET_SHARPNESS !!\n");
+		rc = ov5640_set_sharpness(cdata.cfg.sharpness);
+		break;
+
+	case CFG_SET_WB:
+		CDBG("--CAMERA-- CFG_SET_WB!!\n");
+		ov5640_set_wb_oem(cdata.cfg.wb_val);
+		rc = 0 ;
+		break;
+
+	case CFG_SET_TOUCHAEC:
+		CDBG("--CAMERA-- CFG_SET_TOUCHAEC!!\n");
+		ov5640_set_touchaec(cdata.cfg.aec_cord.x,
+				cdata.cfg.aec_cord.y);
+		rc = 0 ;
+		break;
+
+	case CFG_SET_AUTO_FOCUS:
+		CDBG("--CAMERA-- CFG_SET_AUTO_FOCUS !\n");
+		rc = ov5640_sensor_start_af();
+		break;
+
+	case CFG_SET_AUTOFLASH:
+		CDBG("--CAMERA-- CFG_SET_AUTOFLASH !\n");
+		is_autoflash = cdata.cfg.is_autoflash;
+		CDBG("[kylin] is autoflash %d\r\n", is_autoflash);
+		rc = 0;
+		break;
+
+	case CFG_SET_EXPOSURE_COMPENSATION:
+		CDBG("--CAMERA-- CFG_SET_EXPOSURE_COMPENSATION !\n");
+		rc = ov5640_set_exposure_compensation(
+				cdata.cfg.exp_compensation);
+		break;
+
+	default:
+		CDBG("%s: Command=%d (Not Implement)!!\n", __func__,
+				cdata.cfgtype);
+		rc = -EINVAL;
+		break;
+	}
+
+	mutex_unlock(&ov5640_mutex);
+	return rc;
+}
+
+static struct i2c_driver ov5640_i2c_driver = {
+	.id_table = ov5640_i2c_id,
+	.probe  = ov5640_i2c_probe,
+	.remove = ov5640_i2c_remove,
+	.driver = {
+		.name = "ov5640",
+	},
+};
+
+static int ov5640_probe_init_gpio(const struct msm_camera_sensor_info *data)
+{
+	int rc = 0;
+
+	CDBG("--CAMERA-- %s\n", __func__);
+
+	ov5640_pwdn_gpio = data->sensor_pwd;
+	ov5640_reset_gpio = data->sensor_reset;
+	ov5640_driver_pwdn_gpio = data->vcm_pwd ;
+
+	if (data->vcm_enable)
+		gpio_direction_output(data->vcm_pwd, 1);
+
+	gpio_direction_output(data->sensor_reset, 1);
+	gpio_direction_output(data->sensor_pwd, 1);
+
+	return rc;
+
+}
+
+static void ov5640_probe_free_gpio(const struct msm_camera_sensor_info *data)
+{
+	gpio_free(ov5640_pwdn_gpio);
+	gpio_free(ov5640_reset_gpio);
+
+	if (data->vcm_enable) {
+		gpio_free(ov5640_driver_pwdn_gpio);
+		ov5640_driver_pwdn_gpio = 0xFF ;
+	}
+
+	ov5640_pwdn_gpio	= 0xFF;
+	ov5640_reset_gpio	= 0xFF;
+}
+
+static int ov5640_sensor_probe(const struct msm_camera_sensor_info *info,
+		struct msm_sensor_ctrl *s)
+{
+	int rc = -ENOTSUPP;
+
+	CDBG("--CAMERA-- %s (Start...)\n", __func__);
+	rc = i2c_add_driver(&ov5640_i2c_driver);
+	CDBG("--CAMERA-- i2c_add_driver ret:0x%x,ov5640_client=0x%x\n",
+			rc, (unsigned int)ov5640_client);
+	if ((rc < 0) || (ov5640_client == NULL)) {
+		CDBG("--CAMERA-- i2c_add_driver FAILS!!\n");
+		return rc;
+	}
+
+	rc = ov5640_probe_init_gpio(info);
+	if (rc < 0)
+		return rc;
+
+	ov5640_power_off();
+
+	/* SENSOR NEED MCLK TO DO I2C COMMUNICTION, OPEN CLK FIRST*/
+	msm_camio_clk_rate_set(24000000);
+
+	msleep(20);
+
+	ov5640_power_on();
+	ov5640_power_reset();
+
+	rc = ov5640_probe_readID(info);
+
+	if (rc < 0) {
+		CDBG("--CAMERA--ov5640_probe_readID Fail !!~~~~!!\n");
+		CDBG("--CAMERA-- %s, unregister\n", __func__);
+		i2c_del_driver(&ov5640_i2c_driver);
+		ov5640_power_off();
+		ov5640_probe_free_gpio(info);
+		return rc;
+	}
+
+	s->s_init		= ov5640_sensor_open_init;
+	s->s_release		= ov5640_sensor_release;
+	s->s_config		= ov5640_sensor_config;
+	s->s_camera_type	= BACK_CAMERA_2D;
+	s->s_mount_angle	= info->sensor_platform_info->mount_angle;
+
+	ov5640_power_off();
+
+	CDBG("--CAMERA-- %s (End...)\n", __func__);
+	return rc;
+}
+
+static int ov5640_i2c_probe(struct i2c_client *client,
+		const struct i2c_device_id *id)
+{
+	CDBG("--CAMERA-- %s ... (Start...)\n", __func__);
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CDBG("--CAMERA--i2c_check_functionality failed\n");
+		return -ENOMEM;
+	}
+
+	ov5640_sensorw = kzalloc(sizeof(struct ov5640_work), GFP_KERNEL);
+	if (!ov5640_sensorw) {
+		CDBG("--CAMERA--kzalloc failed\n");
+		return -ENOMEM;
+	}
+
+	i2c_set_clientdata(client, ov5640_sensorw);
+	ov5640_init_client(client);
+	ov5640_client = client;
+
+	CDBG("--CAMERA-- %s ... (End...)\n", __func__);
+	return 0;
+}
+
+static int __ov5640_probe(struct platform_device *pdev)
+{
+	return msm_camera_drv_start(pdev, ov5640_sensor_probe);
+}
+
+static struct platform_driver msm_camera_driver = {
+	.probe	= __ov5640_probe,
+	.driver	= {
+		.name	= "msm_camera_ov5640",
+		.owner	= THIS_MODULE,
+	},
+};
+
+static int __init ov5640_init(void)
+{
+	ov5640_i2c_buf[0] = 0x5A;
+	return platform_driver_register(&msm_camera_driver);
+}
+
+module_init(ov5640_init);
+
+MODULE_DESCRIPTION("OV5640 YUV MIPI sensor driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/video/msm/ov5640.h b/drivers/media/video/msm/ov5640.h
new file mode 100644
index 0000000..0e65329
--- /dev/null
+++ b/drivers/media/video/msm/ov5640.h
@@ -0,0 +1,2993 @@
+/* Copyright (c) 2011, Code Aurora Forum. 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 version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+
+/*
+[SENSOR]
+Sensor Model:   OV5640
+Camera Module:
+Lens Model:
+Driver IC:
+PV Size         = 640 x 480
+Cap Size        = 2592 x 1944
+Output Format   = YUYV
+MCLK Speed      = 24M
+PV DVP_PCLK     = 28M
+Cap DVP_PCLK    = 56M
+PV Frame Rate   = 30fps
+Cap Frame Rate  = 7.5fps
+I2C Slave ID    = 0x78
+I2C Mode        = 16Addr, 8Data
+*/
+
+#ifndef CAMSENSOR_OV5640
+#define CAMSENSOR_OV5640
+
+#define INVMASK(v)  (0xff-v)
+#define OV5640CORE_WRITEPREG(PTBL)	ov5640_writepregs(PTBL,\
+					sizeof(PTBL)/sizeof(PTBL[0]))
+
+/* OV SENSOR SCCB */
+struct ov5640_sensor {
+	uint16_t addr;
+	uint8_t data;
+	uint8_t mask;
+};
+
+/* Auto Focus Command */
+#define OV5640_CMD_MAIN 0x3022
+#define OV5640_CMD_ACK 0x3023
+#define OV5640_CMD_PARA0 0x3024
+#define OV5640_CMD_PARA1 0x3025
+#define OV5640_CMD_PARA2 0x3026
+#define OV5640_CMD_PARA3 0x3027
+#define OV5640_CMD_PARA4 0x3028
+#define OV5640_CMD_FW_STATUS 0x3029
+
+/* Sensor ID */
+#define OV5640_SENSOR_ID 0x5640
+
+#define capture_framerate 750     /* 7.5fps capture frame rate */
+#define g_preview_frameRate 3000  /* 30fps preview frame rate */
+
+struct ov5640_sensor ov5640_init_tbl[] = {
+	{0x3008, 0x42},
+	{0x3103, 0x03},
+	{0x3017, 0x00},
+	{0x3018, 0x00},
+	{0x3034, 0x18},
+	{0x3035, 0x14},
+	{0x3036, 0x38},
+	{0x3037, 0x13},
+	{0x3108, 0x01},
+	{0x3630, 0x36},
+	{0x3631, 0x0e},
+	{0x3632, 0xe2},
+	{0x3633, 0x12},
+	{0x3621, 0xe0},
+	{0x3704, 0xa0},
+	{0x3703, 0x5a},
+	{0x3715, 0x78},
+	{0x3717, 0x01},
+	{0x370b, 0x60},
+	{0x3705, 0x1a},
+	{0x3905, 0x02},
+	{0x3906, 0x10},
+	{0x3901, 0x0a},
+	{0x3731, 0x12},
+	{0x3600, 0x08},
+	{0x3601, 0x33},
+	{0x302d, 0x60},
+	{0x3620, 0x52},
+	{0x371b, 0x20},
+	{0x471c, 0x50},
+	{0x3a13, 0x43},
+	{0x3a18, 0x00},
+	{0x3a19, 0xf8},
+	{0x3635, 0x13},
+	{0x3636, 0x03},
+	{0x3634, 0x40},
+	{0x3622, 0x01},
+	{0x3c01, 0x34},
+	{0x3c04, 0x28},
+	{0x3c05, 0x98},
+	{0x3c06, 0x00},
+	{0x3c07, 0x08},
+	{0x3c08, 0x00},
+	{0x3c09, 0x1c},
+	{0x3c0a, 0x9c},
+	{0x3c0b, 0x40},
+	{0x3820, 0x41},
+	{0x3821, 0x07},
+	{0x3814, 0x31},
+	{0x3815, 0x31},
+	{0x3800, 0x00},
+	{0x3801, 0x00},
+	{0x3802, 0x00},
+	{0x3803, 0x04},
+	{0x3804, 0x0a},
+	{0x3805, 0x3f},
+	{0x3806, 0x07},
+	{0x3807, 0x9b},
+	{0x3808, 0x02},
+	{0x3809, 0x80},
+	{0x380a, 0x01},
+	{0x380b, 0xe0},
+	{0x380c, 0x07},
+	{0x380d, 0x68},
+	{0x380e, 0x03},
+	{0x380f, 0xd8},
+	{0x3810, 0x00},
+	{0x3811, 0x10},
+	{0x3812, 0x00},
+	{0x3813, 0x06},
+	{0x3618, 0x00},
+	{0x3612, 0x29},
+	{0x3708, 0x64},
+	{0x3709, 0x52},
+	{0x370c, 0x03},
+	{0x3a02, 0x03},
+	{0x3a03, 0xd8},
+	{0x3a08, 0x01},
+	{0x3a09, 0x27},
+	{0x3a0a, 0x00},
+	{0x3a0b, 0xf6},
+	{0x3a0e, 0x03},
+	{0x3a0d, 0x04},
+	{0x3a14, 0x03},
+	{0x3a15, 0xd8},
+	{0x4001, 0x02},
+	{0x4004, 0x02},
+	{0x3000, 0x00},
+	{0x3002, 0x1c},
+	{0x3004, 0xff},
+	{0x3006, 0xc3},
+	{0x300e, 0x45},
+	{0x302e, 0x08},
+	{0x4300, 0x30},
+	{0x501f, 0x00},
+	{0x4713, 0x03},
+	{0x4407, 0x04},
+	{0x440e, 0x00},
+	{0x460b, 0x35},
+	{0x460c, 0x22},
+	{0x4837, 0x44},
+	{0x3824, 0x02},
+	{0x5000, 0xa7},
+	{0x5001, 0xa3},
+	{0x5180, 0xff},
+	{0x5181, 0xf2},
+	{0x5182, 0x00},
+	{0x5183, 0x14},
+	{0x5184, 0x25},
+	{0x5185, 0x24},
+	{0x5186, 0x09},
+	{0x5187, 0x09},
+	{0x5188, 0x09},
+	{0x5189, 0x75},
+	{0x518a, 0x54},
+	{0x518b, 0xe0},
+	{0x518c, 0xb2},
+	{0x518d, 0x42},
+	{0x518e, 0x3d},
+	{0x518f, 0x56},
+	{0x5190, 0x46},
+	{0x5191, 0xf8},
+	{0x5192, 0x04},
+	{0x5193, 0x70},
+	{0x5194, 0xf0},
+	{0x5195, 0xf0},
+	{0x5196, 0x03},
+	{0x5197, 0x01},
+	{0x5198, 0x04},
+	{0x5199, 0x12},
+	{0x519a, 0x04},
+	{0x519b, 0x00},
+	{0x519c, 0x06},
+	{0x519d, 0x82},
+	{0x519e, 0x38},
+	{0x5381, 0x1e},
+	{0x5382, 0x5b},
+	{0x5383, 0x08},
+	{0x5384, 0x0a},
+	{0x5385, 0x7e},
+	{0x5386, 0x88},
+	{0x5387, 0x7c},
+	{0x5388, 0x6c},
+	{0x5389, 0x10},
+	{0x538a, 0x01},
+	{0x538b, 0x98},
+	{0x5300, 0x08},
+	{0x5301, 0x30},
+	{0x5302, 0x10},
+	{0x5303, 0x00},
+	{0x5304, 0x08},
+	{0x5305, 0x30},
+	{0x5306, 0x08},
+	{0x5307, 0x16},
+	{0x5309, 0x08},
+	{0x530a, 0x30},
+	{0x530b, 0x04},
+	{0x530c, 0x06},
+	{0x5480, 0x01},
+	{0x5481, 0x08},
+	{0x5482, 0x14},
+	{0x5483, 0x28},
+	{0x5484, 0x51},
+	{0x5485, 0x65},
+	{0x5486, 0x71},
+	{0x5487, 0x7d},
+	{0x5488, 0x87},
+	{0x5489, 0x91},
+	{0x548a, 0x9a},
+	{0x548b, 0xaa},
+	{0x548c, 0xb8},
+	{0x548d, 0xcd},
+	{0x548e, 0xdd},
+	{0x548f, 0xea},
+	{0x5490, 0x1d},
+	{0x5580, 0x02},
+	{0x5583, 0x40},
+	{0x5584, 0x10},
+	{0x5589, 0x10},
+	{0x558a, 0x00},
+	{0x558b, 0xf8},
+	{0x5800, 0x23},
+	{0x5801, 0x14},
+	{0x5802, 0x0f},
+	{0x5803, 0x0f},
+	{0x5804, 0x12},
+	{0x5805, 0x26},
+	{0x5806, 0x0c},
+	{0x5807, 0x08},
+	{0x5808, 0x05},
+	{0x5809, 0x05},
+	{0x580a, 0x08},
+	{0x580b, 0x0d},
+	{0x580c, 0x08},
+	{0x580d, 0x03},
+	{0x580e, 0x00},
+	{0x580f, 0x00},
+	{0x5810, 0x03},
+	{0x5811, 0x09},
+	{0x5812, 0x07},
+	{0x5813, 0x03},
+	{0x5814, 0x00},
+	{0x5815, 0x01},
+	{0x5816, 0x03},
+	{0x5817, 0x08},
+	{0x5818, 0x0d},
+	{0x5819, 0x08},
+	{0x581a, 0x05},
+	{0x581b, 0x06},
+	{0x581c, 0x08},
+	{0x581d, 0x0e},
+	{0x581e, 0x29},
+	{0x581f, 0x17},
+	{0x5820, 0x11},
+	{0x5821, 0x11},
+	{0x5822, 0x15},
+	{0x5823, 0x28},
+	{0x5824, 0x46},
+	{0x5825, 0x26},
+	{0x5826, 0x08},
+	{0x5827, 0x26},
+	{0x5828, 0x64},
+	{0x5829, 0x26},
+	{0x582a, 0x24},
+	{0x582b, 0x22},
+	{0x582c, 0x24},
+	{0x582d, 0x24},
+	{0x582e, 0x06},
+	{0x582f, 0x22},
+	{0x5830, 0x40},
+	{0x5831, 0x42},
+	{0x5832, 0x24},
+	{0x5833, 0x26},
+	{0x5834, 0x24},
+	{0x5835, 0x22},
+	{0x5836, 0x22},
+	{0x5837, 0x26},
+	{0x5838, 0x44},
+	{0x5839, 0x24},
+	{0x583a, 0x26},
+	{0x583b, 0x28},
+	{0x583c, 0x42},
+	{0x583d, 0xce},
+	{0x5025, 0x00},
+	{0x3a0f, 0x30},
+	{0x3a10, 0x28},
+	{0x3a1b, 0x30},
+	{0x3a1e, 0x26},
+	{0x3a11, 0x60},
+	{0x3a1f, 0x14},
+	{0x3008, 0x02},
+};
+
+struct ov5640_sensor ov5640_init_iq_tbl[] = {
+/* Lens correction */
+/* OV5640 LENC setting */
+	{0x5800, 0x3f},
+	{0x5801, 0x20},
+	{0x5802, 0x1a},
+	{0x5803, 0x1a},
+	{0x5804, 0x23},
+	{0x5805, 0x3f},
+	{0x5806, 0x11},
+	{0x5807, 0x0c},
+	{0x5808, 0x09},
+	{0x5809, 0x08},
+	{0x580a, 0x0d},
+	{0x580b, 0x12},
+	{0x580c, 0x0d},
+	{0x580d, 0x04},
+	{0x580e, 0x00},
+	{0x580f, 0x00},
+	{0x5810, 0x05},
+	{0x5811, 0x0d},
+	{0x5812, 0x0d},
+	{0x5813, 0x04},
+	{0x5814, 0x00},
+	{0x5815, 0x00},
+	{0x5816, 0x04},
+	{0x5817, 0x0d},
+	{0x5818, 0x13},
+	{0x5819, 0x0d},
+	{0x581a, 0x08},
+	{0x581b, 0x08},
+	{0x581c, 0x0c},
+	{0x581d, 0x13},
+	{0x581e, 0x3f},
+	{0x581f, 0x1f},
+	{0x5820, 0x1b},
+	{0x5821, 0x1c},
+	{0x5822, 0x23},
+	{0x5823, 0x3f},
+	{0x5824, 0x6a},
+	{0x5825, 0x06},
+	{0x5826, 0x08},
+	{0x5827, 0x06},
+	{0x5828, 0x2a},
+	{0x5829, 0x08},
+	{0x582a, 0x24},
+	{0x582b, 0x24},
+	{0x582c, 0x24},
+	{0x582d, 0x08},
+	{0x582e, 0x08},
+	{0x582f, 0x22},
+	{0x5830, 0x40},
+	{0x5831, 0x22},
+	{0x5832, 0x06},
+	{0x5833, 0x08},
+	{0x5834, 0x24},
+	{0x5835, 0x24},
+	{0x5836, 0x04},
+	{0x5837, 0x0a},
+	{0x5838, 0x86},
+	{0x5839, 0x08},
+	{0x583a, 0x28},
+	{0x583b, 0x28},
+	{0x583c, 0x66},
+	{0x583d, 0xce},
+/* AEC */
+	{0x3a0f, 0x38},
+	{0x3a10, 0x30},
+	{0x3a11, 0x61},
+	{0x3a1b, 0x38},
+	{0x3a1e, 0x30},
+	{0x3a1f, 0x10},
+	/* AWB */
+	{0x5180, 0xff},
+	{0x5181, 0xf2},
+	{0x5182, 0x00},
+	{0x5183, 0x14},
+	{0x5184, 0x25},
+	{0x5185, 0x24},
+	{0x5186, 0x09},
+	{0x5187, 0x09},
+	{0x5188, 0x09},
+	{0x5189, 0x88},
+	{0x518a, 0x54},
+	{0x518b, 0xee},
+	{0x518c, 0xb2},
+	{0x518d, 0x50},
+	{0x518e, 0x34},
+	{0x518f, 0x6b},
+	{0x5190, 0x46},
+	{0x5191, 0xf8},
+	{0x5192, 0x04},
+	{0x5193, 0x70},
+	{0x5194, 0xf0},
+	{0x5195, 0xf0},
+	{0x5196, 0x03},
+	{0x5197, 0x01},
+	{0x5198, 0x04},
+	{0x5199, 0x6c},
+	{0x519a, 0x04},
+	{0x519b, 0x00},
+	{0x519c, 0x09},
+	{0x519d, 0x2b},
+	{0x519e, 0x38},
+
+/* UV Adjust Auto Mode */
+	{0x5580, 0x02},	/* 02 ;Sat enable */
+	{0x5588, 0x01},	/*40 ;enable UV adj */
+	{0x5583, 0x40},	/*	;offset high */
+	{0x5584, 0x18},	/*	;offset low */
+	{0x5589, 0x18},	/*	;gth1	*/
+	{0x558a, 0x00},
+	{0x358b, 0xf8},	/*	;gth2 */
+};
+
+struct ov5640_sensor ov5640_preview_tbl[] = {
+/* @@ MIPI_2lane_5M to vga(YUV) 30fps 99 640 480 98 0 0 */
+	{0x3503, 0x00}, /* enable AE back from capture to preview */
+	{0x3035, 0x14},
+	{0x3036, 0x38},
+	{0x3820, 0x41},
+	{0x3821, 0x07},
+	{0x3814, 0x31},
+	{0x3815, 0x31},
+	{0x3803, 0x04},
+	{0x3807, 0x9b},
+	{0x3808, 0x02},
+	{0x3809, 0x80},
+	{0x380a, 0x01},
+	{0x380b, 0xe0},
+	{0x380c, 0x07},
+	{0x380d, 0x68},
+	{0x380e, 0x03},
+	{0x380f, 0xd8},
+	{0x3813, 0x06},
+	{0x3618, 0x00},
+	{0x3612, 0x29},
+	{0x3708, 0x64},
+	{0x3709, 0x52},
+	{0x370c, 0x03},
+	{0x5001, 0xa3},
+	{0x4004, 0x02},
+	{0x4005, 0x18},
+	{0x4837, 0x44},
+	{0x4713, 0x03},
+	{0x4407, 0x04},
+	{0x460b, 0x35},
+	{0x460c, 0x22},
+	{0x3824, 0x02},
+};
+
+struct ov5640_sensor ov5640_capture_tbl[] = {
+/* @@ MIPI_2lane_5M(YUV) 7.5/15fps 99 2592 1944 98 0 0 */
+	{0x3035, 0x21}, /* 11 */
+	{0x3036, 0x54},
+	{0x3820, 0x40},
+	{0x3821, 0x06},
+	{0x3814, 0x11},
+	{0x3815, 0x11},
+	{0x3803, 0x00},
+	{0x3807, 0x9f},
+	{0x3808, 0x0a},
+	{0x3809, 0x20},
+	{0x380a, 0x07},
+	{0x380b, 0x98},
+	{0x380c, 0x0b},
+	{0x380d, 0x1c},
+	{0x380e, 0x07},
+	{0x380f, 0xb0},
+	{0x3813, 0x04},
+	{0x3618, 0x04},
+	{0x3612, 0x2b},
+	{0x3708, 0x21},
+	{0x3709, 0x12},
+	{0x370c, 0x00},
+	{0x5001, 0x83},
+	{0x4004, 0x06},
+	{0x4005, 0x1a},
+	{0x4837, 0x15}, /* 0a */
+	{0x4713, 0x02},
+	{0x4407, 0x0c},
+	{0x460b, 0x37},
+	{0x460c, 0x20},
+	{0x3824, 0x01},
+};
+
+/* Contrast */
+
+struct ov5640_sensor ov5640_contrast_lv0_tbl[] = {
+/* Contrast -4 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)}, /* Enable BIT2 for contrast/brightness
+					  control*/
+	{0x5586, 0x10},                /* Gain */
+	{0x5585, 0x10},                /* Offset */
+	{0x5588, 0x00, INVMASK(0x04)}, /* Offset sign */
+};
+
+struct ov5640_sensor ov5640_contrast_lv1_tbl[] = {
+/* Contrast -3 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)}, /* Enable BIT2 for contrast/brightness
+					  control */
+	{0x5586, 0x14},                /* Gain */
+	{0x5585, 0x14},                /* Offset */
+	{0x5588, 0x00, INVMASK(0x04)}, /* Offset sign */
+};
+
+struct ov5640_sensor ov5640_contrast_lv2_tbl[] = {
+/* Contrast -2 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)}, /* Enable BIT2 for contrast/brightness
+					  control */
+	{0x5586, 0x18},                /* Gain */
+	{0x5585, 0x18},                /* Offset */
+	{0x5588, 0x00, INVMASK(0x04)}, /* Offset sign */
+};
+
+struct ov5640_sensor ov5640_contrast_lv3_tbl[] = {
+/* Contrast -1 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5586, 0x1c},
+	{0x5585, 0x1c},
+	{0x5588, 0x00, INVMASK(0x04)},
+};
+
+struct ov5640_sensor ov5640_contrast_default_lv4_tbl[] = {
+/* Contrast (Default) */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5586, 0x20},
+	{0x5585, 0x00},
+	{0x5588, 0x00, INVMASK(0x04)},
+};
+
+struct ov5640_sensor ov5640_contrast_lv5_tbl[] = {
+/* Contrast +1 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5586, 0x24},
+	{0x5585, 0x10},
+	{0x5588, 0x00, INVMASK(0x04)},
+};
+
+struct ov5640_sensor ov5640_contrast_lv6_tbl[] = {
+/* Contrast +2 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5586, 0x28},
+	{0x5585, 0x18},
+	{0x5588, 0x00, INVMASK(0x04)},
+};
+
+struct ov5640_sensor ov5640_contrast_lv7_tbl[] = {
+/* Contrast +3 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5586, 0x2c},
+	{0x5585, 0x1c},
+	{0x5588, 0x00, INVMASK(0x04)},
+};
+
+struct ov5640_sensor ov5640_contrast_lv8_tbl[] = {
+/* Contrast +4 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5586, 0x30},
+	{0x5585, 0x20},
+	{0x5588, 0x00, INVMASK(0x04)},
+};
+
+/* Sharpness */
+
+struct ov5640_sensor ov5640_sharpness_lv0_tbl[] = {
+/* Sharpness 0 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x00},
+};
+
+struct ov5640_sensor ov5640_sharpness_lv1_tbl[] = {
+/* Sharpness 1 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x02},
+};
+
+struct ov5640_sensor ov5640_sharpness_default_lv2_tbl[] = {
+/* Sharpness_Auto (Default) */
+	{0x5308, 0x00, INVMASK(0x40)},
+	{0x5300, 0x08},
+	{0x5301, 0x30},
+	{0x5302, 0x10},
+	{0x5303, 0x00},
+	{0x5309, 0x08},
+	{0x530a, 0x30},
+	{0x530b, 0x04},
+	{0x530c, 0x06},
+};
+
+struct ov5640_sensor ov5640_sharpness_lv3_tbl[] = {
+/* Sharpness 3 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x08},
+};
+
+struct ov5640_sensor ov5640_sharpness_lv4_tbl[] = {
+/* Sharpness 4 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x0c},
+};
+
+struct ov5640_sensor ov5640_sharpness_lv5_tbl[] = {
+/* Sharpness 5 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x10},
+};
+
+struct ov5640_sensor ov5640_sharpness_lv6_tbl[] = {
+/* Sharpness 6 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x14},
+};
+
+struct ov5640_sensor ov5640_sharpness_lv7_tbl[] = {
+/* Sharpness 7 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x18},
+};
+
+struct ov5640_sensor ov5640_sharpness_lv8_tbl[] = {
+/* Sharpness 8 */
+	{0x5308, 0x40, INVMASK(0x40)},
+	{0x5302, 0x20},
+};
+
+/* Saturation */
+
+struct ov5640_sensor ov5640_saturation_lv0_tbl[] = {
+/* Saturation x0.25 */
+	{0x5001, 0x83, INVMASK(0x80)},  /* SDE_En */
+	{0x5583, 0x00},                 /* Saturaion gain in U */
+	{0x5584, 0x00},                 /* Saturation gain in V */
+	{0x5580, 0x02, INVMASK(0x02)},  /* Saturation enable */
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_lv1_tbl[] = {
+/* Saturation x0.5 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x10},
+	{0x5584, 0x10},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_lv2_tbl[] = {
+/* Saturation x0.75 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x20},
+	{0x5584, 0x20},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_lv3_tbl[] = {
+/* Saturation x0.75 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x30},
+	{0x5584, 0x30},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_default_lv4_tbl[] = {
+/* Saturation x1 (Default) */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x40},
+	{0x5584, 0x40},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_lv5_tbl[] = {
+/* Saturation x1.25 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x50},
+	{0x5584, 0x50},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_lv6_tbl[] = {
+/* Saturation x1.5 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x60},
+	{0x5584, 0x60},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_lv7_tbl[] = {
+/* Saturation x1.25 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x70},
+	{0x5584, 0x70},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+struct ov5640_sensor ov5640_saturation_lv8_tbl[] = {
+/* Saturation x1.5 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5583, 0x80},
+	{0x5584, 0x80},
+	{0x5580, 0x02, INVMASK(0x02)},
+	{0x5588, 0x40, INVMASK(0x40)},
+};
+
+/* Brightness */
+
+struct ov5640_sensor ov5640_brightness_lv0_tbl[] = {
+/* Brightness -4 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x40},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x08, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_lv1_tbl[] = {
+/* Brightness -3 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x30},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x08, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_lv2_tbl[] = {
+/* Brightness -2 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x20},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x08, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_lv3_tbl[] = {
+/* Brightness -1 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x10},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x08, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_default_lv4_tbl[] = {
+/* Brightness 0 (Default) */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x00},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x00, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_lv5_tbl[] = {
+/* Brightness +1 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x10},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x00, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_lv6_tbl[] = {
+/* Brightness +2 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x20},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x00, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_lv7_tbl[] = {
+/* Brightness +3 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x30},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x00, INVMASK(0x08)},
+};
+
+struct ov5640_sensor ov5640_brightness_lv8_tbl[] = {
+/* Brightness +4 */
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5587, 0x40},
+	{0x5580, 0x04, INVMASK(0x04)},
+	{0x5588, 0x00, INVMASK(0x08)},
+};
+
+/* Exposure Compensation */
+struct ov5640_sensor ov5640_exposure_compensation_lv0_tbl[] = {
+	/* @@ +1.7EV */
+	{0x3a0f, 0x60},
+	{0x3a10, 0x58},
+	{0x3a11, 0xa0},
+	{0x3a1b, 0x60},
+	{0x3a1e, 0x58},
+	{0x3a1f, 0x20},
+};
+
+struct ov5640_sensor ov5640_exposure_compensation_lv1_tbl[] = {
+	/* @@ +1.0EV */
+	{0x3a0f, 0x50},
+	{0x3a10, 0x48},
+	{0x3a11, 0x90},
+	{0x3a1b, 0x50},
+	{0x3a1e, 0x48},
+	{0x3a1f, 0x20},
+};
+
+struct ov5640_sensor ov5640_exposure_compensation_lv2_default_tbl[] = {
+	/* @@ default */
+	{0x3a0f, 0x38},
+	{0x3a10, 0x30},
+	{0x3a11, 0x61},
+	{0x3a1b, 0x38},
+	{0x3a1e, 0x30},
+	{0x3a1f, 0x10},
+};
+
+struct ov5640_sensor ov5640_exposure_compensation_lv3_tbl[] = {
+	/* @@ -1.0EV */
+	{0x3a0f, 0x20},
+	{0x3a10, 0x18},
+	{0x3a11, 0x41},
+	{0x3a1b, 0x20},
+	{0x3a1e, 0x18},
+	{0x3a1f, 0x10},
+};
+
+struct ov5640_sensor ov5640_exposure_compensation_lv4_tbl[] = {
+	/* @@ -1.7EV */
+	{0x3a0f, 0x10},
+	{0x3a10, 0x08},
+	{0x3a11, 0x10},
+	{0x3a1b, 0x08},
+	{0x3a1e, 0x20},
+	{0x3a1f, 0x10},
+};
+
+/* Auto Expourse Weight */
+
+struct ov5640_sensor ov5640_ae_average_tbl[] = {
+  /* Whole Image Average */
+	{0x5688, 0x11}, /* Zone 1/Zone 0 weight */
+	{0x5689, 0x11}, /* Zone 3/Zone 2 weight */
+	{0x569a, 0x11}, /* Zone 5/Zone 4 weight */
+	{0x569b, 0x11}, /* Zone 7/Zone 6 weight */
+	{0x569c, 0x11}, /* Zone 9/Zone 8 weight */
+	{0x569d, 0x11}, /* Zone b/Zone a weight */
+	{0x569e, 0x11}, /* Zone d/Zone c weight */
+	{0x569f, 0x11}, /* Zone f/Zone e weight */
+};
+
+struct ov5640_sensor ov5640_ae_centerweight_tbl[] = {
+  /* Whole Image Center More weight */
+	{0x5688, 0x62},
+	{0x5689, 0x26},
+	{0x568a, 0xe6},
+	{0x568b, 0x6e},
+	{0x568c, 0xea},
+	{0x568d, 0xae},
+	{0x568e, 0xa6},
+	{0x568f, 0x6a},
+};
+
+/* Light Mode */
+struct ov5640_sensor ov5640_wb_def[] = {
+	{0x3406, 0x00, INVMASK(0x01)},
+};
+
+struct ov5640_sensor ov5640_wb_custom[] = {
+	{0x3406, 0x01, INVMASK(0x01)},
+	{0x3400, 0x04},
+	{0x3401, 0x58},
+	{0x3402, 0x04},
+	{0x3403, 0x00},
+	{0x3404, 0x08},
+	{0x3405, 0x40},
+};
+
+struct ov5640_sensor ov5640_wb_inc[] = {
+	{0x3406, 0x01, INVMASK(0x01)},
+	{0x3400, 0x04},
+	{0x3401, 0x88},
+	{0x3402, 0x04},
+	{0x3403, 0x00},
+	{0x3404, 0x08},
+	{0x3405, 0xb6},
+};
+
+struct ov5640_sensor ov5640_wb_daylight[] = {
+	{0x3406, 0x01, INVMASK(0x01)},
+	{0x3400, 0x07},
+	{0x3401, 0x02},
+	{0x3402, 0x04},
+	{0x3403, 0x00},
+	{0x3404, 0x05},
+	{0x3405, 0x15},
+};
+
+struct ov5640_sensor ov5640_wb_cloudy[] = {
+	{0x3406, 0x01, INVMASK(0x01)},
+	{0x3400, 0x07},
+	{0x3401, 0x88},
+	{0x3402, 0x04},
+	{0x3403, 0x00},
+	{0x3404, 0x05},
+	{0x3405, 0x00},
+};
+
+/* EFFECT */
+struct ov5640_sensor ov5640_effect_normal_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x00, INVMASK(0x78)},
+	{0x5003, 0x08},
+	{0x5583, 0x40},
+	{0x5584, 0x40},
+};
+
+struct ov5640_sensor ov5640_effect_mono_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x20, INVMASK(0x78)},
+	{0x5003, 0x08},
+	{0x5583, 0x40},
+	{0x5584, 0x40},
+};
+
+struct ov5640_sensor ov5640_effect_bw_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x18, INVMASK(0x78)},
+	{0x5003, 0x08},
+	{0x5583, 0x80},
+	{0x5584, 0x80},
+};
+
+struct ov5640_sensor ov5640_effect_bluish_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x18, INVMASK(0x78)},
+	{0x5003, 0x08},
+	{0x5583, 0xa0},
+	{0x5584, 0x40},
+};
+
+struct ov5640_sensor ov5640_effect_solarize_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x00, INVMASK(0x78)},
+	{0x5003, 0x09},
+};
+
+
+struct ov5640_sensor ov5640_effect_sepia_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x18, INVMASK(0x78)},
+	{0x5003, 0x08},
+	{0x5583, 0x40},
+	{0x5584, 0xa0},
+};
+
+struct ov5640_sensor ov5640_effect_reddish_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x18, INVMASK(0x78)},
+	{0x5003, 0x08},
+	{0x5583, 0x80},
+	{0x5584, 0xc0},
+};
+
+struct ov5640_sensor ov5640_effect_greenish_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x18, INVMASK(0x78)},
+	{0x5003, 0x08},
+	{0x5583, 0x60},
+	{0x5584, 0x60},
+};
+
+struct ov5640_sensor ov5640_effect_negative_tbl[] = {
+	{0x5001, 0x83, INVMASK(0x80)},
+	{0x5580, 0x40, INVMASK(0x78)},
+	{0x5003, 0x08},
+};
+
+/* AntiBanding */
+struct ov5640_sensor ov5640_antibanding_auto_tbl[] = {
+  /* Auto-XCLK24MHz */
+	{0x3622, 0x01}, /* PD-sel */
+	{0x3635, 0x1c}, /* VMREF 3635[2:0] */
+	{0x3634, 0x40}, /* I_5060 3643[2:0] */
+	{0x3c01, 0x34},
+	{0x3c00, 0x00},
+	{0x3c04, 0x28},
+	{0x3c05, 0x98},
+	{0x3c06, 0x00},
+	{0x3c07, 0x08},
+	{0x3c08, 0x00},
+	{0x3c09, 0x1c},
+	{0x300c, 0x22}, /* 50/60div 300c[2:0] */
+	{0x3c0a, 0x9c},
+	{0x3c0b, 0x40},
+};
+
+struct ov5640_sensor ov5640_antibanding_50z_tbl[] = {
+  /* Band 50Hz */
+	{0x3c01, 0x80, INVMASK(0x80)},
+	{0x3c00, 0x04},
+};
+
+struct ov5640_sensor ov5640_antibanding_60z_tbl[] = {
+  /* Band 60Hz */
+	{0x3c01, 0x80, INVMASK(0x80)},
+	{0x3c00, 0x00},
+};
+
+
+/* Lens_shading */
+
+struct ov5640_sensor ov5640_lens_shading_on_tbl[] = {
+	/* @@ Lenc On(C) */
+	{0x5000, 0x80, INVMASK(0x80)},
+};
+
+struct ov5640_sensor ov5640_lens_shading_off_tbl[] = {
+	/*  Lenc Off */
+	{0x5000, 0x00, INVMASK(0x80)},
+};
+
+/* Auto Focus Firmware-use 2011-08-24 firmware settings */
+u8 ov5640_afinit_tbl[] = {
+	0x80,	0x00,	0x02,	0x0b,	0x7b,	0x02,	0x07,	0xbd,	0xc2,
+	0x01,	0x22,	0x22,	0x00,	0x02,	0x0b,	0x57,	0xe5,	0x1f,
+	0x70,	0x72,	0xf5,	0x1e,	0xd2,	0x35,	0xff,	0xef,	0x25,
+	0xe0,	0x24,	0x4b,	0xf8,	0xe4,	0xf6,	0x08,	0xf6,	0x0f,
+	0xbf,	0x34,	0xf2,	0x90,	0x0e,	0x88,	0xe4,	0x93,	0xff,
+	0xe5,	0x49,	0xc3,	0x9f,	0x50,	0x04,	0x7f,	0x05,	0x80,
+	0x02,	0x7f,	0xfb,	0x78,	0xba,	0xa6,	0x07,	0x12,	0x0a,
+	0xb4,	0x40,	0x04,	0x7f,	0x03,	0x80,	0x02,	0x7f,	0x30,
+	0x78,	0xb9,	0xa6,	0x07,	0xe6,	0x18,	0xf6,	0x08,	0xe6,
+	0x78,	0xb6,	0xf6,	0x78,	0xb9,	0xe6,	0x78,	0xb7,	0xf6,
+	0x78,	0xbc,	0x76,	0x33,	0xe4,	0x08,	0xf6,	0x78,	0xb5,
+	0x76,	0x01,	0x75,	0x48,	0x02,	0x78,	0xb3,	0xf6,	0x08,
+	0xf6,	0x74,	0xff,	0x78,	0xbe,	0xf6,	0x08,	0xf6,	0x75,
+	0x1f,	0x01,	0x78,	0xb9,	0xe6,	0x75,	0xf0,	0x05,	0xa4,
+	0xf5,	0x49,	0x12,	0x08,	0x5b,	0xc2,	0x37,	0x22,	0x78,
+	0xb5,	0xe6,	0xd3,	0x94,	0x00,	0x40,	0x02,	0x16,	0x22,
+	0xe5,	0x1f,	0x64,	0x05,	0x70,	0x28,	0xf5,	0x1f,	0xc2,
+	0x01,	0x78,	0xb6,	0xe6,	0x25,	0xe0,	0x24,	0x4b,	0xf8,
+	0xe6,	0xfe,	0x08,	0xe6,	0xff,	0x78,	0x4b,	0xa6,	0x06,
+	0x08,	0xa6,	0x07,	0xa2,	0x37,	0xe4,	0x33,	0xf5,	0x3c,
+	0x90,	0x30,	0x28,	0xf0,	0x75,	0x1e,	0x10,	0xd2,	0x35,
+	0x22,	0xe5,	0x49,	0x75,	0xf0,	0x05,	0x84,	0x78,	0xb9,
+	0xf6,	0x90,	0x0e,	0x85,	0xe4,	0x93,	0xff,	0x25,	0xe0,
+	0x24,	0x0a,	0xf8,	0xe6,	0xfc,	0x08,	0xe6,	0xfd,	0x78,
+	0xb9,	0xe6,	0x25,	0xe0,	0x24,	0x4b,	0xf8,	0xa6,	0x04,
+	0x08,	0xa6,	0x05,	0xef,	0x12,	0x0a,	0xbb,	0xd3,	0x78,
+	0xb4,	0x96,	0xee,	0x18,	0x96,	0x40,	0x0d,	0x78,	0xb9,
+	0xe6,	0x78,	0xb6,	0xf6,	0x78,	0xb3,	0xa6,	0x06,	0x08,
+	0xa6,	0x07,	0x90,	0x0e,	0x85,	0xe4,	0x93,	0x12,	0x0a,
+	0xbb,	0xc3,	0x78,	0xbf,	0x96,	0xee,	0x18,	0x96,	0x50,
+	0x0d,	0x78,	0xb9,	0xe6,	0x78,	0xb7,	0xf6,	0x78,	0xbe,
+	0xa6,	0x06,	0x08,	0xa6,	0x07,	0x78,	0xb3,	0xe6,	0xfe,
+	0x08,	0xe6,	0xc3,	0x78,	0xbf,	0x96,	0xff,	0xee,	0x18,
+	0x96,	0x78,	0xc0,	0xf6,	0x08,	0xa6,	0x07,	0x90,	0x0e,
+	0x8a,	0xe4,	0x18,	0x12,	0x0a,	0x99,	0xc3,	0x33,	0xce,
+	0x33,	0xce,	0xd8,	0xf9,	0xff,	0xd3,	0xed,	0x9f,	0xec,
+	0x9e,	0x40,	0x02,	0xd2,	0x37,	0x78,	0xb9,	0xe6,	0x08,
+	0x26,	0x08,	0xf6,	0xe5,	0x1f,	0x64,	0x01,	0x70,	0x55,
+	0xe6,	0xc3,	0x78,	0xbd,	0x12,	0x0a,	0x8f,	0x40,	0x10,
+	0x12,	0x0a,	0x8a,	0x50,	0x0b,	0x30,	0x37,	0x41,	0x78,
+	0xb9,	0xe6,	0x78,	0xb6,	0x66,	0x60,	0x39,	0x12,	0x0a,
+	0xb2,	0x40,	0x04,	0x7f,	0xfe,	0x80,	0x02,	0x7f,	0x02,
+	0x78,	0xba,	0xa6,	0x07,	0x78,	0xb6,	0xe6,	0x24,	0x03,
+	0x78,	0xbc,	0xf6,	0x78,	0xb6,	0xe6,	0x24,	0xfd,	0x78,
+	0xbd,	0xf6,	0x12,	0x0a,	0xb2,	0x40,	0x06,	0x78,	0xbd,
+	0xe6,	0xff,	0x80,	0x04,	0x78,	0xbc,	0xe6,	0xff,	0x78,
+	0xbb,	0xa6,	0x07,	0x75,	0x1f,	0x02,	0x78,	0xb5,	0x76,
+	0x01,	0x02,	0x02,	0x68,	0xe5,	0x1f,	0x64,	0x02,	0x60,
+	0x03,	0x02,	0x02,	0x48,	0x78,	0xbb,	0xe6,	0xff,	0xc3,
+	0x78,	0xbd,	0x12,	0x0a,	0x90,	0x40,	0x08,	0x12,	0x0a,
+	0x8a,	0x50,	0x03,	0x02,	0x02,	0x46,	0x12,	0x0a,	0xb2,
+	0x40,	0x04,	0x7f,	0xff,	0x80,	0x02,	0x7f,	0x01,	0x78,
+	0xba,	0xa6,	0x07,	0x78,	0xb6,	0xe6,	0x04,	0x78,	0xbc,
+	0xf6,	0x78,	0xb6,	0xe6,	0x14,	0x78,	0xbd,	0xf6,	0x18,
+	0x12,	0x0a,	0xb4,	0x40,	0x04,	0xe6,	0xff,	0x80,	0x02,
+	0x7f,	0x00,	0x78,	0xbc,	0xa6,	0x07,	0xd3,	0x08,	0xe6,
+	0x64,	0x80,	0x94,	0x80,	0x40,	0x04,	0xe6,	0xff,	0x80,
+	0x02,	0x7f,	0x00,	0x78,	0xbd,	0xa6,	0x07,	0xc3,	0x18,
+	0xe6,	0x64,	0x80,	0x94,	0xb3,	0x50,	0x04,	0xe6,	0xff,
+	0x80,	0x02,	0x7f,	0x33,	0x78,	0xbc,	0xa6,	0x07,	0xc3,
+	0x08,	0xe6,	0x64,	0x80,	0x94,	0xb3,	0x50,	0x04,	0xe6,
+	0xff,	0x80,	0x02,	0x7f,	0x33,	0x78,	0xbd,	0xa6,	0x07,
+	0x12,	0x0a,	0xb2,	0x40,	0x06,	0x78,	0xbd,	0xe6,	0xff,
+	0x80,	0x04,	0x78,	0xbc,	0xe6,	0xff,	0x78,	0xbb,	0xa6,
+	0x07,	0x75,	0x1f,	0x03,	0x78,	0xb5,	0x76,	0x01,	0x80,
+	0x20,	0xe5,	0x1f,	0x64,	0x03,	0x70,	0x26,	0x78,	0xbb,
+	0xe6,	0xff,	0xc3,	0x78,	0xbd,	0x12,	0x0a,	0x90,	0x40,
+	0x05,	0x12,	0x0a,	0x8a,	0x40,	0x09,	0x78,	0xb6,	0xe6,
+	0x78,	0xbb,	0xf6,	0x75,	0x1f,	0x04,	0x78,	0xbb,	0xe6,
+	0x75,	0xf0,	0x05,	0xa4,	0xf5,	0x49,	0x02,	0x08,	0x5b,
+	0xe5,	0x1f,	0xb4,	0x04,	0x1d,	0x90,	0x0e,	0x89,	0xe4,
+	0x78,	0xc0,	0x12,	0x0a,	0x99,	0xc3,	0x33,	0xce,	0x33,
+	0xce,	0xd8,	0xf9,	0xff,	0xd3,	0xed,	0x9f,	0xec,	0x9e,
+	0x40,	0x02,	0xd2,	0x37,	0x75,	0x1f,	0x05,	0x22,	0xef,
+	0x8d,	0xf0,	0xa4,	0xa8,	0xf0,	0xcf,	0x8c,	0xf0,	0xa4,
+	0x28,	0xce,	0x8d,	0xf0,	0xa4,	0x2e,	0xfe,	0x22,	0xbc,
+	0x00,	0x0b,	0xbe,	0x00,	0x29,	0xef,	0x8d,	0xf0,	0x84,
+	0xff,	0xad,	0xf0,	0x22,	0xe4,	0xcc,	0xf8,	0x75,	0xf0,
+	0x08,	0xef,	0x2f,	0xff,	0xee,	0x33,	0xfe,	0xec,	0x33,
+	0xfc,	0xee,	0x9d,	0xec,	0x98,	0x40,	0x05,	0xfc,	0xee,
+	0x9d,	0xfe,	0x0f,	0xd5,	0xf0,	0xe9,	0xe4,	0xce,	0xfd,
+	0x22,	0xed,	0xf8,	0xf5,	0xf0,	0xee,	0x84,	0x20,	0xd2,
+	0x1c,	0xfe,	0xad,	0xf0,	0x75,	0xf0,	0x08,	0xef,	0x2f,
+	0xff,	0xed,	0x33,	0xfd,	0x40,	0x07,	0x98,	0x50,	0x06,
+	0xd5,	0xf0,	0xf2,	0x22,	0xc3,	0x98,	0xfd,	0x0f,	0xd5,
+	0xf0,	0xea,	0x22,	0xe8,	0x8f,	0xf0,	0xa4,	0xcc,	0x8b,
+	0xf0,	0xa4,	0x2c,	0xfc,	0xe9,	0x8e,	0xf0,	0xa4,	0x2c,
+	0xfc,	0x8a,	0xf0,	0xed,	0xa4,	0x2c,	0xfc,	0xea,	0x8e,
+	0xf0,	0xa4,	0xcd,	0xa8,	0xf0,	0x8b,	0xf0,	0xa4,	0x2d,
+	0xcc,	0x38,	0x25,	0xf0,	0xfd,	0xe9,	0x8f,	0xf0,	0xa4,
+	0x2c,	0xcd,	0x35,	0xf0,	0xfc,	0xeb,	0x8e,	0xf0,	0xa4,
+	0xfe,	0xa9,	0xf0,	0xeb,	0x8f,	0xf0,	0xa4,	0xcf,	0xc5,
+	0xf0,	0x2e,	0xcd,	0x39,	0xfe,	0xe4,	0x3c,	0xfc,	0xea,
+	0xa4,	0x2d,	0xce,	0x35,	0xf0,	0xfd,	0xe4,	0x3c,	0xfc,
+	0x22,	0x75,	0xf0,	0x08,	0x75,	0x82,	0x00,	0xef,	0x2f,
+	0xff,	0xee,	0x33,	0xfe,	0xcd,	0x33,	0xcd,	0xcc,	0x33,
+	0xcc,	0xc5,	0x82,	0x33,	0xc5,	0x82,	0x9b,	0xed,	0x9a,
+	0xec,	0x99,	0xe5,	0x82,	0x98,	0x40,	0x0c,	0xf5,	0x82,
+	0xee,	0x9b,	0xfe,	0xed,	0x9a,	0xfd,	0xec,	0x99,	0xfc,
+	0x0f,	0xd5,	0xf0,	0xd6,	0xe4,	0xce,	0xfb,	0xe4,	0xcd,
+	0xfa,	0xe4,	0xcc,	0xf9,	0xa8,	0x82,	0x22,	0xb8,	0x00,
+	0xc1,	0xb9,	0x00,	0x59,	0xba,	0x00,	0x2d,	0xec,	0x8b,
+	0xf0,	0x84,	0xcf,	0xce,	0xcd,	0xfc,	0xe5,	0xf0,	0xcb,
+	0xf9,	0x78,	0x18,	0xef,	0x2f,	0xff,	0xee,	0x33,	0xfe,
+	0xed,	0x33,	0xfd,	0xec,	0x33,	0xfc,	0xeb,	0x33,	0xfb,
+	0x10,	0xd7,	0x03,	0x99,	0x40,	0x04,	0xeb,	0x99,	0xfb,
+	0x0f,	0xd8,	0xe5,	0xe4,	0xf9,	0xfa,	0x22,	0x78,	0x18,
+	0xef,	0x2f,	0xff,	0xee,	0x33,	0xfe,	0xed,	0x33,	0xfd,
+	0xec,	0x33,	0xfc,	0xc9,	0x33,	0xc9,	0x10,	0xd7,	0x05,
+	0x9b,	0xe9,	0x9a,	0x40,	0x07,	0xec,	0x9b,	0xfc,	0xe9,
+	0x9a,	0xf9,	0x0f,	0xd8,	0xe0,	0xe4,	0xc9,	0xfa,	0xe4,
+	0xcc,	0xfb,	0x22,	0x75,	0xf0,	0x10,	0xef,	0x2f,	0xff,
+	0xee,	0x33,	0xfe,	0xed,	0x33,	0xfd,	0xcc,	0x33,	0xcc,
+	0xc8,	0x33,	0xc8,	0x10,	0xd7,	0x07,	0x9b,	0xec,	0x9a,
+	0xe8,	0x99,	0x40,	0x0a,	0xed,	0x9b,	0xfd,	0xec,	0x9a,
+	0xfc,	0xe8,	0x99,	0xf8,	0x0f,	0xd5,	0xf0,	0xda,	0xe4,
+	0xcd,	0xfb,	0xe4,	0xcc,	0xfa,	0xe4,	0xc8,	0xf9,	0x22,
+	0xeb,	0x9f,	0xf5,	0xf0,	0xea,	0x9e,	0x42,	0xf0,	0xe9,
+	0x9d,	0x42,	0xf0,	0xe8,	0x9c,	0x45,	0xf0,	0x22,	0xe8,
+	0x60,	0x0f,	0xef,	0xc3,	0x33,	0xff,	0xee,	0x33,	0xfe,
+	0xed,	0x33,	0xfd,	0xec,	0x33,	0xfc,	0xd8,	0xf1,	0x22,
+	0xe4,	0x93,	0xfc,	0x74,	0x01,	0x93,	0xfd,	0x74,	0x02,
+	0x93,	0xfe,	0x74,	0x03,	0x93,	0xff,	0x22,	0xe6,	0xfb,
+	0x08,	0xe6,	0xf9,	0x08,	0xe6,	0xfa,	0x08,	0xe6,	0xcb,
+	0xf8,	0x22,	0xec,	0xf6,	0x08,	0xed,	0xf6,	0x08,	0xee,
+	0xf6,	0x08,	0xef,	0xf6,	0x22,	0xa4,	0x25,	0x82,	0xf5,
+	0x82,	0xe5,	0xf0,	0x35,	0x83,	0xf5,	0x83,	0x22,	0xd0,
+	0x83,	0xd0,	0x82,	0xf8,	0xe4,	0x93,	0x70,	0x12,	0x74,
+	0x01,	0x93,	0x70,	0x0d,	0xa3,	0xa3,	0x93,	0xf8,	0x74,
+	0x01,	0x93,	0xf5,	0x82,	0x88,	0x83,	0xe4,	0x73,	0x74,
+	0x02,	0x93,	0x68,	0x60,	0xef,	0xa3,	0xa3,	0xa3,	0x80,
+	0xdf,	0x90,	0x38,	0x04,	0x78,	0x4f,	0x12,	0x09,	0x50,
+	0x90,	0x38,	0x00,	0xe0,	0xfe,	0xa3,	0xe0,	0xfd,	0xed,
+	0xff,	0xc3,	0x12,	0x09,	0x09,	0x90,	0x38,	0x10,	0x12,
+	0x08,	0xfd,	0x90,	0x38,	0x06,	0x78,	0x51,	0x12,	0x09,
+	0x50,	0x90,	0x38,	0x02,	0xe0,	0xfe,	0xa3,	0xe0,	0xfd,
+	0xed,	0xff,	0xc3,	0x12,	0x09,	0x09,	0x90,	0x38,	0x12,
+	0x12,	0x08,	0xfd,	0xa3,	0xe0,	0xb4,	0x31,	0x07,	0x78,
+	0x4f,	0x79,	0x4f,	0x12,	0x09,	0x66,	0x90,	0x38,	0x14,
+	0xe0,	0xb4,	0x71,	0x15,	0x78,	0x4f,	0xe6,	0xfe,	0x08,
+	0xe6,	0x78,	0x02,	0xce,	0xc3,	0x13,	0xce,	0x13,	0xd8,
+	0xf9,	0x79,	0x50,	0xf7,	0xee,	0x19,	0xf7,	0x90,	0x38,
+	0x15,	0xe0,	0xb4,	0x31,	0x07,	0x78,	0x51,	0x79,	0x51,
+	0x12,	0x09,	0x66,	0x90,	0x38,	0x15,	0xe0,	0xb4,	0x71,
+	0x15,	0x78,	0x51,	0xe6,	0xfe,	0x08,	0xe6,	0x78,	0x02,
+	0xce,	0xc3,	0x13,	0xce,	0x13,	0xd8,	0xf9,	0x79,	0x52,
+	0xf7,	0xee,	0x19,	0xf7,	0x79,	0x4f,	0x12,	0x09,	0x38,
+	0x09,	0x12,	0x09,	0x38,	0xaf,	0x45,	0x12,	0x08,	0xee,
+	0x7d,	0x50,	0x12,	0x02,	0xa9,	0x78,	0x57,	0xa6,	0x06,
+	0x08,	0xa6,	0x07,	0xaf,	0x43,	0x12,	0x08,	0xee,	0x7d,
+	0x50,	0x12,	0x02,	0xa9,	0x78,	0x53,	0xa6,	0x06,	0x08,
+	0xa6,	0x07,	0xaf,	0x46,	0x78,	0x51,	0x12,	0x08,	0xf0,
+	0x7d,	0x3c,	0x12,	0x02,	0xa9,	0x78,	0x59,	0xa6,	0x06,
+	0x08,	0xa6,	0x07,	0xaf,	0x44,	0x7e,	0x00,	0x78,	0x51,
+	0x12,	0x08,	0xf2,	0x7d,	0x3c,	0x12,	0x02,	0xa9,	0x78,
+	0x55,	0xa6,	0x06,	0x08,	0xa6,	0x07,	0xc3,	0x78,	0x58,
+	0xe6,	0x94,	0x08,	0x18,	0xe6,	0x94,	0x00,	0x50,	0x05,
+	0x76,	0x00,	0x08,	0x76,	0x08,	0xc3,	0x78,	0x5a,	0xe6,
+	0x94,	0x08,	0x18,	0xe6,	0x94,	0x00,	0x50,	0x05,	0x76,
+	0x00,	0x08,	0x76,	0x08,	0x78,	0x57,	0x12,	0x09,	0x25,
+	0xff,	0xd3,	0x78,	0x54,	0xe6,	0x9f,	0x18,	0xe6,	0x9e,
+	0x40,	0x0e,	0x78,	0x57,	0xe6,	0x13,	0xfe,	0x08,	0xe6,
+	0x78,	0x54,	0x12,	0x09,	0x5b,	0x80,	0x04,	0x7e,	0x00,
+	0x7f,	0x00,	0x78,	0x5b,	0x12,	0x09,	0x1d,	0xff,	0xd3,
+	0x78,	0x56,	0xe6,	0x9f,	0x18,	0xe6,	0x9e,	0x40,	0x0e,
+	0x78,	0x59,	0xe6,	0x13,	0xfe,	0x08,	0xe6,	0x78,	0x56,
+	0x12,	0x09,	0x5b,	0x80,	0x04,	0x7e,	0x00,	0x7f,	0x00,
+	0xe4,	0xfc,	0xfd,	0x78,	0x5f,	0x12,	0x04,	0x5c,	0x78,
+	0x57,	0x12,	0x09,	0x25,	0x78,	0x54,	0x26,	0xff,	0xee,
+	0x18,	0x36,	0xfe,	0x78,	0x63,	0x12,	0x09,	0x1d,	0x78,
+	0x56,	0x26,	0xff,	0xee,	0x18,	0x36,	0xfe,	0xe4,	0xfc,
+	0xfd,	0x78,	0x67,	0x12,	0x04,	0x5c,	0x12,	0x09,	0x2d,
+	0x78,	0x63,	0x12,	0x04,	0x4f,	0xd3,	0x12,	0x04,	0x1b,
+	0x40,	0x08,	0x12,	0x09,	0x2d,	0x78,	0x63,	0x12,	0x04,
+	0x5c,	0x78,	0x51,	0x12,	0x09,	0x2f,	0x78,	0x67,	0x12,
+	0x04,	0x4f,	0xd3,	0x12,	0x04,	0x1b,	0x40,	0x0a,	0x78,
+	0x51,	0x12,	0x09,	0x2f,	0x78,	0x67,	0x12,	0x04,	0x5c,
+	0xe4,	0xfd,	0x78,	0x5e,	0x12,	0x09,	0x48,	0x24,	0x01,
+	0x12,	0x09,	0x11,	0x78,	0x62,	0x12,	0x09,	0x48,	0x24,
+	0x02,	0x12,	0x09,	0x11,	0x78,	0x66,	0x12,	0x09,	0x48,
+	0x24,	0x03,	0x12,	0x09,	0x11,	0x78,	0x6a,	0x12,	0x09,
+	0x48,	0x24,	0x04,	0x12,	0x09,	0x11,	0x0d,	0xbd,	0x05,
+	0xd4,	0xc2,	0x0e,	0xc2,	0x06,	0x22,	0x85,	0x08,	0x41,
+	0x90,	0x30,	0x24,	0xe0,	0xf5,	0x3d,	0xa3,	0xe0,	0xf5,
+	0x3e,	0xa3,	0xe0,	0xf5,	0x3f,	0xa3,	0xe0,	0xf5,	0x40,
+	0xa3,	0xe0,	0xf5,	0x3c,	0xd2,	0x34,	0xe5,	0x41,	0x12,
+	0x04,	0x74,	0x06,	0xc7,	0x03,	0x06,	0xcb,	0x04,	0x06,
+	0xd1,	0x07,	0x06,	0xda,	0x08,	0x06,	0xeb,	0x12,	0x07,
+	0x03,	0x18,	0x07,	0x19,	0x19,	0x06,	0xee,	0x1a,	0x06,
+	0xfa,	0x1b,	0x07,	0x3e,	0x80,	0x07,	0x43,	0x81,	0x07,
+	0xa1,	0x8f,	0x07,	0x90,	0x90,	0x07,	0xa1,	0x91,	0x07,
+	0xa1,	0x92,	0x07,	0xa1,	0x93,	0x07,	0xa1,	0x94,	0x07,
+	0xa1,	0x98,	0x07,	0x9e,	0x9f,	0x00,	0x00,	0x07,	0xbc,
+	0x12,	0x0a,	0xf4,	0x22,	0x12,	0x0a,	0xf4,	0xd2,	0x03,
+	0x22,	0xa2,	0x37,	0xe4,	0x33,	0xf5,	0x3c,	0x02,	0x07,
+	0xa1,	0xc2,	0x01,	0xc2,	0x02,	0xc2,	0x03,	0x12,	0x09,
+	0x70,	0x75,	0x1e,	0x70,	0xd2,	0x35,	0x02,	0x07,	0xa1,
+	0x02,	0x07,	0x8b,	0x85,	0x40,	0x48,	0x85,	0x3c,	0x49,
+	0x12,	0x08,	0x5b,	0x02,	0x07,	0xa1,	0x85,	0x48,	0x40,
+	0x85,	0x49,	0x3c,	0x02,	0x07,	0xa1,	0xe4,	0xf5,	0x22,
+	0xf5,	0x23,	0x85,	0x40,	0x31,	0x85,	0x3f,	0x30,	0x85,
+	0x3e,	0x2f,	0x85,	0x3d,	0x2e,	0x12,	0x0a,	0xc6,	0x80,
+	0x1f,	0x75,	0x22,	0x00,	0x75,	0x23,	0x01,	0x74,	0xff,
+	0xf5,	0x2d,	0xf5,	0x2c,	0xf5,	0x2b,	0xf5,	0x2a,	0x12,
+	0x0a,	0xc6,	0x85,	0x2d,	0x40,	0x85,	0x2c,	0x3f,	0x85,
+	0x2b,	0x3e,	0x85,	0x2a,	0x3d,	0xe4,	0xf5,	0x3c,	0x02,
+	0x07,	0xa1,	0x12,	0x0b,	0x3d,	0x80,	0x5e,	0x85,	0x3d,
+	0x43,	0x85,	0x3e,	0x44,	0xe5,	0x45,	0xc3,	0x13,	0xff,
+	0xe5,	0x43,	0xc3,	0x9f,	0x50,	0x02,	0x8f,	0x43,	0xe5,
+	0x46,	0xc3,	0x13,	0xff,	0xe5,	0x44,	0xc3,	0x9f,	0x50,
+	0x02,	0x8f,	0x44,	0xe5,	0x45,	0xc3,	0x13,	0xff,	0xfd,
+	0xe5,	0x43,	0x90,	0x0e,	0x7f,	0x12,	0x0b,	0x10,	0x40,
+	0x04,	0xee,	0x9f,	0xf5,	0x43,	0xe5,	0x46,	0xc3,	0x13,
+	0xff,	0xfd,	0xe5,	0x44,	0x90,	0x0e,	0x80,	0x12,	0x0b,
+	0x10,	0x40,	0x04,	0xee,	0x9f,	0xf5,	0x44,	0x12,	0x04,
+	0x9a,	0x80,	0x11,	0x85,	0x40,	0x46,	0x85,	0x3f,	0x45,
+	0x85,	0x3e,	0x44,	0x85,	0x3d,	0x43,	0x80,	0x03,	0x02,
+	0x04,	0x9a,	0x90,	0x30,	0x24,	0xe5,	0x3d,	0xf0,	0xa3,
+	0xe5,	0x3e,	0xf0,	0xa3,	0xe5,	0x3f,	0xf0,	0xa3,	0xe5,
+	0x40,	0xf0,	0xa3,	0xe5,	0x3c,	0xf0,	0x90,	0x30,	0x23,
+	0xe4,	0xf0,	0x22,	0xc0,	0xe0,	0xc0,	0x83,	0xc0,	0x82,
+	0xc0,	0xd0,	0x90,	0x3f,	0x0c,	0xe0,	0xf5,	0x32,	0xe5,
+	0x32,	0x30,	0xe3,	0x4c,	0x30,	0x36,	0x3e,	0x90,	0x60,
+	0x19,
+	0xe0,
+	0xf5,
+	0x0a,
+	0xa3,
+	0xe0,
+	0xf5,
+	0x0b,
+	0x90,
+	0x60,
+	0x1d,
+	0xe0,
+	0xf5,
+	0x14,
+	0xa3,
+	0xe0,
+	0xf5,
+	0x15,
+	0x30,
+	0x01,
+	0x06,
+	0x30,
+	0x33,
+	0x03,
+	0xd3,
+	0x80,
+	0x01,
+	0xc3,
+	0x92,
+	0x09,
+	0x30,
+	0x02,
+	0x06,
+	0x30,
+	0x33,
+	0x03,
+	0xd3,
+	0x80,
+	0x01,
+	0xc3,
+	0x92,
+	0x0a,
+	0x30,
+	0x33,
+	0x0c,
+	0x30,
+	0x03,
+	0x09,
+	0x20,
+	0x02,
+	0x06,
+	0x20,
+	0x01,
+	0x03,
+	0xd3,
+	0x80,
+	0x01,
+	0xc3,
+	0x92,
+	0x0b,
+	0x90,
+	0x30,
+	0x01,
+	0xe0,
+	0x44,
+	0x40,
+	0xf0,
+	0xe0,
+	0x54,
+	0xbf,
+	0xf0,
+	0xe5,
+	0x32,
+	0x30,
+	0xe1,
+	0x14,
+	0x30,
+	0x34,
+	0x11,
+	0x90,
+	0x30,
+	0x22,
+	0xe0,
+	0xf5,
+	0x08,
+	0xe4,
+	0xf0,
+	0x30,
+	0x00,
+	0x03,
+	0xd3,
+	0x80,
+	0x01,
+	0xc3,
+	0x92,
+	0x08,
+	0xe5,
+	0x32,
+	0x30,
+	0xe5,
+	0x12,
+	0x90,
+	0x56,
+	0xa1,
+	0xe0,
+	0xf5,
+	0x09,
+	0x30,
+	0x31,
+	0x09,
+	0x30,
+	0x05,
+	0x03,
+	0xd3,
+	0x80,
+	0x01,
+	0xc3,
+	0x92,
+	0x0d,
+	0x90,
+	0x3f,
+	0x0c,
+	0xe5,
+	0x32,
+	0xf0,
+	0xd0,
+	0xd0,
+	0xd0,
+	0x82,
+	0xd0,
+	0x83,
+	0xd0,
+	0xe0,
+	0x32,
+	0x90,
+	0x0e,
+	0x7d,
+	0xe4,
+	0x93,
+	0xfe,
+	0x74,
+	0x01,
+	0x93,
+	0xff,
+	0xc3,
+	0x90,
+	0x0e,
+	0x7b,
+	0x74,
+	0x01,
+	0x93,
+	0x9f,
+	0xff,
+	0xe4,
+	0x93,
+	0x9e,
+	0xfe,
+	0xe4,
+	0x8f,
+	0x3b,
+	0x8e,
+	0x3a,
+	0xf5,
+	0x39,
+	0xf5,
+	0x38,
+	0xab,
+	0x3b,
+	0xaa,
+	0x3a,
+	0xa9,
+	0x39,
+	0xa8,
+	0x38,
+	0xaf,
+	0x49,
+	0xfc,
+	0xfd,
+	0xfe,
+	0x12,
+	0x02,
+	0xfe,
+	0x12,
+	0x0b,
+	0x22,
+	0xe4,
+	0x7b,
+	0xff,
+	0xfa,
+	0xf9,
+	0xf8,
+	0x12,
+	0x03,
+	0x89,
+	0x12,
+	0x0b,
+	0x22,
+	0x90,
+	0x0e,
+	0x69,
+	0xe4,
+	0x12,
+	0x0b,
+	0x37,
+	0x12,
+	0x0b,
+	0x22,
+	0xe4,
+	0x85,
+	0x48,
+	0x37,
+	0xf5,
+	0x36,
+	0xf5,
+	0x35,
+	0xf5,
+	0x34,
+	0xaf,
+	0x37,
+	0xae,
+	0x36,
+	0xad,
+	0x35,
+	0xac,
+	0x34,
+	0xa3,
+	0x12,
+	0x0b,
+	0x37,
+	0x8f,
+	0x37,
+	0x8e,
+	0x36,
+	0x8d,
+	0x35,
+	0x8c,
+	0x34,
+	0xe5,
+	0x3b,
+	0x45,
+	0x37,
+	0xf5,
+	0x3b,
+	0xe5,
+	0x3a,
+	0x45,
+	0x36,
+	0xf5,
+	0x3a,
+	0xe5,
+	0x39,
+	0x45,
+	0x35,
+	0xf5,
+	0x39,
+	0xe5,
+	0x38,
+	0x45,
+	0x34,
+	0xf5,
+	0x38,
+	0xe4,
+	0xf5,
+	0x22,
+	0xf5,
+	0x23,
+	0x85,
+	0x3b,
+	0x31,
+	0x85,
+	0x3a,
+	0x30,
+	0x85,
+	0x39,
+	0x2f,
+	0x85,
+	0x38,
+	0x2e,
+	0x02,
+	0x0a,
+	0xc6,
+	0x78,
+	0x4f,
+	0x7e,
+	0x00,
+	0xe6,
+	0xfc,
+	0x08,
+	0xe6,
+	0xfd,
+	0x12,
+	0x02,
+	0x97,
+	0x7c,
+	0x00,
+	0x22,
+	0xe0,
+	0xa3,
+	0xe0,
+	0x75,
+	0xf0,
+	0x02,
+	0xa4,
+	0xff,
+	0xae,
+	0xf0,
+	0xc3,
+	0x08,
+	0xe6,
+	0x9f,
+	0xf6,
+	0x18,
+	0xe6,
+	0x9e,
+	0xf6,
+	0x22,
+	0xff,
+	0xe5,
+	0xf0,
+	0x34,
+	0x60,
+	0x8f,
+	0x82,
+	0xf5,
+	0x83,
+	0xec,
+	0xf0,
+	0x22,
+	0xe4,
+	0xfc,
+	0xfd,
+	0x12,
+	0x04,
+	0x5c,
+	0x78,
+	0x59,
+	0xe6,
+	0xc3,
+	0x13,
+	0xfe,
+	0x08,
+	0xe6,
+	0x13,
+	0x22,
+	0x78,
+	0x4f,
+	0xe6,
+	0xfe,
+	0x08,
+	0xe6,
+	0xff,
+	0xe4,
+	0xfc,
+	0xfd,
+	0x22,
+	0xe7,
+	0xc4,
+	0xf8,
+	0x54,
+	0xf0,
+	0xc8,
+	0x68,
+	0xf7,
+	0x09,
+	0xe7,
+	0xc4,
+	0x54,
+	0x0f,
+	0x48,
+	0xf7,
+	0x22,
+	0xe6,
+	0xfc,
+	0xed,
+	0x75,
+	0xf0,
+	0x04,
+	0xa4,
+	0x22,
+	0xe0,
+	0xfe,
+	0xa3,
+	0xe0,
+	0xfd,
+	0xee,
+	0xf6,
+	0xed,
+	0x08,
+	0xf6,
+	0x22,
+	0x13,
+	0xff,
+	0xc3,
+	0xe6,
+	0x9f,
+	0xff,
+	0x18,
+	0xe6,
+	0x9e,
+	0xfe,
+	0x22,
+	0xe6,
+	0xc3,
+	0x13,
+	0xf7,
+	0x08,
+	0xe6,
+	0x13,
+	0x09,
+	0xf7,
+	0x22,
+	0xe4,
+	0xf5,
+	0x49,
+	0x90,
+	0x0e,
+	0x77,
+	0x93,
+	0xff,
+	0xe4,
+	0x8f,
+	0x37,
+	0xf5,
+	0x36,
+	0xf5,
+	0x35,
+	0xf5,
+	0x34,
+	0xaf,
+	0x37,
+	0xae,
+	0x36,
+	0xad,
+	0x35,
+	0xac,
+	0x34,
+	0x90,
+	0x0e,
+	0x6a,
+	0x12,
+	0x0b,
+	0x37,
+	0x8f,
+	0x37,
+	0x8e,
+	0x36,
+	0x8d,
+	0x35,
+	0x8c,
+	0x34,
+	0x90,
+	0x0e,
+	0x72,
+	0x12,
+	0x04,
+	0x3f,
+	0xef,
+	0x45,
+	0x37,
+	0xf5,
+	0x37,
+	0xee,
+	0x45,
+	0x36,
+	0xf5,
+	0x36,
+	0xed,
+	0x45,
+	0x35,
+	0xf5,
+	0x35,
+	0xec,
+	0x45,
+	0x34,
+	0xf5,
+	0x34,
+	0xe4,
+	0xf5,
+	0x22,
+	0xf5,
+	0x23,
+	0x85,
+	0x37,
+	0x31,
+	0x85,
+	0x36,
+	0x30,
+	0x85,
+	0x35,
+	0x2f,
+	0x85,
+	0x34,
+	0x2e,
+	0x12,
+	0x0a,
+	0xc6,
+	0xe4,
+	0xf5,
+	0x22,
+	0xf5,
+	0x23,
+	0x90,
+	0x0e,
+	0x72,
+	0x12,
+	0x0b,
+	0x2b,
+	0x12,
+	0x0a,
+	0xc6,
+	0xe4,
+	0xf5,
+	0x22,
+	0xf5,
+	0x23,
+	0x90,
+	0x0e,
+	0x6e,
+	0x12,
+	0x0b,
+	0x2b,
+	0x02,
+	0x0a,
+	0xc6,
+	0x75,
+	0x89,
+	0x03,
+	0x75,
+	0xa8,
+	0x01,
+	0x75,
+	0xb8,
+	0x04,
+	0x75,
+	0x34,
+	0xff,
+	0x75,
+	0x35,
+	0x0e,
+	0x75,
+	0x36,
+	0x15,
+	0x75,
+	0x37,
+	0x0d,
+	0x12,
+	0x0a,
+	0x4a,
+	0x12,
+	0x00,
+	0x09,
+	0x12,
+	0x0b,
+	0x3d,
+	0x12,
+	0x00,
+	0x06,
+	0xd2,
+	0x00,
+	0xd2,
+	0x34,
+	0xd2,
+	0xaf,
+	0x75,
+	0x34,
+	0xff,
+	0x75,
+	0x35,
+	0x0e,
+	0x75,
+	0x36,
+	0x49,
+	0x75,
+	0x37,
+	0x03,
+	0x12,
+	0x0a,
+	0x4a,
+	0x30,
+	0x08,
+	0x09,
+	0xc2,
+	0x34,
+	0x12,
+	0x06,
+	0x6a,
+	0xc2,
+	0x08,
+	0xd2,
+	0x34,
+	0x30,
+	0x09,
+	0x09,
+	0xc2,
+	0x36,
+	0x12,
+	0x00,
+	0x0e,
+	0xc2,
+	0x09,
+	0xd2,
+	0x36,
+	0x30,
+	0x0e,
+	0x03,
+	0x12,
+	0x04,
+	0x9a,
+	0x30,
+	0x35,
+	0xdf,
+	0x90,
+	0x30,
+	0x29,
+	0xe5,
+	0x1e,
+	0xf0,
+	0xb4,
+	0x10,
+	0x05,
+	0x90,
+	0x30,
+	0x23,
+	0xe4,
+	0xf0,
+	0xc2,
+	0x35,
+	0x80,
+	0xcd,
+	0xae,
+	0x35,
+	0xaf,
+	0x36,
+	0xe4,
+	0xfd,
+	0xed,
+	0xc3,
+	0x95,
+	0x37,
+	0x50,
+	0x33,
+	0x12,
+	0x0b,
+	0x87,
+	0xe4,
+	0x93,
+	0xf5,
+	0x38,
+	0x74,
+	0x01,
+	0x93,
+	0xf5,
+	0x39,
+	0x45,
+	0x38,
+	0x60,
+	0x23,
+	0x85,
+	0x39,
+	0x82,
+	0x85,
+	0x38,
+	0x83,
+	0xe0,
+	0xfc,
+	0x12,
+	0x0b,
+	0x87,
+	0x74,
+	0x03,
+	0x93,
+	0x52,
+	0x04,
+	0x12,
+	0x0b,
+	0x87,
+	0x74,
+	0x02,
+	0x93,
+	0x42,
+	0x04,
+	0x85,
+	0x39,
+	0x82,
+	0x85,
+	0x38,
+	0x83,
+	0xec,
+	0xf0,
+	0x0d,
+	0x80,
+	0xc7,
+	0x22,
+	0x78,
+	0xbb,
+	0xe6,
+	0xd3,
+	0x08,
+	0xff,
+	0xe6,
+	0x64,
+	0x80,
+	0xf8,
+	0xef,
+	0x64,
+	0x80,
+	0x98,
+	0x22,
+	0x93,
+	0xff,
+	0x7e,
+	0x00,
+	0xe6,
+	0xfc,
+	0x08,
+	0xe6,
+	0xfd,
+	0x12,
+	0x02,
+	0x97,
+	0xac,
+	0x06,
+	0xad,
+	0x07,
+	0x78,
+	0xb3,
+	0xe6,
+	0xfe,
+	0x08,
+	0xe6,
+	0x78,
+	0x03,
+	0x22,
+	0x78,
+	0xba,
+	0xd3,
+	0xe6,
+	0x64,
+	0x80,
+	0x94,
+	0x80,
+	0x22,
+	0x25,
+	0xe0,
+	0x24,
+	0x0a,
+	0xf8,
+	0xe6,
+	0xfe,
+	0x08,
+	0xe6,
+	0xff,
+	0x22,
+	0xa2,
+	0xaf,
+	0x92,
+	0x32,
+	0xc2,
+	0xaf,
+	0xe5,
+	0x23,
+	0x45,
+	0x22,
+	0x90,
+	0x0e,
+	0x5d,
+	0x60,
+	0x0e,
+	0x12,
+	0x0b,
+	0x70,
+	0xe0,
+	0xf5,
+	0x2c,
+	0x12,
+	0x0b,
+	0x6d,
+	0xe0,
+	0xf5,
+	0x2d,
+	0x80,
+	0x0c,
+	0x12,
+	0x0b,
+	0x70,
+	0xe5,
+	0x30,
+	0xf0,
+	0x12,
+	0x0b,
+	0x6d,
+	0xe5,
+	0x31,
+	0xf0,
+	0xa2,
+	0x32,
+	0x92,
+	0xaf,
+	0x22,
+	0xd2,
+	0x01,
+	0xc2,
+	0x02,
+	0xe4,
+	0xf5,
+	0x1f,
+	0xf5,
+	0x1e,
+	0xd2,
+	0x35,
+	0xd2,
+	0x33,
+	0xd2,
+	0x36,
+	0xd2,
+	0x01,
+	0xc2,
+	0x02,
+	0xf5,
+	0x1f,
+	0xf5,
+	0x1e,
+	0xd2,
+	0x35,
+	0xd2,
+	0x33,
+	0x22,
+	0x2d,
+	0xfd,
+	0xe4,
+	0x33,
+	0xfc,
+	0xe4,
+	0x93,
+	0xfe,
+	0xfb,
+	0xd3,
+	0xed,
+	0x9b,
+	0x74,
+	0x80,
+	0xf8,
+	0x6c,
+	0x98,
+	0x22,
+	0x8f,
+	0x3b,
+	0x8e,
+	0x3a,
+	0x8d,
+	0x39,
+	0x8c,
+	0x38,
+	0x22,
+	0x12,
+	0x04,
+	0x3f,
+	0x8f,
+	0x31,
+	0x8e,
+	0x30,
+	0x8d,
+	0x2f,
+	0x8c,
+	0x2e,
+	0x22,
+	0x93,
+	0xf9,
+	0xf8,
+	0x02,
+	0x04,
+	0x2c,
+	0x90,
+	0x0e,
+	0x81,
+	0x12,
+	0x04,
+	0x3f,
+	0x8f,
+	0x46,
+	0x8e,
+	0x45,
+	0x8d,
+	0x44,
+	0x8c,
+	0x43,
+	0xd2,
+	0x06,
+	0x30,
+	0x06,
+	0x03,
+	0xd3,
+	0x80,
+	0x01,
+	0xc3,
+	0x92,
+	0x0e,
+	0x22,
+	0xc0,
+	0xe0,
+	0xc0,
+	0x83,
+	0xc0,
+	0x82,
+	0x90,
+	0x3f,
+	0x0d,
+	0xe0,
+	0xf5,
+	0x33,
+	0xe5,
+	0x33,
+	0xf0,
+	0xd0,
+	0x82,
+	0xd0,
+	0x83,
+	0xd0,
+	0xe0,
+	0x32,
+	0x90,
+	0x0e,
+	0x5f,
+	0xe4,
+	0x93,
+	0xfe,
+	0x74,
+	0x01,
+	0x93,
+	0xf5,
+	0x82,
+	0x8e,
+	0x83,
+	0x22,
+	0x78,
+	0x7f,
+	0xe4,
+	0xf6,
+	0xd8,
+	0xfd,
+	0x75,
+	0x81,
+	0xca,
+	0x02,
+	0x09,
+	0xe1,
+	0x8f,
+	0x82,
+	0x8e,
+	0x83,
+	0x75,
+	0xf0,
+	0x04,
+	0xed,
+	0x02,
+	0x04,
+	0x68,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x11,
+	0x07,
+	0x21,
+	0x15,
+	0x29,
+	0x13,
+	0x4f,
+	0x56,
+	0x54,
+	0x20,
+	0x20,
+	0x20,
+	0x20,
+	0x20,
+	0x20,
+	0x01,
+	0x10,
+	0x00,
+	0x56,
+	0x40,
+	0x1a,
+	0x30,
+	0x29,
+	0x7e,
+	0x00,
+	0x30,
+	0x04,
+	0x20,
+	0xdf,
+	0x30,
+	0x05,
+	0x40,
+	0xbf,
+	0x50,
+	0x03,
+	0x00,
+	0xfd,
+	0x50,
+	0x27,
+	0x01,
+	0xfe,
+	0x60,
+	0x00,
+	0x11,
+	0x00,
+	0x3f,
+	0x05,
+	0x30,
+	0x00,
+	0x3f,
+	0x06,
+	0x22,
+	0x00,
+	0x3f,
+	0x01,
+	0x2a,
+	0x00,
+	0x3f,
+	0x02,
+	0x00,
+	0x00,
+	0x36,
+	0x06,
+	0x07,
+	0x00,
+	0x3f,
+	0x0b,
+	0x0f,
+	0xf0,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x30,
+	0x01,
+	0x40,
+	0xbf,
+	0x30,
+	0x01,
+	0x00,
+	0xbf,
+	0x30,
+	0x29,
+	0x70,
+	0x00,
+	0x3a,
+	0x00,
+	0x00,
+	0xff,
+	0x3a,
+	0x00,
+	0x00,
+	0xff,
+	0x36,
+	0x03,
+	0x36,
+	0x02,
+	0x41,
+	0x44,
+	0x58,
+	0x20,
+	0x18,
+	0x10,
+	0x0a,
+	0x04,
+	0x04,
+	0x00,
+	0x03,
+	0xff,
+	0x64,
+	0x00,
+	0x00,
+	0x80,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x00,
+	0x02,
+	0x04,
+	0x06,
+	0x00,
+	0x03,
+	0x98,
+	0x00,
+	0xcc,
+	0x50,
+	0x3c,
+	0x28,
+	0x1e,
+	0x10,
+	0x10,
+	0x00,
+	0x00,
+	0x00,
+	0x6e,
+	0x30,
+	0x28,
+	0x00,
+	0xa5,
+	0x5a,
+	0x00,
+};
+
+#endif /* CAMSENSOR_OV5640 */
diff --git a/drivers/media/video/msm/ov7692_qrd.c b/drivers/media/video/msm/ov7692_qrd.c
new file mode 100644
index 0000000..e558e57
--- /dev/null
+++ b/drivers/media/video/msm/ov7692_qrd.c
@@ -0,0 +1,679 @@
+/* Copyright (c) 2011, Code Aurora Forum. 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 version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/* #define DEBUG */
+
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <linux/i2c.h>
+#include <linux/uaccess.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <media/msm_camera.h>
+#include <mach/camera.h>
+#include <mach/gpio.h>
+#include "ov7692.h"
+
+/*=============================================================
+    SENSOR REGISTER DEFINES
+==============================================================*/
+#define Q8    0x00000100
+
+/* Omnivision8810 product ID register address */
+#define REG_OV7692_MODEL_ID_MSB                       0x0A
+#define REG_OV7692_MODEL_ID_LSB                       0x0B
+
+#define OV7692_MODEL_ID                       0x7692
+/* Omnivision8810 product ID */
+
+/* Time in milisecs for waiting for the sensor to reset */
+#define OV7692_RESET_DELAY_MSECS    66
+#define OV7692_DEFAULT_CLOCK_RATE   24000000
+/* Registers*/
+
+/* Color bar pattern selection */
+#define OV7692_COLOR_BAR_PATTERN_SEL_REG     0x82
+/* Color bar enabling control */
+#define OV7692_COLOR_BAR_ENABLE_REG           0x601
+/* Time in milisecs for waiting for the sensor to reset*/
+#define OV7692_RESET_DELAY_MSECS    66
+
+static int ov7692_pwdn_gpio;
+static int ov7692_reset_gpio;
+
+
+/*============================================================================
+  DATA DECLARATIONS
+  ============================================================================*/
+/*  96MHz PCLK @ 24MHz MCLK */
+struct reg_addr_val_pair_struct ov7692_init_settings_array[] = {
+	{0x12, 0x80},
+	{0x0e, 0x08},
+	{0x69, 0x52},
+	{0x1e, 0xb3},
+	{0x48, 0x42},
+	{0xff, 0x01},
+	{0xae, 0xa0},
+	{0xa8, 0x26},
+	{0xb4, 0xc0},
+	{0xb5, 0x40},
+	{0xff, 0x00},
+	{0x0c, 0x00},
+	{0x62, 0x10},
+	{0x12, 0x00},
+	{0x17, 0x65},
+	{0x18, 0xa4},
+	{0x19, 0x0a},
+	{0x1a, 0xf6},
+	{0x3e, 0x30},
+	{0x64, 0x0a},
+	{0xff, 0x01},
+	{0xb4, 0xc0},
+	{0xff, 0x00},
+	{0x67, 0x20},
+	{0x81, 0x3f},
+	{0xcc, 0x02},
+	{0xcd, 0x80},
+	{0xce, 0x01},
+	{0xcf, 0xe0},
+	{0xc8, 0x02},
+	{0xc9, 0x80},
+	{0xca, 0x01},
+	{0xcb, 0xe0},
+	{0xd0, 0x48},
+	{0x82, 0x03},
+	{0x0e, 0x00},
+	{0x70, 0x00},
+	{0x71, 0x34},
+	{0x74, 0x28},
+	{0x75, 0x98},
+	{0x76, 0x00},
+	{0x77, 0x64},
+	{0x78, 0x01},
+	{0x79, 0xc2},
+	{0x7a, 0x4e},
+	{0x7b, 0x1f},
+	{0x7c, 0x00},
+	{0x11, 0x00},
+	{0x20, 0x00},
+	{0x21, 0x23},
+	{0x50, 0x9a},
+	{0x51, 0x80},
+	{0x4c, 0x7d},
+	{0x0e, 0x00},
+	{0x85, 0x10},
+	{0x86, 0x00},
+	{0x87, 0x00},
+	{0x88, 0x00},
+	{0x89, 0x2a},
+	{0x8a, 0x26},
+	{0x8b, 0x22},
+	{0xbb, 0x7a},
+	{0xbc, 0x69},
+	{0xbd, 0x11},
+	{0xbe, 0x13},
+	{0xbf, 0x81},
+	{0xc0, 0x96},
+	{0xc1, 0x1e},
+	{0xb7, 0x05},
+	{0xb8, 0x09},
+	{0xb9, 0x00},
+	{0xba, 0x18},
+	{0x5a, 0x1f},
+	{0x5b, 0x9f},
+	{0x5c, 0x6a},
+	{0x5d, 0x42},
+	{0x24, 0x78},
+	{0x25, 0x68},
+	{0x26, 0xb3},
+	{0xa3, 0x0b},
+	{0xa4, 0x15},
+	{0xa5, 0x2a},
+	{0xa6, 0x51},
+	{0xa7, 0x63},
+	{0xa8, 0x74},
+	{0xa9, 0x83},
+	{0xaa, 0x91},
+	{0xab, 0x9e},
+	{0xac, 0xaa},
+	{0xad, 0xbe},
+	{0xae, 0xce},
+	{0xaf, 0xe5},
+	{0xb0, 0xf3},
+	{0xb1, 0xfb},
+	{0xb2, 0x06},
+	{0x8c, 0x5c},
+	{0x8d, 0x11},
+	{0x8e, 0x12},
+	{0x8f, 0x19},
+	{0x90, 0x50},
+	{0x91, 0x20},
+	{0x92, 0x96},
+	{0x93, 0x80},
+	{0x94, 0x13},
+	{0x95, 0x1b},
+	{0x96, 0xff},
+	{0x97, 0x00},
+	{0x98, 0x3d},
+	{0x99, 0x36},
+	{0x9a, 0x51},
+	{0x9b, 0x43},
+	{0x9c, 0xf0},
+	{0x9d, 0xf0},
+	{0x9e, 0xf0},
+	{0x9f, 0xff},
+	{0xa0, 0x68},
+	{0xa1, 0x62},
+	{0xa2, 0x0e},
+};
+
+static bool OV7692_CSI_CONFIG;
+/* 816x612, 24MHz MCLK 96MHz PCLK */
+uint32_t OV7692_FULL_SIZE_WIDTH        = 640;
+uint32_t OV7692_FULL_SIZE_HEIGHT       = 480;
+
+uint32_t OV7692_QTR_SIZE_WIDTH         = 640;
+uint32_t OV7692_QTR_SIZE_HEIGHT        = 480;
+
+uint32_t OV7692_HRZ_FULL_BLK_PIXELS    = 16;
+uint32_t OV7692_VER_FULL_BLK_LINES     = 12;
+uint32_t OV7692_HRZ_QTR_BLK_PIXELS     = 16;
+uint32_t OV7692_VER_QTR_BLK_LINES      = 12;
+
+struct ov7692_work_t {
+	struct work_struct work;
+};
+static struct  ov7692_work_t *ov7692_sensorw;
+static struct  i2c_client *ov7692_client;
+struct ov7692_ctrl_t {
+	const struct  msm_camera_sensor_info *sensordata;
+	uint32_t sensormode;
+	uint32_t fps_divider;        /* init to 1 * 0x00000400 */
+	uint32_t pict_fps_divider;    /* init to 1 * 0x00000400 */
+	uint32_t fps;
+	int32_t  curr_lens_pos;
+	uint32_t curr_step_pos;
+	uint32_t my_reg_gain;
+	uint32_t my_reg_line_count;
+	uint32_t total_lines_per_frame;
+	enum ov7692_resolution_t prev_res;
+	enum ov7692_resolution_t pict_res;
+	enum ov7692_resolution_t curr_res;
+	enum ov7692_test_mode_t  set_test;
+	unsigned short imgaddr;
+};
+static struct ov7692_ctrl_t *ov7692_ctrl;
+static DECLARE_WAIT_QUEUE_HEAD(ov7692_wait_queue);
+DEFINE_MUTEX(ov7692_mut);
+
+/*=============================================================*/
+
+static int ov7692_i2c_rxdata(unsigned short saddr,
+		unsigned char *rxdata, int length)
+{
+	struct i2c_msg msgs[] = {
+		{
+			.addr  = saddr,
+			.flags = 0,
+			.len   = 1,
+			.buf   = rxdata,
+		},
+		{
+			.addr  = saddr,
+			.flags = I2C_M_RD,
+			.len   = 1,
+			.buf   = rxdata,
+		},
+	};
+	if (i2c_transfer(ov7692_client->adapter, msgs, 2) < 0) {
+		CDBG("ov7692_i2c_rxdata failed!\n");
+		return -EIO;
+	}
+	return 0;
+}
+static int32_t ov7692_i2c_txdata(unsigned short saddr,
+		unsigned char *txdata, int length)
+{
+	struct i2c_msg msg[] = {
+		{
+			.addr = saddr,
+			.flags = 0,
+			.len = 2,
+			.buf = txdata,
+		},
+	};
+	if (i2c_transfer(ov7692_client->adapter, msg, 1) < 0) {
+		CDBG("ov7692_i2c_txdata faild 0x%x\n", ov7692_client->addr);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int32_t ov7692_i2c_read(uint8_t raddr,
+		uint8_t *rdata, int rlen)
+{
+	int32_t rc = 0;
+	unsigned char buf[1];
+	if (!rdata)
+		return -EIO;
+	memset(buf, 0, sizeof(buf));
+	buf[0] = raddr;
+	rc = ov7692_i2c_rxdata(ov7692_client->addr >> 1, buf, rlen);
+	if (rc < 0) {
+		CDBG("ov7692_i2c_read 0x%x failed!\n", raddr);
+		return rc;
+	}
+	*rdata = buf[0];
+	return rc;
+}
+static int32_t ov7692_i2c_write_b_sensor(uint8_t waddr, uint8_t bdata)
+{
+	int32_t rc = -EFAULT;
+	unsigned char buf[2];
+
+	memset(buf, 0, sizeof(buf));
+	buf[0] = waddr;
+	buf[1] = bdata;
+
+	rc = ov7692_i2c_txdata(ov7692_client->addr >> 1, buf, 2);
+	if (rc < 0)
+		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
+				waddr, bdata);
+	return rc;
+}
+
+static int32_t ov7692_sensor_setting(int update_type, int rt)
+{
+	int32_t i, array_length;
+	int32_t rc = 0;
+	struct msm_camera_csi_params ov7692_csi_params;
+
+	CDBG("%s: rt = %d\n", __func__, rt);
+
+	switch (update_type) {
+	case REG_INIT:
+		OV7692_CSI_CONFIG = 0;
+		ov7692_i2c_write_b_sensor(0x0e, 0x08);
+		return rc;
+		break;
+	case UPDATE_PERIODIC:
+		if (!OV7692_CSI_CONFIG) {
+			ov7692_csi_params.lane_cnt = 1;
+			ov7692_csi_params.data_format = CSI_8BIT;
+			ov7692_csi_params.lane_assign = 0xe4;
+			ov7692_csi_params.dpcm_scheme = 0;
+			ov7692_csi_params.settle_cnt = 0x14;
+
+			rc = msm_camio_csi_config(&ov7692_csi_params);
+			msleep(20);
+			array_length = sizeof(ov7692_init_settings_array) /
+				sizeof(ov7692_init_settings_array[0]);
+			for (i = 0; i < array_length; i++) {
+				rc = ov7692_i2c_write_b_sensor(
+				ov7692_init_settings_array[i].reg_addr,
+				ov7692_init_settings_array[i].reg_val);
+				if (rc < 0)
+					return rc;
+			}
+			OV7692_CSI_CONFIG = 1;
+			msleep(20);
+			return rc;
+		}
+		break;
+	default:
+		rc = -EINVAL;
+		break;
+	}
+	return rc;
+}
+
+static int32_t ov7692_video_config(int mode)
+{
+	int32_t rc = 0;
+	int rt;
+	/* change sensor resolution if needed */
+	rt = RES_PREVIEW;
+
+	CDBG("%s\n", __func__);
+
+	if (ov7692_sensor_setting(UPDATE_PERIODIC, rt) < 0)
+		return rc;
+	ov7692_ctrl->curr_res = ov7692_ctrl->prev_res;
+	ov7692_ctrl->sensormode = mode;
+	return rc;
+}
+
+static int32_t ov7692_set_sensor_mode(int mode,
+		int res)
+{
+	int32_t rc = 0;
+	switch (mode) {
+	case SENSOR_PREVIEW_MODE:
+		rc = ov7692_video_config(mode);
+		break;
+	case SENSOR_SNAPSHOT_MODE:
+	case SENSOR_RAW_SNAPSHOT_MODE:
+		break;
+	default:
+		rc = -EINVAL;
+		break;
+	}
+	return rc;
+}
+
+static void ov7692_power_on(void)
+{
+	CDBG("%s\n", __func__);
+	gpio_set_value(ov7692_pwdn_gpio, 0);
+}
+
+static void ov7692_power_down(void)
+{
+	CDBG("%s\n", __func__);
+	gpio_set_value(ov7692_pwdn_gpio, 1);
+}
+
+static void ov7692_sw_reset(void)
+{
+	CDBG("%s\n", __func__);
+	ov7692_i2c_write_b_sensor(0x12, 0x80);
+}
+
+static void ov7692_hw_reset(void)
+{
+	CDBG("--CAMERA-- %s ... (Start...)\n", __func__);
+	gpio_set_value(ov7692_reset_gpio, 1);   /* reset camera reset pin */
+	msleep(20);
+	gpio_set_value(ov7692_reset_gpio, 0);
+	msleep(20);
+	gpio_set_value(ov7692_reset_gpio, 1);
+	msleep(20);
+
+	CDBG("--CAMERA-- %s ... (End...)\n", __func__);
+}
+
+
+
+static int ov7692_probe_init_sensor(const struct msm_camera_sensor_info *data)
+{
+	uint8_t model_id_msb, model_id_lsb = 0;
+	uint16_t model_id = 0;
+	int32_t rc = 0;
+	/*The reset pin is not physically connected to the sensor.
+	  The standby pin will do the reset hence there is no need
+	  to request the gpio reset*/
+
+	/* Read sensor Model ID: */
+	rc = ov7692_i2c_read(REG_OV7692_MODEL_ID_MSB, &model_id_msb, 1);
+	if (rc < 0)
+		goto init_probe_fail;
+	rc = ov7692_i2c_read(REG_OV7692_MODEL_ID_LSB, &model_id_lsb, 1);
+	if (rc < 0)
+		goto init_probe_fail;
+	model_id = (model_id_msb << 8) | ((model_id_lsb & 0x00FF)) ;
+	CDBG("ov7692 model_id = 0x%x, 0x%x, 0x%x\n",
+			model_id, model_id_msb, model_id_lsb);
+	/* 4. Compare sensor ID to OV7692 ID: */
+	if (model_id != OV7692_MODEL_ID) {
+		rc = -ENODEV;
+		goto init_probe_fail;
+	}
+	goto init_probe_done;
+init_probe_fail:
+	pr_warning(" ov7692_probe_init_sensor fails\n");
+init_probe_done:
+	CDBG(" ov7692_probe_init_sensor finishes\n");
+	return rc;
+}
+
+int ov7692_sensor_open_init(const struct msm_camera_sensor_info *data)
+{
+	int32_t rc = 0;
+
+	CDBG("%s: %d\n", __func__, __LINE__);
+	CDBG("Calling ov7692_sensor_open_init\n");
+	ov7692_ctrl = kzalloc(sizeof(struct ov7692_ctrl_t), GFP_KERNEL);
+	if (!ov7692_ctrl) {
+		CDBG("ov7692_init failed!\n");
+		rc = -ENOMEM;
+		goto init_done;
+	}
+	ov7692_ctrl->fps_divider = 1 * 0x00000400;
+	ov7692_ctrl->pict_fps_divider = 1 * 0x00000400;
+	ov7692_ctrl->fps = 30 * Q8;
+	ov7692_ctrl->set_test = TEST_OFF;
+	ov7692_ctrl->prev_res = QTR_SIZE;
+	ov7692_ctrl->pict_res = FULL_SIZE;
+	ov7692_ctrl->curr_res = INVALID_SIZE;
+
+	if (data)
+		ov7692_ctrl->sensordata = data;
+
+	/* enable mclk first */
+
+	msm_camio_clk_rate_set(24000000);
+	msleep(20);
+
+	ov7692_power_on();
+	msleep(20);
+
+	rc = ov7692_probe_init_sensor(data);
+	if (rc < 0) {
+		CDBG("Calling ov7692_sensor_open_init fail\n");
+		goto init_fail;
+	}
+
+	rc = ov7692_sensor_setting(REG_INIT, RES_PREVIEW);
+	if (rc < 0)
+		goto init_fail;
+	else
+		goto init_done;
+
+init_fail:
+	CDBG(" ov7692_sensor_open_init fail\n");
+	kfree(ov7692_ctrl);
+init_done:
+	CDBG("ov7692_sensor_open_init done\n");
+	return rc;
+}
+
+static int ov7692_init_client(struct i2c_client *client)
+{
+	/* Initialize the MSM_CAMI2C Chip */
+	init_waitqueue_head(&ov7692_wait_queue);
+	return 0;
+}
+
+static const struct i2c_device_id ov7692_i2c_id[] = {
+	{"ov7692", 0},
+	{ }
+};
+
+static int ov7692_i2c_probe(struct i2c_client *client,
+		const struct i2c_device_id *id)
+{
+	int rc = 0;
+	CDBG("ov7692_i2c_probe called!\n");
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CDBG("i2c_check_functionality failed\n");
+		goto probe_failure;
+	}
+
+	ov7692_sensorw = kzalloc(sizeof(struct ov7692_work_t), GFP_KERNEL);
+	if (!ov7692_sensorw) {
+		CDBG("kzalloc failed.\n");
+		rc = -ENOMEM;
+		goto probe_failure;
+	}
+
+	i2c_set_clientdata(client, ov7692_sensorw);
+	ov7692_init_client(client);
+	ov7692_client = client;
+
+	CDBG("ov7692_i2c_probe success! rc = %d\n", rc);
+	return 0;
+
+probe_failure:
+	CDBG("ov7692_i2c_probe failed! rc = %d\n", rc);
+	return rc;
+}
+
+static int __exit ov7692_remove(struct i2c_client *client)
+{
+	struct ov7692_work_t_t *sensorw = i2c_get_clientdata(client);
+	free_irq(client->irq, sensorw);
+	ov7692_client = NULL;
+	kfree(sensorw);
+	return 0;
+}
+
+static struct i2c_driver ov7692_i2c_driver = {
+	.id_table = ov7692_i2c_id,
+	.probe  = ov7692_i2c_probe,
+	.remove = __exit_p(ov7692_i2c_remove),
+	.driver = {
+		.name = "ov7692",
+	},
+};
+
+int ov7692_sensor_config(void __user *argp)
+{
+	struct sensor_cfg_data cdata;
+	long   rc = 0;
+	if (copy_from_user(&cdata,
+				(void *)argp,
+				sizeof(struct sensor_cfg_data)))
+		return -EFAULT;
+	mutex_lock(&ov7692_mut);
+	CDBG("ov7692_sensor_config: cfgtype = %d\n", cdata.cfgtype);
+	switch (cdata.cfgtype) {
+	case CFG_SET_MODE:
+		rc = ov7692_set_sensor_mode(cdata.mode,
+				cdata.rs);
+		break;
+	case CFG_PWR_DOWN:
+		ov7692_power_down();
+		break;
+	default:
+		rc = -EFAULT;
+		break;
+	}
+
+	mutex_unlock(&ov7692_mut);
+
+	return rc;
+}
+static int ov7692_sensor_release(void)
+{
+	int rc = -EBADF;
+	mutex_lock(&ov7692_mut);
+	ov7692_sw_reset();
+	ov7692_power_down();
+	kfree(ov7692_ctrl);
+	ov7692_ctrl = NULL;
+	CDBG("ov7692_release completed\n");
+	mutex_unlock(&ov7692_mut);
+
+	return rc;
+}
+
+static int ov7692_probe_init_gpio(const struct msm_camera_sensor_info *data)
+{
+	int rc = 0;
+
+	ov7692_pwdn_gpio = data->sensor_pwd;
+	ov7692_reset_gpio = data->sensor_reset ;
+
+	if (data->sensor_reset_enable)
+		gpio_direction_output(data->sensor_reset, 1);
+
+	gpio_direction_output(data->sensor_pwd, 1);
+
+	return rc;
+
+}
+
+
+static int ov7692_sensor_probe(const struct msm_camera_sensor_info *info,
+		struct msm_sensor_ctrl *s)
+{
+	int rc = 0;
+	rc = i2c_add_driver(&ov7692_i2c_driver);
+	if (rc < 0 || ov7692_client == NULL) {
+		rc = -ENOTSUPP;
+		goto probe_fail;
+	}
+
+	rc = ov7692_probe_init_gpio(info);
+	if (rc < 0) {
+		CDBG("%s: gpio init failed\n", __func__);
+		goto probe_fail;
+	}
+
+	ov7692_power_down();
+
+	msm_camio_clk_rate_set(24000000);
+	msleep(20);
+
+	ov7692_power_on();
+	msleep(20);
+
+	if (info->sensor_reset_enable)
+		ov7692_hw_reset();
+	else
+		ov7692_sw_reset();
+
+	rc = ov7692_probe_init_sensor(info);
+	if (rc < 0)
+		goto probe_fail;
+
+
+	s->s_init = ov7692_sensor_open_init;
+	s->s_release = ov7692_sensor_release;
+	s->s_config  = ov7692_sensor_config;
+	s->s_camera_type = FRONT_CAMERA_2D;
+	s->s_mount_angle = info->sensor_platform_info->mount_angle;
+
+	ov7692_power_down();
+
+	return rc;
+
+probe_fail:
+	CDBG("ov7692_sensor_probe: SENSOR PROBE FAILS!\n");
+	i2c_del_driver(&ov7692_i2c_driver);
+	return rc;
+}
+
+static int __ov7692_probe(struct platform_device *pdev)
+{
+	return msm_camera_drv_start(pdev, ov7692_sensor_probe);
+}
+
+static struct platform_driver msm_camera_driver = {
+	.probe = __ov7692_probe,
+	.driver = {
+		.name = "msm_camera_ov7692",
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init ov7692_init(void)
+{
+	return platform_driver_register(&msm_camera_driver);
+}
+
+module_init(ov7692_init);
+
+MODULE_DESCRIPTION("OMNI VGA YUV sensor driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/pm8xxx-pwm.c b/drivers/mfd/pm8xxx-pwm.c
index ca9eebb..fa4b130 100644
--- a/drivers/mfd/pm8xxx-pwm.c
+++ b/drivers/mfd/pm8xxx-pwm.c
@@ -25,12 +25,33 @@
 #include <linux/mfd/pm8xxx/core.h>
 #include <linux/mfd/pm8xxx/pwm.h>
 
-#define PM8XXX_LPG_BANKS		8
-#define PM8XXX_PWM_CHANNELS		PM8XXX_LPG_BANKS
+#define PM8XXX_PWM_CHANNELS		3
 
+#define PM8XXX_LPG_BANKS                8
+#define PM8XXX_LPG_PWM_CHANNELS         PM8XXX_LPG_BANKS
 #define PM8XXX_LPG_CTL_REGS		7
 
 /* PM8XXX PWM */
+#define SSBI_REG_ADDR_PWM1_CTRL1	0x88
+#define SSBI_REG_ADDR_PWM1_CTRL2	0x89
+#define SSBI_REG_ADDR_PWM_CTL(id, base) (id == 0 ? base : (base + (id << 1)))
+#define SSBI_REG_ADDR_PWM_CTL1(id)	SSBI_REG_ADDR_PWM_CTL(id, \
+						SSBI_REG_ADDR_PWM1_CTRL1)
+#define SSBI_REG_ADDR_PWM_CTL2(id)	SSBI_REG_ADDR_PWM_CTL(id, \
+						SSBI_REG_ADDR_PWM1_CTRL2)
+
+#define PM8XXX_PWM_CLK_SEL_SHIFT	6
+#define PM8XXX_PWM_CLK_SEL_MASK		0xC0
+#define PM8XXX_PWM_PREDIVIDE_SHIFT	5
+#define PM8XXX_PWM_PREDIVIDE_MASK	0x20
+#define PM8XXX_PWM_M_SHIFT		2
+#define PM8XXX_PWM_M_MASK		0x1C
+#define PM8XXX_PWM_SIZE_SHIFT		1
+#define PM8XXX_PWM_SIZE_MASK		0x02
+#define PM8XXX_PWM_VALUE_BIT0		0x01
+#define PM8XXX_PWM_DISABLE		0x3F
+
+/* PM8XXX LPG PWM */
 #define SSBI_REG_ADDR_LPG_CTL_BASE	0x13C
 #define SSBI_REG_ADDR_LPG_CTL(n)	(SSBI_REG_ADDR_LPG_CTL_BASE + (n))
 #define SSBI_REG_ADDR_LPG_BANK_SEL	0x143
@@ -38,7 +59,7 @@
 #define SSBI_REG_ADDR_LPG_LUT_CFG0	0x145
 #define SSBI_REG_ADDR_LPG_LUT_CFG1	0x146
 
-/* Control 0 */
+/* LPG Control 0 */
 #define PM8XXX_PWM_1KHZ_COUNT_MASK	0xF0
 #define PM8XXX_PWM_1KHZ_COUNT_SHIFT	4
 
@@ -54,51 +75,51 @@
 #define PM8XXX_PWM_RAMP_GEN_START	(PM8XXX_PWM_RAMP_GEN_EN \
 					| PM8XXX_PWM_RAMP_START)
 
-/* Control 1 */
+/* LPG Control 1 */
 #define PM8XXX_PWM_REVERSE_EN		0x80
 #define PM8XXX_PWM_BYPASS_LUT		0x40
 #define PM8XXX_PWM_HIGH_INDEX_MASK	0x3F
 
-/* Control 2 */
+/* LPG Control 2 */
 #define PM8XXX_PWM_LOOP_EN		0x80
 #define PM8XXX_PWM_RAMP_UP		0x40
 #define PM8XXX_PWM_LOW_INDEX_MASK	0x3F
 
-/* Control 3 */
+/* LPG Control 3 */
 #define PM8XXX_PWM_VALUE_BIT7_0		0xFF
 #define PM8XXX_PWM_VALUE_BIT5_0		0x3F
 
-/* Control 4 */
+/* LPG Control 4 */
 #define PM8XXX_PWM_VALUE_BIT8		0x80
 
-#define PM8XXX_PWM_CLK_SEL_MASK		0x60
-#define PM8XXX_PWM_CLK_SEL_SHIFT	5
+#define PM8XXX_LPG_PWM_CLK_SEL_MASK	0x60
+#define PM8XXX_LPG_PWM_CLK_SEL_SHIFT	5
 
 #define PM8XXX_PWM_CLK_SEL_NO		0
 #define PM8XXX_PWM_CLK_SEL_1KHZ		1
 #define PM8XXX_PWM_CLK_SEL_32KHZ	2
 #define PM8XXX_PWM_CLK_SEL_19P2MHZ	3
 
-#define PM8XXX_PWM_PREDIVIDE_MASK	0x18
-#define PM8XXX_PWM_PREDIVIDE_SHIFT	3
+#define PM8XXX_LPG_PWM_PREDIVIDE_MASK	0x18
+#define PM8XXX_LPG_PWM_PREDIVIDE_SHIFT	3
 
 #define PM8XXX_PWM_PREDIVIDE_2		0
 #define PM8XXX_PWM_PREDIVIDE_3		1
 #define PM8XXX_PWM_PREDIVIDE_5		2
 #define PM8XXX_PWM_PREDIVIDE_6		3
 
-#define PM8XXX_PWM_M_MASK		0x07
+#define PM8XXX_LPG_PWM_M_MASK		0x07
 #define PM8XXX_PWM_M_MIN		0
 #define PM8XXX_PWM_M_MAX		7
 
-/* Control 5 */
+/* LPG Control 5 */
 #define PM8XXX_PWM_PAUSE_COUNT_HI_MASK		0xFC
 #define PM8XXX_PWM_PAUSE_COUNT_HI_SHIFT		2
 
 #define PM8XXX_PWM_PAUSE_ENABLE_HIGH		0x02
 #define PM8XXX_PWM_SIZE_9_BIT			0x01
 
-/* Control 6 */
+/* LPG Control 6 */
 #define PM8XXX_PWM_PAUSE_COUNT_LO_MASK		0xFC
 #define PM8XXX_PWM_PAUSE_COUNT_LO_SHIFT		2
 
@@ -107,11 +128,10 @@
 
 #define PM8XXX_PWM_PAUSE_COUNT_MAX		56 /* < 2^6 = 64 */
 
-/* LUT_CFG1 */
+/* LPG LUT_CFG1 */
 #define PM8XXX_PWM_LUT_READ			0x40
 
 
-
 /*
  * PWM Frequency = Clock Frequency / (N * T)
  *	or
@@ -132,7 +152,8 @@
 #define CLK_PERIOD_MIN	NSEC_19P2MHZ
 #define CLK_PERIOD_MAX	NSEC_1000HZ
 
-#define NUM_PRE_DIVIDE	3	/* No default support for pre-divide = 6 */
+#define NUM_LPG_PRE_DIVIDE	3  /* No default support for pre-divide = 6 */
+#define NUM_PWM_PRE_DIVIDE	2
 
 #define PRE_DIVIDE_0		2
 #define PRE_DIVIDE_1		3
@@ -141,7 +162,7 @@
 #define PRE_DIVIDE_MIN		PRE_DIVIDE_0
 #define PRE_DIVIDE_MAX		PRE_DIVIDE_2
 
-static unsigned int pt_t[NUM_PRE_DIVIDE][NUM_CLOCKS] = {
+static unsigned int pt_t[NUM_LPG_PRE_DIVIDE][NUM_CLOCKS] = {
 	{	PRE_DIVIDE_0 * NSEC_1000HZ,
 		PRE_DIVIDE_0 * NSEC_32768HZ,
 		PRE_DIVIDE_0 * NSEC_19P2MHZ,
@@ -170,17 +191,22 @@
 	int			pwm_value;
 	int			pwm_period;
 	int			pwm_duty;
-	u8			pwm_ctl[PM8XXX_LPG_CTL_REGS];
+	u8			pwm_lpg_ctl[PM8XXX_LPG_CTL_REGS];
+	u8			pwm_ctl1;
+	u8			pwm_ctl2;
 	int			irq;
 	struct pm8xxx_pwm_chip	*chip;
 	int			bypass_lut;
 };
 
 struct pm8xxx_pwm_chip {
-	struct pwm_device		pwm_dev[PM8XXX_PWM_CHANNELS];
+	struct pwm_device		*pwm_dev;
+	u8				pwm_channels;
+	u8				pwm_total_pre_divs;
 	u8				bank_mask;
 	struct mutex			pwm_mutex;
 	struct device			*dev;
+	bool				is_lpg_supported;
 };
 
 static struct pm8xxx_pwm_chip	*pwm_chip;
@@ -255,13 +281,13 @@
 	u8	reg;
 
 	if (start) {
-		reg = pwm->pwm_ctl[0] | PM8XXX_PWM_PWM_START;
+		reg = pwm->pwm_lpg_ctl[0] | PM8XXX_PWM_PWM_START;
 		if (ramp_start)
 			reg |= PM8XXX_PWM_RAMP_GEN_START;
 		else
 			reg &= ~PM8XXX_PWM_RAMP_GEN_START;
 	} else {
-		reg = pwm->pwm_ctl[0] & ~PM8XXX_PWM_PWM_START;
+		reg = pwm->pwm_lpg_ctl[0] & ~PM8XXX_PWM_PWM_START;
 		reg &= ~PM8XXX_PWM_RAMP_GEN_START;
 	}
 
@@ -270,7 +296,40 @@
 	if (rc)
 		pr_err("pm8xxx_writeb(): rc=%d (Enable PWM Ctl 0)\n", rc);
 	else
-		pwm->pwm_ctl[0] = reg;
+		pwm->pwm_lpg_ctl[0] = reg;
+	return rc;
+}
+
+static int pm8xxx_pwm_disable(struct pwm_device *pwm)
+{
+	int	rc;
+	u8	reg;
+
+	reg = pwm->pwm_ctl1 & PM8XXX_PWM_DISABLE;
+
+	rc = pm8xxx_writeb(pwm->chip->dev->parent,
+			SSBI_REG_ADDR_PWM_CTL1(pwm->pwm_id), reg);
+
+	if (rc)
+		pr_err("pm8xxx_writeb(): rc=%d (Disable PWM Ctl %d)\n", rc,
+								pwm->pwm_id);
+	return rc;
+}
+
+static int pm8xxx_pwm_enable(struct pwm_device *pwm)
+{
+	/**
+	 * A kind of best Effort: Just write the clock information that
+	 * we have in the register.
+	 */
+	int	rc;
+
+	rc = pm8xxx_writeb(pwm->chip->dev->parent,
+			SSBI_REG_ADDR_PWM_CTL1(pwm->pwm_id), pwm->pwm_ctl1);
+
+	if (rc)
+		pr_err("pm8xxx_writeb(): rc=%d (Enable PWM Ctl %d)\n", rc,
+								pwm->pwm_id);
 	return rc;
 }
 
@@ -304,7 +363,7 @@
 	best_clk = 0;
 	best_div = 0;
 	for (clk = 0; clk < NUM_CLOCKS; clk++) {
-		for (div = 0; div < NUM_PRE_DIVIDE; div++) {
+		for (div = 0; div < pwm_chip->pwm_total_pre_divs; div++) {
 			tmp_p = period_n;
 			last_p = tmp_p;
 			for (m = 0; m <= PM8XXX_PWM_M_MAX; m++) {
@@ -384,7 +443,7 @@
 	int	i, pwm_size;
 	int	rc = 0;
 
-	pwm_size = (pwm->pwm_ctl[5] & PM8XXX_PWM_SIZE_9_BIT) ? 9 : 6;
+	pwm_size = (pwm->pwm_lpg_ctl[5] & PM8XXX_PWM_SIZE_9_BIT) ? 9 : 6;
 	max_pwm_value = (1 << pwm_size) - 1;
 	for (i = 0; i < len; i++) {
 		if (raw_value)
@@ -414,44 +473,65 @@
 static void pm8xxx_pwm_save_index(struct pwm_device *pwm,
 				   int low_idx, int high_idx, int flags)
 {
-	pwm->pwm_ctl[1] = high_idx & PM8XXX_PWM_HIGH_INDEX_MASK;
-	pwm->pwm_ctl[2] = low_idx & PM8XXX_PWM_LOW_INDEX_MASK;
+	pwm->pwm_lpg_ctl[1] = high_idx & PM8XXX_PWM_HIGH_INDEX_MASK;
+	pwm->pwm_lpg_ctl[2] = low_idx & PM8XXX_PWM_LOW_INDEX_MASK;
 
 	if (flags & PM_PWM_LUT_REVERSE)
-		pwm->pwm_ctl[1] |= PM8XXX_PWM_REVERSE_EN;
+		pwm->pwm_lpg_ctl[1] |= PM8XXX_PWM_REVERSE_EN;
 	if (flags & PM_PWM_LUT_RAMP_UP)
-		pwm->pwm_ctl[2] |= PM8XXX_PWM_RAMP_UP;
+		pwm->pwm_lpg_ctl[2] |= PM8XXX_PWM_RAMP_UP;
 	if (flags & PM_PWM_LUT_LOOP)
-		pwm->pwm_ctl[2] |= PM8XXX_PWM_LOOP_EN;
+		pwm->pwm_lpg_ctl[2] |= PM8XXX_PWM_LOOP_EN;
 }
 
 static void pm8xxx_pwm_save_period(struct pwm_device *pwm)
 {
 	u8	mask, val;
 
-	val = ((pwm->period.clk + 1) << PM8XXX_PWM_CLK_SEL_SHIFT)
-		& PM8XXX_PWM_CLK_SEL_MASK;
-	val |= (pwm->period.pre_div << PM8XXX_PWM_PREDIVIDE_SHIFT)
-		& PM8XXX_PWM_PREDIVIDE_MASK;
-	val |= pwm->period.pre_div_exp & PM8XXX_PWM_M_MASK;
-	mask = PM8XXX_PWM_CLK_SEL_MASK | PM8XXX_PWM_PREDIVIDE_MASK |
-		PM8XXX_PWM_M_MASK;
-	pm8xxx_pwm_save(&pwm->pwm_ctl[4], mask, val);
+	if (pwm_chip->is_lpg_supported) {
+		val = ((pwm->period.clk + 1) << PM8XXX_LPG_PWM_CLK_SEL_SHIFT)
+			& PM8XXX_LPG_PWM_CLK_SEL_MASK;
+		val |= (pwm->period.pre_div << PM8XXX_LPG_PWM_PREDIVIDE_SHIFT)
+			& PM8XXX_LPG_PWM_PREDIVIDE_MASK;
+		val |= pwm->period.pre_div_exp & PM8XXX_LPG_PWM_M_MASK;
+		mask = PM8XXX_LPG_PWM_CLK_SEL_MASK |
+			PM8XXX_LPG_PWM_PREDIVIDE_MASK | PM8XXX_LPG_PWM_M_MASK;
+		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[4], mask, val);
 
-	val = (pwm->period.pwm_size > 6) ? PM8XXX_PWM_SIZE_9_BIT : 0;
-	mask = PM8XXX_PWM_SIZE_9_BIT;
-	pm8xxx_pwm_save(&pwm->pwm_ctl[5], mask, val);
+		val = (pwm->period.pwm_size > 6) ? PM8XXX_PWM_SIZE_9_BIT : 0;
+		mask = PM8XXX_PWM_SIZE_9_BIT;
+		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[5], mask, val);
+	} else {
+		val = ((pwm->period.clk + 1) << PM8XXX_PWM_CLK_SEL_SHIFT)
+			& PM8XXX_PWM_CLK_SEL_MASK;
+		val |= (pwm->period.pre_div << PM8XXX_PWM_PREDIVIDE_SHIFT)
+			& PM8XXX_PWM_PREDIVIDE_MASK;
+		val |= (pwm->period.pre_div_exp << PM8XXX_PWM_M_SHIFT)
+				& PM8XXX_PWM_M_MASK;
+		val |= (((pwm->period.pwm_size > 6) ? PM8XXX_PWM_SIZE_9_BIT : 0)
+			<< PM8XXX_PWM_SIZE_SHIFT) & PM8XXX_PWM_SIZE_MASK;
+
+		mask = PM8XXX_PWM_CLK_SEL_MASK | PM8XXX_PWM_PREDIVIDE_MASK |
+			PM8XXX_PWM_M_MASK | PM8XXX_PWM_SIZE_MASK;
+		pm8xxx_pwm_save(&pwm->pwm_ctl1, mask, val);
+	}
 }
 
 static void pm8xxx_pwm_save_pwm_value(struct pwm_device *pwm)
 {
 	u8	mask, val;
 
-	pwm->pwm_ctl[3] = pwm->pwm_value;
-
-	val = (pwm->period.pwm_size > 6) ? (pwm->pwm_value >> 1) : 0;
-	mask = PM8XXX_PWM_VALUE_BIT8;
-	pm8xxx_pwm_save(&pwm->pwm_ctl[4], mask, val);
+	if (pwm_chip->is_lpg_supported) {
+		val = (pwm->period.pwm_size > 6) ? (pwm->pwm_value >> 1) : 0;
+		pwm->pwm_lpg_ctl[3] = pwm->pwm_value;
+		mask = PM8XXX_PWM_VALUE_BIT8;
+		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[4], mask, val);
+	} else {
+		val = (pwm->period.pwm_size > 6) ? (pwm->pwm_value >> 8) : 0;
+		pwm->pwm_ctl2 = pwm->pwm_value;
+		mask = PM8XXX_PWM_VALUE_BIT0;
+		pm8xxx_pwm_save(&pwm->pwm_ctl1, mask, val);
+	}
 }
 
 static void pm8xxx_pwm_save_duty_time(struct pwm_device *pwm,
@@ -468,7 +548,7 @@
 	val = i << PM8XXX_PWM_1KHZ_COUNT_SHIFT;
 
 	mask = PM8XXX_PWM_1KHZ_COUNT_MASK;
-	pm8xxx_pwm_save(&pwm->pwm_ctl[0], mask, val);
+	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[0], mask, val);
 }
 
 static void pm8xxx_pwm_save_pause(struct pwm_device *pwm,
@@ -477,7 +557,7 @@
 	int	i, pause_cnt, time_cnt;
 	u8	mask, val;
 
-	time_cnt = (pwm->pwm_ctl[0] & PM8XXX_PWM_1KHZ_COUNT_MASK)
+	time_cnt = (pwm->pwm_lpg_ctl[0] & PM8XXX_PWM_1KHZ_COUNT_MASK)
 				>> PM8XXX_PWM_1KHZ_COUNT_SHIFT;
 	if (lut->flags & PM_PWM_LUT_PAUSE_HI_EN) {
 		pause_cnt = (lut->lut_pause_hi + duty_msec[time_cnt] / 2)
@@ -495,7 +575,7 @@
 	}
 
 	mask = PM8XXX_PWM_PAUSE_COUNT_HI_MASK | PM8XXX_PWM_PAUSE_ENABLE_HIGH;
-	pm8xxx_pwm_save(&pwm->pwm_ctl[5], mask, val);
+	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[5], mask, val);
 
 	if (lut->flags & PM_PWM_LUT_PAUSE_LO_EN) {
 		/* Linear search for pause time */
@@ -513,10 +593,35 @@
 	}
 
 	mask = PM8XXX_PWM_PAUSE_COUNT_LO_MASK | PM8XXX_PWM_PAUSE_ENABLE_LOW;
-	pm8xxx_pwm_save(&pwm->pwm_ctl[6], mask, val);
+	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[6], mask, val);
 }
 
-static int pm8xxx_pwm_write(struct pwm_device *pwm, int start, int end)
+static int pm8xxx_pwm_write(struct pwm_device *pwm)
+{
+	int rc = 0;
+
+	rc = pm8xxx_writeb(pwm->chip->dev->parent,
+			   SSBI_REG_ADDR_PWM_CTL1(pwm->pwm_id),
+			   pwm->pwm_ctl1);
+	if (rc) {
+		pr_err("pm8xxx_writeb() failed: rc=%d (PWM Ctl1[%d])\n",
+							rc, pwm->pwm_id);
+		return rc;
+	}
+
+	rc = pm8xxx_writeb(pwm->chip->dev->parent,
+			   SSBI_REG_ADDR_PWM_CTL2(pwm->pwm_id),
+			   pwm->pwm_ctl2);
+	if (rc) {
+		pr_err("pm8xxx_writeb() failed: rc=%d (PWM Ctl2[%d])\n",
+							rc, pwm->pwm_id);
+		return rc;
+	}
+
+	return rc;
+}
+
+static int pm8xxx_lpg_pwm_write(struct pwm_device *pwm, int start, int end)
 {
 	int	i, rc;
 
@@ -524,7 +629,7 @@
 	for (i = end - 1; i >= start; i--) {
 		rc = pm8xxx_writeb(pwm->chip->dev->parent,
 				   SSBI_REG_ADDR_LPG_CTL(i),
-				   pwm->pwm_ctl[i]);
+				   pwm->pwm_lpg_ctl[i]);
 		if (rc) {
 			pr_err("pm8xxx_writeb(): rc=%d (PWM Ctl[%d])\n", rc, i);
 			return rc;
@@ -543,10 +648,10 @@
 			     lut->lut_hi_index, lut->flags);
 	pm8xxx_pwm_save_duty_time(pwm, lut);
 	pm8xxx_pwm_save_pause(pwm, lut);
-	pm8xxx_pwm_save(&pwm->pwm_ctl[1], PM8XXX_PWM_BYPASS_LUT, 0);
+	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[1], PM8XXX_PWM_BYPASS_LUT, 0);
 
 	pm8xxx_pwm_bank_sel(pwm);
-	rc = pm8xxx_pwm_write(pwm, 0, 7);
+	rc = pm8xxx_lpg_pwm_write(pwm, 0, 7);
 
 	return rc;
 }
@@ -561,16 +666,17 @@
 {
 	struct pwm_device	*pwm;
 
-	if (pwm_id > PM8XXX_PWM_CHANNELS || pwm_id < 0) {
-		pr_err("Invalid pwm_id: %d with %s\n",
-		       pwm_id, label ? label : ".");
-		return ERR_PTR(-EINVAL);
-	}
 	if (pwm_chip == NULL) {
 		pr_err("No pwm_chip\n");
 		return ERR_PTR(-ENODEV);
 	}
 
+	if (pwm_id >= pwm_chip->pwm_channels || pwm_id < 0) {
+		pr_err("Invalid pwm_id: %d with %s\n",
+		       pwm_id, label ? label : ".");
+		return ERR_PTR(-EINVAL);
+	}
+
 	mutex_lock(&pwm_chip->pwm_mutex);
 	pwm = &pwm_chip->pwm_dev[pwm_id];
 	if (!pwm->in_use) {
@@ -598,13 +704,17 @@
 
 	mutex_lock(&pwm->chip->pwm_mutex);
 	if (pwm->in_use) {
-		pm8xxx_pwm_bank_sel(pwm);
-		pm8xxx_pwm_start(pwm, 0, 0);
-
+		if (pwm_chip->is_lpg_supported) {
+			pm8xxx_pwm_bank_sel(pwm);
+			pm8xxx_pwm_start(pwm, 0, 0);
+		} else {
+			pm8xxx_pwm_disable(pwm);
+		}
 		pwm->in_use = 0;
 		pwm->label = NULL;
 	}
-	pm8xxx_pwm_bank_enable(pwm, 0);
+	if (pwm_chip->is_lpg_supported)
+		pm8xxx_pwm_bank_enable(pwm, 0);
 	mutex_unlock(&pwm->chip->pwm_mutex);
 }
 EXPORT_SYMBOL_GPL(pwm_free);
@@ -618,7 +728,7 @@
 int pwm_config(struct pwm_device *pwm, int duty_us, int period_us)
 {
 	struct pm8xxx_pwm_period *period;
-	int	rc;
+	int	rc = 0;
 
 	if (pwm == NULL || IS_ERR(pwm) ||
 		duty_us > period_us ||
@@ -649,11 +759,16 @@
 
 	pm8xxx_pwm_calc_pwm_value(pwm, period_us, duty_us);
 	pm8xxx_pwm_save_pwm_value(pwm);
-	pm8xxx_pwm_save(&pwm->pwm_ctl[1],
-			PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT);
 
-	pm8xxx_pwm_bank_sel(pwm);
-	rc = pm8xxx_pwm_write(pwm, 1, 6);
+	if (pwm_chip->is_lpg_supported) {
+		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[1],
+				PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT);
+
+		pm8xxx_pwm_bank_sel(pwm);
+		rc = pm8xxx_lpg_pwm_write(pwm, 1, 6);
+	} else {
+		rc = pm8xxx_pwm_write(pwm);
+	}
 
 	pr_debug("duty/period=%u/%u usec: pwm_value=%d (of %d)\n",
 		 (unsigned)duty_us, (unsigned)period_us,
@@ -671,7 +786,7 @@
  */
 int pwm_enable(struct pwm_device *pwm)
 {
-	int	rc;
+	int	rc = 0;
 
 	if (pwm == NULL || IS_ERR(pwm)) {
 		pr_err("Invalid pwm handle\n");
@@ -687,10 +802,13 @@
 		pr_err("pwm_id: %d: stale handle?\n", pwm->pwm_id);
 		rc = -EINVAL;
 	} else {
-		rc = pm8xxx_pwm_bank_enable(pwm, 1);
-
-		pm8xxx_pwm_bank_sel(pwm);
-		pm8xxx_pwm_start(pwm, 1, 0);
+		if (pwm_chip->is_lpg_supported) {
+			rc = pm8xxx_pwm_bank_enable(pwm, 1);
+			pm8xxx_pwm_bank_sel(pwm);
+			pm8xxx_pwm_start(pwm, 1, 0);
+		} else {
+			pm8xxx_pwm_enable(pwm);
+		}
 	}
 	mutex_unlock(&pwm->chip->pwm_mutex);
 	return rc;
@@ -710,10 +828,13 @@
 
 	mutex_lock(&pwm->chip->pwm_mutex);
 	if (pwm->in_use) {
-		pm8xxx_pwm_bank_sel(pwm);
-		pm8xxx_pwm_start(pwm, 0, 0);
-
-		pm8xxx_pwm_bank_enable(pwm, 0);
+		if (pwm_chip->is_lpg_supported) {
+			pm8xxx_pwm_bank_sel(pwm);
+			pm8xxx_pwm_start(pwm, 0, 0);
+			pm8xxx_pwm_bank_enable(pwm, 0);
+		} else {
+			pm8xxx_pwm_disable(pwm);
+		}
 	}
 	mutex_unlock(&pwm->chip->pwm_mutex);
 }
@@ -748,8 +869,14 @@
 	pwm->period.pre_div_exp = period->pre_div_exp;
 
 	pm8xxx_pwm_save_period(pwm);
-	pm8xxx_pwm_bank_sel(pwm);
-	rc = pm8xxx_pwm_write(pwm, 4, 6);
+
+	if (pwm_chip->is_lpg_supported) {
+		pm8xxx_pwm_bank_sel(pwm);
+		rc = pm8xxx_lpg_pwm_write(pwm, 4, 6);
+	} else {
+		rc = pm8xxx_pwm_write(pwm);
+	}
+
 
 out_unlock:
 	mutex_unlock(&pwm->chip->pwm_mutex);
@@ -784,11 +911,15 @@
 	pwm->pwm_value = pwm_value;
 
 	pm8xxx_pwm_save_pwm_value(pwm);
-	pm8xxx_pwm_save(&pwm->pwm_ctl[1],
-			PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT);
 
-	pm8xxx_pwm_bank_sel(pwm);
-	rc = pm8xxx_pwm_write(pwm, 1, 6);
+	if (pwm_chip->is_lpg_supported) {
+		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[1],
+				PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT);
+		pm8xxx_pwm_bank_sel(pwm);
+		rc = pm8xxx_lpg_pwm_write(pwm, 1, 6);
+	} else {
+		rc = pm8xxx_pwm_write(pwm);
+	}
 
 	if (rc)
 		pr_err("[%d]: pm8xxx_pwm_write: rc=%d\n", pwm->pwm_id, rc);
@@ -832,6 +963,12 @@
 		pr_err("No pwm_chip\n");
 		return -ENODEV;
 	}
+
+	if (pwm->chip->is_lpg_supported == 0) {
+		pr_err("LPG module isn't supported\n");
+		return -EINVAL;
+	}
+
 	if (idx_len >= PM_PWM_LUT_SIZE && start_idx) {
 		pr_err("Wrong LUT size or index\n");
 		return -EINVAL;
@@ -904,6 +1041,10 @@
 		pr_err("No pwm_chip\n");
 		return -ENODEV;
 	}
+	if (pwm->chip->is_lpg_supported == 0) {
+		pr_err("LPG module isn't supported\n");
+		return -EINVAL;
+	}
 
 	mutex_lock(&pwm->chip->pwm_mutex);
 	if (start) {
@@ -940,7 +1081,7 @@
 	struct device		*dev;
 	struct dentry		*dent;
 
-	struct pm8xxx_pwm_user	user[PM8XXX_PWM_CHANNELS];
+	struct pm8xxx_pwm_user	*user;
 };
 
 static struct pm8xxx_pwm_dbg_device *pmic_dbg_device;
@@ -1101,6 +1242,14 @@
 		return -ENOMEM;
 	}
 
+	dbgdev->user = kcalloc(pwm_chip->pwm_channels,
+				sizeof(struct pm8xxx_pwm_user), GFP_KERNEL);
+	if (dbgdev->user == NULL) {
+		pr_err("kcalloc() failed.\n");
+		kfree(dbgdev);
+		return -ENOMEM;
+	}
+
 	mutex_init(&dbgdev->dbg_mutex);
 
 	dbgdev->dev = dev;
@@ -1113,7 +1262,7 @@
 
 	dbgdev->dent = dent;
 
-	for (i = 0; i < PM8XXX_PWM_CHANNELS; i++) {
+	for (i = 0; i < pwm_chip->pwm_channels; i++) {
 		char pwm_ch[] = "0";
 
 		pwm_ch[0] = '0' + i;
@@ -1160,6 +1309,7 @@
 static int __devexit pm8xxx_pwm_dbg_remove(void)
 {
 	if (pmic_dbg_device) {
+		kfree(pmic_dbg_device->user);
 		debugfs_remove_recursive(pmic_dbg_device->dent);
 		kfree(pmic_dbg_device);
 	}
@@ -1184,6 +1334,7 @@
 {
 	struct pm8xxx_pwm_chip	*chip;
 	int	i;
+	enum pm8xxx_version version;
 
 	chip = kzalloc(sizeof *chip, GFP_KERNEL);
 	if (chip == NULL) {
@@ -1191,15 +1342,39 @@
 		return -ENOMEM;
 	}
 
-	for (i = 0; i < PM8XXX_PWM_CHANNELS; i++) {
-		chip->pwm_dev[i].pwm_id = i;
-		chip->pwm_dev[i].chip = chip;
-	}
-
 	mutex_init(&chip->pwm_mutex);
 
 	chip->dev = &pdev->dev;
 	pwm_chip = chip;
+
+	version = pm8xxx_get_version(chip->dev->parent);
+
+	if (version == PM8XXX_VERSION_8921 ||
+			version == PM8XXX_VERSION_8058) {
+		chip->is_lpg_supported = 1;
+	}
+	if (chip->is_lpg_supported) {
+		chip->pwm_channels = PM8XXX_LPG_PWM_CHANNELS;
+		chip->pwm_total_pre_divs = NUM_LPG_PRE_DIVIDE;
+	} else {
+		chip->pwm_channels = PM8XXX_PWM_CHANNELS;
+		chip->pwm_total_pre_divs = NUM_PWM_PRE_DIVIDE;
+	}
+
+	chip->pwm_dev = kcalloc(chip->pwm_channels, sizeof(struct pwm_device),
+								GFP_KERNEL);
+	if (chip->pwm_dev == NULL) {
+		pr_err("kcalloc() failed.\n");
+		mutex_destroy(&chip->pwm_mutex);
+		kfree(chip);
+		return -ENOMEM;
+	}
+
+	for (i = 0; i < chip->pwm_channels; i++) {
+		chip->pwm_dev[i].pwm_id = i;
+		chip->pwm_dev[i].chip = chip;
+	}
+
 	platform_set_drvdata(pdev, chip);
 
 	if (pm8xxx_pwm_dbg_probe(&pdev->dev) < 0)
@@ -1214,6 +1389,7 @@
 	struct pm8xxx_pwm_chip	*chip = dev_get_drvdata(pdev->dev.parent);
 
 	pm8xxx_pwm_dbg_remove();
+	kfree(chip->pwm_dev);
 	mutex_destroy(&chip->pwm_mutex);
 	platform_set_drvdata(pdev, NULL);
 	kfree(chip);
diff --git a/drivers/power/pm8921-bms.c b/drivers/power/pm8921-bms.c
index e666bfc..fdbc819 100644
--- a/drivers/power/pm8921-bms.c
+++ b/drivers/power/pm8921-bms.c
@@ -88,30 +88,122 @@
 	unsigned int		pmic_bms_irq[PM_BMS_MAX_INTS];
 	DECLARE_BITMAP(enabled_irqs, PM_BMS_MAX_INTS);
 	spinlock_t		bms_output_lock;
+	struct single_row_lut	*adjusted_fcc_temp_lut;
 };
 
 static struct pm8921_bms_chip *the_chip;
 
 #define DEFAULT_RBATT_MOHMS		128
-#define DEFAULT_UNUSABLE_CHARGE_MAH	10
 #define DEFAULT_OCV_MICROVOLTS		3900000
-#define DEFAULT_REMAINING_CHARGE_MAH	990
-#define DEFAULT_COULUMB_COUNTER		0
 #define DEFAULT_CHARGE_CYCLES		0
 
+static int last_chargecycles = DEFAULT_CHARGE_CYCLES;
+static int last_charge_increase;
+module_param(last_chargecycles, int, 0644);
+module_param(last_charge_increase, int, 0644);
+
 static int last_rbatt = -EINVAL;
 static int last_ocv_uv = -EINVAL;
 static int last_soc = -EINVAL;
 static int last_real_fcc = -EINVAL;
+static int last_real_fcc_batt_temp = -EINVAL;
 
-static int last_chargecycles = DEFAULT_CHARGE_CYCLES;
-static int last_charge_increase;
+static int bms_ops_set(const char *val, const struct kernel_param *kp)
+{
+	if (*(int *)kp->arg == -EINVAL)
+		return param_set_int(val, kp);
+	else
+		return 0;
+}
 
-module_param(last_rbatt, int, 0644);
-module_param(last_ocv_uv, int, 0644);
-module_param(last_chargecycles, int, 0644);
-module_param(last_charge_increase, int, 0644);
-module_param(last_real_fcc, int, 0644);
+static struct kernel_param_ops bms_param_ops = {
+	.set = bms_ops_set,
+	.get = param_get_int,
+};
+
+module_param_cb(last_rbatt, &bms_param_ops, &last_rbatt, 0644);
+module_param_cb(last_ocv_uv, &bms_param_ops, &last_ocv_uv, 0644);
+module_param_cb(last_soc, &bms_param_ops, &last_soc, 0644);
+
+static int interpolate_fcc(struct pm8921_bms_chip *chip, int batt_temp);
+static void readjust_fcc_table(void)
+{
+	struct single_row_lut *temp, *old;
+	int i, fcc, ratio;
+
+	if (!the_chip->fcc_temp_lut) {
+		pr_err("The static fcc lut table is NULL\n");
+		return;
+	}
+
+	temp = kzalloc(sizeof(struct single_row_lut), GFP_KERNEL);
+	if (!temp) {
+		pr_err("Cannot allocate memory for adjusted fcc table\n");
+		return;
+	}
+
+	fcc = interpolate_fcc(the_chip, last_real_fcc_batt_temp);
+
+	temp->cols = the_chip->fcc_temp_lut->cols;
+	for (i = 0; i < the_chip->fcc_temp_lut->cols; i++) {
+		temp->x[i] = the_chip->fcc_temp_lut->x[i];
+		ratio = div_u64(the_chip->fcc_temp_lut->y[i] * 1000, fcc);
+		temp->y[i] =  (ratio * last_real_fcc);
+		temp->y[i] /= 1000;
+		pr_debug("temp=%d, staticfcc=%d, adjfcc=%d, ratio=%d\n",
+				temp->x[i], the_chip->fcc_temp_lut->y[i],
+				temp->y[i], ratio);
+	}
+
+	old = the_chip->adjusted_fcc_temp_lut;
+	the_chip->adjusted_fcc_temp_lut = temp;
+	kfree(old);
+}
+
+static int bms_last_real_fcc_set(const char *val,
+				const struct kernel_param *kp)
+{
+	int rc = 0;
+
+	if (last_real_fcc == -EINVAL)
+		rc = param_set_int(val, kp);
+	if (rc) {
+		pr_err("Failed to set last_real_fcc rc=%d\n", rc);
+		return rc;
+	}
+	if (last_real_fcc_batt_temp != -EINVAL)
+		readjust_fcc_table();
+	return rc;
+}
+static struct kernel_param_ops bms_last_real_fcc_param_ops = {
+	.set = bms_last_real_fcc_set,
+	.get = param_get_int,
+};
+module_param_cb(last_real_fcc, &bms_last_real_fcc_param_ops,
+					&last_real_fcc, 0644);
+
+static int bms_last_real_fcc_batt_temp_set(const char *val,
+				const struct kernel_param *kp)
+{
+	int rc = 0;
+
+	if (last_real_fcc_batt_temp == -EINVAL)
+		rc = param_set_int(val, kp);
+	if (rc) {
+		pr_err("Failed to set last_real_fcc_batt_temp rc=%d\n", rc);
+		return rc;
+	}
+	if (last_real_fcc != -EINVAL)
+		readjust_fcc_table();
+	return rc;
+}
+
+static struct kernel_param_ops bms_last_real_fcc_batt_temp_param_ops = {
+	.set = bms_last_real_fcc_batt_temp_set,
+	.get = param_get_int,
+};
+module_param_cb(last_real_fcc_batt_temp, &bms_last_real_fcc_batt_temp_param_ops,
+					&last_real_fcc_batt_temp, 0644);
 
 static int pm_bms_get_rt_status(struct pm8921_bms_chip *chip, int irq_id)
 {
@@ -247,25 +339,34 @@
 	return 0;
 }
 
-#define V_PER_BIT_MUL_FACTOR	293
-#define INTRINSIC_OFFSET	0x6000
-static int vbatt_to_microvolt(unsigned int a)
+#define V_PER_BIT_MUL_FACTOR	97656
+#define V_PER_BIT_DIV_FACTOR	1000
+#define XOADC_INTRINSIC_OFFSET	0x6000
+static int xoadc_reading_to_microvolt(unsigned int a)
 {
-	if (a <= INTRINSIC_OFFSET)
+	if (a <= XOADC_INTRINSIC_OFFSET)
 		return 0;
 
-	return (a - INTRINSIC_OFFSET) * V_PER_BIT_MUL_FACTOR;
+	return (a - XOADC_INTRINSIC_OFFSET)
+			* V_PER_BIT_MUL_FACTOR / V_PER_BIT_DIV_FACTOR;
 }
 
 #define XOADC_CALIB_UV		625000
-static int adjust_xo_reading(struct pm8921_bms_chip *chip, unsigned int uv)
+#define VBATT_MUL_FACTOR	3
+static int adjust_xo_vbatt_reading(struct pm8921_bms_chip *chip,
+							unsigned int uv)
 {
-	u64 numerator = ((u64)uv - chip->xoadc_v0625) * XOADC_CALIB_UV;
-	u64 denominator =  chip->xoadc_v125 - chip->xoadc_v0625;
+	u64 numerator, denominator;
 
+	if (uv == 0)
+		return 0;
+
+	numerator = ((u64)uv - chip->xoadc_v0625) * XOADC_CALIB_UV;
+	denominator =  chip->xoadc_v125 - chip->xoadc_v0625;
 	if (denominator == 0)
-		return uv;
-	return XOADC_CALIB_UV + div_u64(numerator, denominator);
+		return uv * VBATT_MUL_FACTOR;
+	return (XOADC_CALIB_UV + div_u64(numerator, denominator))
+						* VBATT_MUL_FACTOR;
 }
 
 #define CC_RESOLUTION_N_V1	1085069
@@ -333,8 +434,10 @@
 		pr_err("fail to read LAST_GOOD_OCV_VALUE rc = %d\n", rc);
 		return rc;
 	}
-	*result = vbatt_to_microvolt(reading);
+	*result = xoadc_reading_to_microvolt(reading);
 	pr_debug("raw = %04x ocv_microV = %u\n", reading, *result);
+	if (*result != 0)
+		last_ocv_uv = *result;
 	return 0;
 }
 
@@ -348,8 +451,10 @@
 		pr_err("fail to read VBATT_FOR_RBATT rc = %d\n", rc);
 		return rc;
 	}
-	*result = vbatt_to_microvolt(reading);
+	*result = xoadc_reading_to_microvolt(reading);
 	pr_debug("raw = %04x vbatt_for_r_microV = %u\n", reading, *result);
+	*result = adjust_xo_vbatt_reading(chip, *result);
+	pr_debug("after adj vbatt_for_r_uV = %u\n", *result);
 	return 0;
 }
 
@@ -378,8 +483,10 @@
 		pr_err("fail to read OCV_FOR_RBATT rc = %d\n", rc);
 		return rc;
 	}
-	*result = vbatt_to_microvolt(reading);
-	pr_debug("read = %04x ocv_for_r_microV = %u\n", reading, *result);
+	*result = xoadc_reading_to_microvolt(reading);
+	pr_debug("raw = %04x ocv_for_r_uV = %u\n", reading, *result);
+	*result = adjust_xo_vbatt_reading(chip, *result);
+	pr_debug("after adj ocv_for_r_uV = %u\n", *result);
 	return 0;
 }
 
@@ -444,6 +551,11 @@
 	return interpolate_single_lut(chip->fcc_temp_lut, batt_temp);
 }
 
+static int interpolate_fcc_adjusted(struct pm8921_bms_chip *chip, int batt_temp)
+{
+	return interpolate_single_lut(chip->adjusted_fcc_temp_lut, batt_temp);
+}
+
 static int interpolate_scalingfactor_fcc(struct pm8921_bms_chip *chip,
 								int cycles)
 {
@@ -642,14 +754,12 @@
 		pr_err("fail to read ocv_for_rbatt rc = %d\n", rc);
 		ocv = 0;
 	}
-	ocv = adjust_xo_reading(chip, ocv);
 
 	rc = read_vbatt_for_rbatt(chip, &vbatt);
 	if (rc) {
 		pr_err("fail to read vbatt_for_rbatt rc = %d\n", rc);
 		ocv = 0;
 	}
-	vbatt = adjust_xo_reading(chip, vbatt);
 
 	rc = read_vsense_for_rbatt(chip, &vsense);
 	if (rc) {
@@ -665,6 +775,7 @@
 		return -EINVAL;
 	}
 	r_batt = ((ocv - vbatt) * chip->r_sense) / vsense;
+	last_rbatt = r_batt;
 	pr_debug("r_batt = %umilliOhms", r_batt);
 	return r_batt;
 }
@@ -674,16 +785,18 @@
 {
 	int initfcc, result, scalefactor = 0;
 
-	initfcc = interpolate_fcc(chip, batt_temp);
-	pr_debug("intfcc = %umAh batt_temp = %d\n", initfcc, batt_temp);
+	if (chip->adjusted_fcc_temp_lut == NULL) {
+		initfcc = interpolate_fcc(chip, batt_temp);
 
-	scalefactor = interpolate_scalingfactor_fcc(chip, chargecycles);
-	pr_debug("scalefactor = %d batt_temp = %d\n", scalefactor, batt_temp);
+		scalefactor = interpolate_scalingfactor_fcc(chip, chargecycles);
 
-	/* Multiply the initial FCC value by the scale factor. */
-	result = (initfcc * scalefactor) / 100;
-	pr_debug("fcc mAh = %d\n", result);
-	return result;
+		/* Multiply the initial FCC value by the scale factor. */
+		result = (initfcc * scalefactor) / 100;
+		pr_debug("fcc mAh = %d\n", result);
+		return result;
+	} else {
+		return interpolate_fcc_adjusted(chip, batt_temp);
+	}
 }
 
 static int get_battery_uvolts(struct pm8921_bms_chip *chip, int *uvolts)
@@ -711,20 +824,18 @@
 	rc = get_battery_uvolts(chip, &vbatt);
 	if (rc) {
 		pr_err("failed to read vbatt from adc rc = %d\n", rc);
-		last_ocv_uv = DEFAULT_OCV_MICROVOLTS;
 		return rc;
 	}
 
 	rc =  pm8921_bms_get_battery_current(&ibatt);
 	if (rc) {
 		pr_err("failed to read batt current rc = %d\n", rc);
-		last_ocv_uv = DEFAULT_OCV_MICROVOLTS;
 		return rc;
 	}
 
 	rbatt = calculate_rbatt(the_chip);
 	if (rbatt < 0)
-		rbatt = DEFAULT_RBATT_MOHMS;
+		rbatt = (last_rbatt < 0) ? DEFAULT_RBATT_MOHMS : last_rbatt;
 	*ocv = vbatt + ibatt * rbatt;
 	return 0;
 }
@@ -771,8 +882,6 @@
 	if (rbatt < 0) {
 		rbatt = (last_rbatt < 0) ? DEFAULT_RBATT_MOHMS : last_rbatt;
 		pr_debug("rbatt unavailable assuming %d\n", rbatt);
-	} else {
-		last_rbatt = rbatt;
 	}
 
 	/* calculate unusable charge */
@@ -800,9 +909,6 @@
 	if (ocv == 0) {
 		ocv = last_ocv_uv;
 		pr_debug("ocv not available using last_ocv_uv=%d\n", ocv);
-	} else {
-		/* update the usespace param since a good ocv is available */
-		last_ocv_uv = ocv;
 	}
 
 	pc = calculate_pc(chip, ocv, batt_temp, chargecycles);
@@ -941,7 +1047,8 @@
 #define HKADC_V_PER_BIT_DIV_FACTOR	10
 static int calib_hkadc_convert_microvolt(unsigned int phy)
 {
-	return phy * HKADC_V_PER_BIT_MUL_FACTOR / HKADC_V_PER_BIT_DIV_FACTOR;
+	return (phy - 0x6000) *
+			HKADC_V_PER_BIT_MUL_FACTOR / HKADC_V_PER_BIT_DIV_FACTOR;
 }
 
 static void calib_hkadc(struct pm8921_bms_chip *chip)
@@ -954,10 +1061,10 @@
 		pr_err("ADC failed for 1.25volts rc = %d\n", rc);
 		return;
 	}
-	voltage = calib_hkadc_convert_microvolt(result.physical);
+	voltage = calib_hkadc_convert_microvolt(result.adc_code);
 
-	pr_debug("result 1.25v = 0x%llx, voltage = %dmV adc_meas = %lld\n",
-				result.physical, voltage, result.measurement);
+	pr_debug("result 1.25v = 0x%x, voltage = %duV adc_meas = %lld\n",
+				result.adc_code, voltage, result.measurement);
 
 	/* check for valid range */
 	if (voltage > XOADC_MAX_1P25V)
@@ -971,9 +1078,9 @@
 		pr_err("ADC failed for 1.25volts rc = %d\n", rc);
 		return;
 	}
-	voltage = calib_hkadc_convert_microvolt(result.physical);
-	pr_debug("result 0.625V = 0x%llx, voltage = %dmV adc_mead = %lld\n",
-				result.physical, voltage, result.measurement);
+	voltage = calib_hkadc_convert_microvolt(result.adc_code);
+	pr_debug("result 0.625V = 0x%x, voltage = %duV adc_mead = %lld\n",
+				result.adc_code, voltage, result.measurement);
 	/* check for valid range */
 	if (voltage > XOADC_MAX_0P625V)
 		voltage = XOADC_MAX_0P625V;
@@ -1107,6 +1214,8 @@
 		batt_temp = (int)result.physical;
 		last_real_fcc = calculate_real_fcc(the_chip,
 						batt_temp, last_chargecycles);
+		last_real_fcc_batt_temp = batt_temp;
+		readjust_fcc_table();
 	}
 
 charge_cycle_calculation:
@@ -1272,13 +1381,19 @@
 	int ocv, rc;
 
 	/*
-	 * Check if a last_good_ocv is available,
-	 * if not compute it here at boot time.
+	 * Check if a ocv is available in bms hw,
+	 * if not compute it here at boot time and save it
+	 * in the last_ocv_uv.
 	 */
+	ocv = 0;
 	rc = read_last_good_ocv(chip, &ocv);
 	if (rc || ocv == 0) {
-		rc = adc_based_ocv(chip, &last_ocv_uv);
-		pr_err("failed to read ocv from adc and bms rc = %d\n", rc);
+		rc = adc_based_ocv(chip, &ocv);
+		if (rc) {
+			pr_err("failed to read adc based ocv rc = %d\n", rc);
+			ocv = DEFAULT_OCV_MICROVOLTS;
+		}
+		last_ocv_uv = ocv;
 	}
 	pr_debug("ocv = %d last_ocv_uv = %d\n", ocv, last_ocv_uv);
 }
@@ -1575,9 +1690,11 @@
 static int __devinit pm8921_bms_probe(struct platform_device *pdev)
 {
 	int rc = 0;
+	int vbatt;
 	struct pm8921_bms_chip *chip;
 	const struct pm8921_bms_platform_data *pdata
 				= pdev->dev.platform_data;
+
 	if (!pdata) {
 		pr_err("missing platform data\n");
 		return -EINVAL;
@@ -1626,12 +1743,16 @@
 
 	check_initial_ocv(chip);
 
+	/* initial hkadc calibration */
+	schedule_work(&chip->calib_hkadc_work);
 	/* enable the vbatt reading interrupts for scheduling hkadc calib */
 	pm8921_bms_enable_irq(chip, PM8921_BMS_GOOD_OCV);
 	pm8921_bms_enable_irq(chip, PM8921_BMS_OCV_FOR_R);
 
-	pr_info("OK battery_capacity_at_boot=%d\n",
-				pm8921_bms_get_percent_charge());
+	get_battery_uvolts(chip, &vbatt);
+	pr_info("OK battery_capacity_at_boot=%d volt = %d ocv = %d\n",
+				pm8921_bms_get_percent_charge(),
+				vbatt, last_ocv_uv);
 	return 0;
 
 free_chip:
@@ -1644,6 +1765,7 @@
 	struct pm8921_bms_chip *chip = platform_get_drvdata(pdev);
 
 	free_irqs(chip);
+	kfree(chip->adjusted_fcc_temp_lut);
 	platform_set_drvdata(pdev, NULL);
 	the_chip = NULL;
 	kfree(chip);
diff --git a/drivers/slimbus/slim-msm-ctrl.c b/drivers/slimbus/slim-msm-ctrl.c
index fc7c049..4a2ad3f 100644
--- a/drivers/slimbus/slim-msm-ctrl.c
+++ b/drivers/slimbus/slim-msm-ctrl.c
@@ -673,7 +673,9 @@
 	 * use their own slots
 	 * This "get" votes for messaging bandwidth
 	 */
-	if (dev->state != MSM_CTRL_SLEEPING)
+	if (txn->mc < SLIM_MSG_MC_BEGIN_RECONFIGURATION ||
+		txn->mc > SLIM_MSG_MC_RECONFIGURE_NOW ||
+		dev->state != MSM_CTRL_SLEEPING)
 		pm_runtime_get_sync(dev->dev);
 	mutex_lock(&dev->tx_lock);
 	if (dev->state == MSM_CTRL_ASLEEP) {
@@ -692,8 +694,7 @@
 		if (dev->ctrl.sched.usedslots != 0 &&
 			!dev->chan_active) {
 			dev->chan_active = true;
-			if (dev->state != MSM_CTRL_SLEEPING)
-				pm_runtime_get(dev->dev);
+			pm_runtime_get(dev->dev);
 		}
 	}
 	txn->rl--;
@@ -703,7 +704,9 @@
 
 	if (txn->dt == SLIM_MSG_DEST_ENUMADDR) {
 		mutex_unlock(&dev->tx_lock);
-		if (dev->state != MSM_CTRL_SLEEPING)
+		if (txn->mc < SLIM_MSG_MC_BEGIN_RECONFIGURATION ||
+			txn->mc > SLIM_MSG_MC_RECONFIGURE_NOW ||
+			dev->state != MSM_CTRL_SLEEPING)
 			pm_runtime_put(dev->dev);
 		return -EPROTONOSUPPORT;
 	}
@@ -776,11 +779,26 @@
 			txn->mc == SLIM_MSG_MC_RECONFIGURE_NOW &&
 			txn->mt == SLIM_MSG_MT_CORE && timeout) {
 		timeout = wait_for_completion_timeout(&dev->reconf, HZ);
-		if (timeout)
-			dev->reconf_busy = false;
+		dev->reconf_busy = false;
+		if (timeout) {
+			clk_disable(dev->rclk);
+			disable_irq(dev->irq);
+			dev->state = MSM_CTRL_ASLEEP;
+		}
 	}
+	if (!timeout && dev->state == MSM_CTRL_SLEEPING &&
+			txn->mc >= SLIM_MSG_MC_BEGIN_RECONFIGURATION &&
+			txn->mc <= SLIM_MSG_MC_RECONFIGURE_NOW &&
+			txn->mt == SLIM_MSG_MT_CORE) {
+		dev->reconf_busy = false;
+		dev->state = MSM_CTRL_AWAKE;
+		dev_err(dev->dev, "clock pause failed");
+		mutex_unlock(&dev->tx_lock);
+		return -ETIMEDOUT;
+	}
+
 	mutex_unlock(&dev->tx_lock);
-	if (!txn->rbuf && dev->state != MSM_CTRL_SLEEPING)
+	if (!txn->rbuf && dev->state == MSM_CTRL_AWAKE)
 		pm_runtime_put(dev->dev);
 
 	if (!timeout)
@@ -831,6 +849,7 @@
 	 * we get the message
 	 */
 	usleep_range(5000, 5000);
+	dev->state = MSM_CTRL_AWAKE;
 	return 0;
 }
 
@@ -1855,36 +1874,23 @@
 {
 	struct platform_device *pdev = to_platform_device(device);
 	struct msm_slim_ctrl *dev = platform_get_drvdata(pdev);
-	int ret;
 	dev_dbg(device, "pm_runtime: suspending...\n");
 	dev->state = MSM_CTRL_SLEEPING;
-	ret = slim_ctrl_clk_pause(&dev->ctrl, false, SLIM_CLK_UNSPECIFIED);
-	/* Make sure clock pause goes through */
-	if (!ret) {
-		clk_disable(dev->rclk);
-		disable_irq(dev->irq);
-		dev->state = MSM_CTRL_ASLEEP;
-	} else
-		dev->state = MSM_CTRL_AWAKE;
-	return ret;
+	return slim_ctrl_clk_pause(&dev->ctrl, false, SLIM_CLK_UNSPECIFIED);
 }
 
 static int msm_slim_runtime_resume(struct device *device)
 {
 	struct platform_device *pdev = to_platform_device(device);
 	struct msm_slim_ctrl *dev = platform_get_drvdata(pdev);
-	int ret = 0;
 	dev_dbg(device, "pm_runtime: resuming...\n");
 	mutex_lock(&dev->tx_lock);
 	if (dev->state == MSM_CTRL_ASLEEP) {
 		mutex_unlock(&dev->tx_lock);
-		ret = slim_ctrl_clk_pause(&dev->ctrl, true, 0);
-		if (!ret)
-			dev->state = MSM_CTRL_AWAKE;
-		return ret;
+		return slim_ctrl_clk_pause(&dev->ctrl, true, 0);
 	}
 	mutex_unlock(&dev->tx_lock);
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
diff --git a/drivers/slimbus/slimbus.c b/drivers/slimbus/slimbus.c
index 3b79129..bb30570 100644
--- a/drivers/slimbus/slimbus.c
+++ b/drivers/slimbus/slimbus.c
@@ -892,10 +892,6 @@
 	cur = slim_slicecodefromsize(sl);
 	ec = ((sl | (1 << 3)) | ((msg->start_offset & 0xFFF) << 4));
 
-	ret = slim_ctrl_clk_pause(ctrl, true, 0);
-	if (ret)
-		return ret;
-
 	if (wbuf)
 		mlen += len;
 	if (rbuf) {
@@ -1127,10 +1123,6 @@
 	u8 chan = (u8)(chanh & 0xFF);
 	struct slim_ich *slc = &ctrl->chans[chan];
 
-	ret = slim_ctrl_clk_pause(ctrl, true, 0);
-	if (ret)
-		return ret;
-
 	mutex_lock(&ctrl->m_ctrl);
 	/* Make sure the channel is not already pending reconf. or active */
 	if (slc->state >= SLIM_CH_PENDING_ACTIVE) {
@@ -1193,11 +1185,8 @@
 int slim_disconnect_ports(struct slim_device *sb, u32 *ph, int nph)
 {
 	struct slim_controller *ctrl = sb->ctrl;
-	int i, ret;
+	int i;
 
-	ret = slim_ctrl_clk_pause(ctrl, true, 0);
-	if (ret)
-		return ret;
 	mutex_lock(&ctrl->m_ctrl);
 
 	for (i = 0; i < nph; i++)
@@ -2389,10 +2378,6 @@
 	u32 segdist;
 	struct slim_pending_ch *pch;
 
-	ret = slim_ctrl_clk_pause(ctrl, true, 0);
-	if (ret)
-		return ret;
-
 	mutex_lock(&ctrl->sched.m_reconf);
 	mutex_lock(&ctrl->m_ctrl);
 	ctrl->sched.pending_msgsl += sb->pending_msgsl - sb->cur_msgsl;
diff --git a/drivers/thermal/msm8960_tsens.c b/drivers/thermal/msm8960_tsens.c
index 12b3a42e..742bae5 100644
--- a/drivers/thermal/msm8960_tsens.c
+++ b/drivers/thermal/msm8960_tsens.c
@@ -722,7 +722,7 @@
 
 static int tsens_calib_sensors(void)
 {
-	int rc;
+	int rc = -ENODEV;
 
 	if (tmdev->hw_type == MSM_8660)
 		rc = tsens_calib_sensors8660();
diff --git a/drivers/usb/gadget/f_rmnet.c b/drivers/usb/gadget/f_rmnet.c
index 69f158a..6f0fb07 100644
--- a/drivers/usb/gadget/f_rmnet.c
+++ b/drivers/usb/gadget/f_rmnet.c
@@ -444,7 +444,7 @@
 	event->wIndex = cpu_to_le16(dev->ifc_id);
 	event->wLength = cpu_to_le16(0);
 
-	status = usb_ep_queue(dev->notify, dev->notify_req, GFP_KERNEL);
+	status = usb_ep_queue(dev->notify, dev->notify_req, GFP_ATOMIC);
 	if (status < 0) {
 		if (!atomic_read(&dev->online))
 			return;
@@ -789,8 +789,12 @@
 	spin_lock_irqsave(&dev->lock, flags);
 	dev->cdev = c->cdev;
 	f = &dev->port.func;
-	f->name = kasprintf(GFP_KERNEL, "rmnet%d", portno);
+	f->name = kasprintf(GFP_ATOMIC, "rmnet%d", portno);
 	spin_unlock_irqrestore(&dev->lock, flags);
+	if (!f->name) {
+		pr_err("%s: cannot allocate memory for name\n", __func__);
+		return -ENOMEM;
+	}
 
 	f->strings = rmnet_strings;
 	f->bind = frmnet_bind;
diff --git a/drivers/video/msm/hdmi_msm.c b/drivers/video/msm/hdmi_msm.c
index 63c2147..9805b6c 100644
--- a/drivers/video/msm/hdmi_msm.c
+++ b/drivers/video/msm/hdmi_msm.c
@@ -1231,8 +1231,12 @@
 	 * Configure the Threshold */
 	HDMI_OUTP_ND(0x0220, (10 << 16) | (2 << 0));
 
-	/* 0x0224 HDMI_DDC_SETUP */
-	HDMI_OUTP_ND(0x0224, 0);
+	/*
+	 * 0x0224 HDMI_DDC_SETUP
+	 * Setting 31:24 bits : Time units to wait before timeout
+	 * when clock is being stalled by external sink device
+	 */
+	HDMI_OUTP_ND(0x0224, 0xff000000);
 
 	/* 0x027C HDMI_DDC_REF
 	   [6] REFTIMER_ENABLE	Enable the timer
diff --git a/include/linux/ion.h b/include/linux/ion.h
index e63d282..9f220f8 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -76,6 +76,7 @@
 #define ION_IS_CACHED(__flags)	((__flags) & (1 << ION_CACHE_SHIFT))
 
 #ifdef __KERNEL__
+#include <linux/err.h>
 #include <mach/ion.h>
 struct ion_device;
 struct ion_heap;
diff --git a/include/media/msm_camera.h b/include/media/msm_camera.h
index 1ebbf88..327aee4 100644
--- a/include/media/msm_camera.h
+++ b/include/media/msm_camera.h
@@ -726,6 +726,89 @@
 #define CAMERA_EFFECT_NEON		11
 #define CAMERA_EFFECT_MAX		12
 
+/* QRD */
+#define CAMERA_EFFECT_BW		10
+#define CAMERA_EFFECT_BLUISH	12
+#define CAMERA_EFFECT_REDDISH	13
+#define CAMERA_EFFECT_GREENISH	14
+
+/* QRD */
+#define CAMERA_ANTIBANDING_OFF		0
+#define CAMERA_ANTIBANDING_50HZ		2
+#define CAMERA_ANTIBANDING_60HZ		1
+#define CAMERA_ANTIBANDING_AUTO		3
+
+#define CAMERA_CONTRAST_LV0			0
+#define CAMERA_CONTRAST_LV1			1
+#define CAMERA_CONTRAST_LV2			2
+#define CAMERA_CONTRAST_LV3			3
+#define CAMERA_CONTRAST_LV4			4
+#define CAMERA_CONTRAST_LV5			5
+#define CAMERA_CONTRAST_LV6			6
+#define CAMERA_CONTRAST_LV7			7
+#define CAMERA_CONTRAST_LV8			8
+#define CAMERA_CONTRAST_LV9			9
+
+#define CAMERA_BRIGHTNESS_LV0			0
+#define CAMERA_BRIGHTNESS_LV1			1
+#define CAMERA_BRIGHTNESS_LV2			2
+#define CAMERA_BRIGHTNESS_LV3			3
+#define CAMERA_BRIGHTNESS_LV4			4
+#define CAMERA_BRIGHTNESS_LV5			5
+#define CAMERA_BRIGHTNESS_LV6			6
+#define CAMERA_BRIGHTNESS_LV7			7
+#define CAMERA_BRIGHTNESS_LV8			8
+
+
+#define CAMERA_SATURATION_LV0			0
+#define CAMERA_SATURATION_LV1			1
+#define CAMERA_SATURATION_LV2			2
+#define CAMERA_SATURATION_LV3			3
+#define CAMERA_SATURATION_LV4			4
+#define CAMERA_SATURATION_LV5			5
+#define CAMERA_SATURATION_LV6			6
+#define CAMERA_SATURATION_LV7			7
+#define CAMERA_SATURATION_LV8			8
+
+#define CAMERA_SHARPNESS_LV0		0
+#define CAMERA_SHARPNESS_LV1		3
+#define CAMERA_SHARPNESS_LV2		6
+#define CAMERA_SHARPNESS_LV3		9
+#define CAMERA_SHARPNESS_LV4		12
+#define CAMERA_SHARPNESS_LV5		15
+#define CAMERA_SHARPNESS_LV6		18
+#define CAMERA_SHARPNESS_LV7		21
+#define CAMERA_SHARPNESS_LV8		24
+#define CAMERA_SHARPNESS_LV9		27
+#define CAMERA_SHARPNESS_LV10		30
+
+#define CAMERA_SETAE_AVERAGE		0
+#define CAMERA_SETAE_CENWEIGHT	1
+
+#define CFG_SET_SATURATION		30
+#define CFG_SET_SHARPNESS			31
+#define CFG_SET_TOUCHAEC            32
+#define CFG_SET_AUTO_FOCUS          33
+#define CFG_SET_AUTOFLASH 34
+/* QRD */
+#define CFG_SET_EXPOSURE_COMPENSATION 35
+
+#define  CAMERA_WB_AUTO               1 /* This list must match aeecamera.h */
+#define  CAMERA_WB_CUSTOM             2
+#define  CAMERA_WB_INCANDESCENT       3
+#define  CAMERA_WB_FLUORESCENT        4
+#define  CAMERA_WB_DAYLIGHT           5
+#define  CAMERA_WB_CLOUDY_DAYLIGHT    6
+#define  CAMERA_WB_TWILIGHT           7
+#define  CAMERA_WB_SHADE              8
+
+#define CAMERA_EXPOSURE_COMPENSATION_LV0			12
+#define CAMERA_EXPOSURE_COMPENSATION_LV1			6
+#define CAMERA_EXPOSURE_COMPENSATION_LV2			0
+#define CAMERA_EXPOSURE_COMPENSATION_LV3			-6
+#define CAMERA_EXPOSURE_COMPENSATION_LV4			-12
+
+
 struct sensor_pict_fps {
 	uint16_t prevfps;
 	uint16_t pictfps;
@@ -836,6 +919,16 @@
 	uint16_t index;
 };
 
+struct mirror_flip {
+	int32_t x_mirror;
+	int32_t y_flip;
+};
+
+struct cord {
+	uint32_t x;
+	uint32_t y;
+};
+
 struct sensor_cfg_data {
 	int cfgtype;
 	int mode;
@@ -861,6 +954,18 @@
 		struct sensor_calib_data calib_info;
 		struct sensor_output_info_t output_info;
 		struct sensor_eeprom_data_t eeprom_data;
+		/* QRD */
+		uint16_t antibanding;
+		uint8_t contrast;
+		uint8_t saturation;
+		uint8_t sharpness;
+		int8_t brightness;
+		int ae_mode;
+		uint8_t wb_val;
+		int8_t exp_compensation;
+		struct cord aec_cord;
+		int is_autoflash;
+		struct mirror_flip mirror_flip;
 	} cfg;
 };
 
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 643a497..155c6fd 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -66,12 +66,12 @@
 
 #define BT_DEFER_SETUP	7
 
-#define BT_POWER	8
+#define BT_POWER	9
 struct bt_power {
 	__u8 force_active;
 };
 
-#define BT_AMP_POLICY          9
+#define BT_AMP_POLICY          10
 
 /* Require BR/EDR (default policy)
  *   AMP controllers cannot be used
@@ -80,6 +80,13 @@
  */
 #define BT_AMP_POLICY_REQUIRE_BR_EDR   0
 
+/* Prefer BR/EDR
+ *   Allow use of AMP controllers
+ *   If the L2CAP channel is currently on AMP, move it to BR/EDR
+ *   Channel move requests from the remote device are allowed
+ */
+#define BT_AMP_POLICY_PREFER_BR_EDR    1
+
 /* Prefer AMP
  *   Allow use of AMP controllers
  *   If the L2CAP channel is currently on BR/EDR and AMP controller
@@ -89,14 +96,7 @@
  *     and configure the channel directly on an AMP controller rather
  *     than BR/EDR
  */
-#define BT_AMP_POLICY_PREFER_AMP       1
-
-/* Prefer BR/EDR
- *   Allow use of AMP controllers
- *   If the L2CAP channel is currently on AMP, move it to BR/EDR
- *   Channel move requests from the remote device are allowed
- */
-#define BT_AMP_POLICY_PREFER_BR_EDR    2
+#define BT_AMP_POLICY_PREFER_AMP       2
 
 #define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
 #define BT_ERR(fmt, arg...)  printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 75c3e04..a6e3485 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -224,13 +224,11 @@
 	if (!sent)
 		return;
 
+	if (!status)
+		memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH);
+
 	if (test_bit(HCI_MGMT, &hdev->flags))
 		mgmt_set_local_name_complete(hdev->id, sent, status);
-
-	if (status)
-		return;
-
-	memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH);
 }
 
 static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 361c984..9beea74 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -750,7 +750,7 @@
 			break;
 		}
 
-		if ((opt > BT_AMP_POLICY_PREFER_BR_EDR) ||
+		if ((opt > BT_AMP_POLICY_PREFER_AMP) ||
 			((l2cap_pi(sk)->mode != L2CAP_MODE_ERTM) &&
 			 (l2cap_pi(sk)->mode != L2CAP_MODE_STREAMING))) {
 			err = -EINVAL;